Search in sources :

Example 36 with ReceiveEvent

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

the class VoxelWorldSystem method onChunkUnloaded.

/**
 * free chunk region from bullet
 *
 * @param beforeChunkUnload
 * @param worldEntity
 */
@ReceiveEvent(components = WorldComponent.class)
public void onChunkUnloaded(BeforeChunkUnload beforeChunkUnload, EntityRef worldEntity) {
    Vector3ic chunkPos = beforeChunkUnload.getChunkPos();
    colliders.forEach(k -> k.unloadChunk(chunkPos));
}
Also used : Vector3ic(org.joml.Vector3ic) ReceiveEvent(org.terasology.engine.entitySystem.event.ReceiveEvent)

Example 37 with ReceiveEvent

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

the class ThirdPersonRemoteClientSystem method onHeldItemActivated.

@ReceiveEvent
public void onHeldItemActivated(OnActivatedComponent event, EntityRef player, CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
    if (relatesToLocalPlayer(player)) {
        logger.debug("onHeldItemActivated found its given player to relate to the local player, ignoring: {}", player);
        return;
    }
    logger.debug("onHeldItemActivated says the given player is not the local player's character entity: {}", player);
    EntityRef newItem = heldItemComponent.selectedItem;
    linkHeldItemLocationForRemotePlayer(newItem, player);
}
Also used : EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ReceiveEvent(org.terasology.engine.entitySystem.event.ReceiveEvent)

Example 38 with ReceiveEvent

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

the class ThirdPersonRemoteClientSystem method onHeldItemChanged.

@ReceiveEvent
public void onHeldItemChanged(OnChangedComponent event, EntityRef character, CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
    if (relatesToLocalPlayer(character)) {
        logger.debug("onHeldItemChanged found its given character to relate to the local player, ignoring: {}", character);
        return;
    }
    logger.debug("onHeldItemChanged says the given character is not the local player's character entity: {}", character);
    EntityRef newItem = heldItemComponent.selectedItem;
    linkHeldItemLocationForRemotePlayer(newItem, character);
}
Also used : EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ReceiveEvent(org.terasology.engine.entitySystem.event.ReceiveEvent)

Example 39 with ReceiveEvent

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

the class LocalPlayerSystem method onFrobButton.

@ReceiveEvent(components = CharacterComponent.class)
public void onFrobButton(FrobButton event, EntityRef character) {
    if (event.getState() != ButtonState.DOWN) {
        return;
    }
    ResourceUrn activeInteractionScreenUri = InteractionUtil.getActiveInteractionScreenUri(character);
    if (activeInteractionScreenUri != null) {
        InteractionUtil.cancelInteractionAsClient(character);
        return;
    }
    boolean activeRequestSent = localPlayer.activateTargetAsClient();
    if (activeRequestSent) {
        event.consume();
    }
}
Also used : ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ReceiveEvent(org.terasology.engine.entitySystem.event.ReceiveEvent)

Example 40 with ReceiveEvent

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

the class LocalPlayerSystem method onMouseMove.

@ReceiveEvent(components = CharacterComponent.class)
public void onMouseMove(MouseAxisEvent event, EntityRef entity) {
    MouseAxis axis = event.getMouseAxis();
    if (axis == MouseAxis.X) {
        lookYawDelta = event.getValue();
    } else if (axis == MouseAxis.Y) {
        lookPitchDelta = event.getValue();
    }
    event.consume();
}
Also used : MouseAxis(org.terasology.engine.input.events.MouseAxisEvent.MouseAxis) ReceiveEvent(org.terasology.engine.entitySystem.event.ReceiveEvent)

Aggregations

ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)83 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)27 Vector3f (org.joml.Vector3f)18 LocationComponent (org.terasology.engine.logic.location.LocationComponent)12 Vector3i (org.joml.Vector3i)10 StaticSound (org.terasology.engine.audio.StaticSound)10 Vector3ic (org.joml.Vector3ic)9 PlaySoundEvent (org.terasology.engine.audio.events.PlaySoundEvent)9 ClientComponent (org.terasology.engine.network.ClientComponent)8 Quaternionf (org.joml.Quaternionf)6 BlockComponent (org.terasology.engine.world.block.BlockComponent)6 OnItemUseEvent (org.terasology.engine.logic.characters.events.OnItemUseEvent)5 Block (org.terasology.engine.world.block.Block)5 CharacterComponent (org.terasology.engine.logic.characters.CharacterComponent)4 BlockRegion (org.terasology.engine.world.block.BlockRegion)4 EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)3 BlockRegionComponent (org.terasology.engine.world.block.regions.BlockRegionComponent)3 Component (org.terasology.gestalt.entitysystem.component.Component)3 Method (java.lang.reflect.Method)2 Vector3fc (org.joml.Vector3fc)2