Search in sources :

Example 1 with ActivateEvent

use of org.terasology.logic.common.ActivateEvent in project Terasology by MovingBlocks.

the class CharacterSystem method onActivationRequest.

@ReceiveEvent(components = { CharacterComponent.class, LocationComponent.class }, netFilter = RegisterMode.AUTHORITY)
public void onActivationRequest(ActivationRequest event, EntityRef character) {
    if (isPredictionOfEventCorrect(character, event)) {
        OnItemUseEvent onItemUseEvent = new OnItemUseEvent();
        event.getInstigator().send(onItemUseEvent);
        if (!onItemUseEvent.isConsumed()) {
            if (event.getUsedOwnedEntity().exists()) {
                event.getUsedOwnedEntity().send(new ActivateEvent(event));
            } else {
                event.getTarget().send(new ActivateEvent(event));
            }
        }
    } else {
        character.send(new ActivationRequestDenied(event.getActivationId()));
    }
}
Also used : ActivateEvent(org.terasology.logic.common.ActivateEvent) OnItemUseEvent(org.terasology.logic.characters.events.OnItemUseEvent) ActivationRequestDenied(org.terasology.logic.characters.events.ActivationRequestDenied) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Aggregations

ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)1 ActivationRequestDenied (org.terasology.logic.characters.events.ActivationRequestDenied)1 OnItemUseEvent (org.terasology.logic.characters.events.OnItemUseEvent)1 ActivateEvent (org.terasology.logic.common.ActivateEvent)1