Search in sources :

Example 1 with ConsumableEvent

use of org.terasology.engine.entitySystem.event.ConsumableEvent in project Terasology by MovingBlocks.

the class EventSystemImpl method send.

@Override
public void send(EntityRef entity, Event event) {
    if (Thread.currentThread() != mainThread) {
        pendingEvents.offer(new PendingEvent(entity, event));
    } else {
        Set<EventHandlerInfo> selectedHandlersSet = selectEventHandlers(event.getClass(), entity);
        List<EventHandlerInfo> selectedHandlers = Lists.newArrayList(selectedHandlersSet);
        selectedHandlers.sort(priorityComparator);
        if (event instanceof ConsumableEvent) {
            sendConsumableEvent(entity, event, selectedHandlers);
        } else {
            sendStandardEvent(entity, event, selectedHandlers);
        }
    }
}
Also used : PendingEvent(org.terasology.engine.entitySystem.event.PendingEvent) AbstractConsumableEvent(org.terasology.engine.entitySystem.event.AbstractConsumableEvent) ConsumableEvent(org.terasology.engine.entitySystem.event.ConsumableEvent)

Example 2 with ConsumableEvent

use of org.terasology.engine.entitySystem.event.ConsumableEvent in project Terasology by MovingBlocks.

the class EventSystemReplayImpl method originalSend.

// send method of EventSystemImpl
private void originalSend(EntityRef entity, Event event) {
    if (Thread.currentThread() != mainThread) {
        pendingEvents.offer(new PendingEvent(entity, event));
    } else {
        networkReplicate(entity, event);
        Set<EventHandlerInfo> selectedHandlersSet = selectEventHandlers(event.getClass(), entity);
        List<EventHandlerInfo> selectedHandlers = Lists.newArrayList(selectedHandlersSet);
        selectedHandlers.sort(priorityComparator);
        if (event instanceof ConsumableEvent) {
            sendConsumableEvent(entity, event, selectedHandlers);
        } else {
            sendStandardEvent(entity, event, selectedHandlers);
        }
    }
}
Also used : PendingEvent(org.terasology.engine.entitySystem.event.PendingEvent) AbstractConsumableEvent(org.terasology.engine.entitySystem.event.AbstractConsumableEvent) ConsumableEvent(org.terasology.engine.entitySystem.event.ConsumableEvent)

Aggregations

AbstractConsumableEvent (org.terasology.engine.entitySystem.event.AbstractConsumableEvent)2 ConsumableEvent (org.terasology.engine.entitySystem.event.ConsumableEvent)2 PendingEvent (org.terasology.engine.entitySystem.event.PendingEvent)2