Search in sources :

Example 1 with ActivationRequestDenied

use of org.terasology.engine.logic.characters.events.ActivationRequestDenied 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.engine.logic.common.ActivateEvent) OnItemUseEvent(org.terasology.engine.logic.characters.events.OnItemUseEvent) ActivationRequestDenied(org.terasology.engine.logic.characters.events.ActivationRequestDenied) ReceiveEvent(org.terasology.engine.entitySystem.event.ReceiveEvent)

Aggregations

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