Search in sources :

Example 6 with ReceiveEvent

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

the class DebugControlSystem method onKeyDown.

@ReceiveEvent(components = ClientComponent.class)
public void onKeyDown(KeyDownEvent event, EntityRef entity) {
    boolean debugEnabled = config.getSystem().isDebugEnabled();
    // Features for debug mode only
    if (debugEnabled) {
        switch(event.getKey().getId()) {
            case Keyboard.KeyId.F6:
                config.getRendering().getDebug().setEnabled(!config.getRendering().getDebug().isEnabled());
                event.consume();
                break;
            case Keyboard.KeyId.F8:
                config.getRendering().getDebug().setRenderChunkBoundingBoxes(!config.getRendering().getDebug().isRenderChunkBoundingBoxes());
                event.consume();
                break;
            case Keyboard.KeyId.F9:
                config.getRendering().getDebug().setWireframe(!config.getRendering().getDebug().isWireframe());
                event.consume();
                break;
            default:
                break;
        }
    }
    switch(event.getKey().getId()) {
        case Keyboard.KeyId.F2:
            mouseGrabbed = !mouseGrabbed;
            DebugProperties debugProperties = (DebugProperties) nuiManager.getHUD().getHUDElement("engine:DebugProperties");
            debugProperties.setVisible(!mouseGrabbed);
            Mouse.setGrabbed(mouseGrabbed);
            event.consume();
            break;
        case Keyboard.KeyId.F3:
            config.getSystem().setDebugEnabled(!config.getSystem().isDebugEnabled());
            event.consume();
            break;
        case Keyboard.KeyId.F4:
            overlay.toggleMetricsMode();
            event.consume();
            break;
        default:
            break;
    }
}
Also used : DebugProperties(org.terasology.logic.debug.DebugProperties) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 7 with ReceiveEvent

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

the class FirstPersonClientSystem method onHeldItemActivated.

@ReceiveEvent
public void onHeldItemActivated(OnActivatedComponent event, EntityRef character, CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
    if (localPlayer.getCharacterEntity().equals(character)) {
        EntityRef newItem = heldItemComponent.selectedItem;
        linkHeldItemLocationForLocalPlayer(newItem);
    }
}
Also used : EntityRef(org.terasology.entitySystem.entity.EntityRef) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 8 with ReceiveEvent

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

the class FirstPersonClientSystem method onHeldItemChanged.

@ReceiveEvent
public void onHeldItemChanged(OnChangedComponent event, EntityRef character, CharacterHeldItemComponent heldItemComponent, CharacterComponent characterComponents) {
    if (localPlayer.getCharacterEntity().equals(character)) {
        EntityRef newItem = heldItemComponent.selectedItem;
        linkHeldItemLocationForLocalPlayer(newItem);
    }
}
Also used : EntityRef(org.terasology.entitySystem.entity.EntityRef) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 9 with ReceiveEvent

use of org.terasology.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.input.events.MouseAxisEvent.MouseAxis) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 10 with ReceiveEvent

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

the class LocalPlayerSystem method onTargetChanged.

@ReceiveEvent
public void onTargetChanged(PlayerTargetChangedEvent event, EntityRef entity) {
    EntityRef target = event.getNewTarget();
    if (target.exists()) {
        LocationComponent location = target.getComponent(LocationComponent.class);
        if (location != null) {
            BlockComponent blockComp = target.getComponent(BlockComponent.class);
            BlockRegionComponent blockRegion = target.getComponent(BlockRegionComponent.class);
            if (blockComp != null || blockRegion != null) {
                Vector3f blockPos = location.getWorldPosition();
                Block block = worldProvider.getBlock(blockPos);
                aabb = block.getBounds(blockPos);
            } else {
                MeshComponent mesh = target.getComponent(MeshComponent.class);
                if (mesh != null && mesh.mesh != null) {
                    aabb = mesh.mesh.getAABB();
                    aabb = aabb.transform(location.getWorldRotation(), location.getWorldPosition(), location.getWorldScale());
                }
            }
        }
    } else {
        aabb = null;
    }
}
Also used : BlockComponent(org.terasology.world.block.BlockComponent) MeshComponent(org.terasology.rendering.logic.MeshComponent) BlockRegionComponent(org.terasology.world.block.regions.BlockRegionComponent) Vector3f(org.terasology.math.geom.Vector3f) Block(org.terasology.world.block.Block) EntityRef(org.terasology.entitySystem.entity.EntityRef) LocationComponent(org.terasology.logic.location.LocationComponent) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Aggregations

ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)98 EntityRef (org.terasology.entitySystem.entity.EntityRef)36 Vector3f (org.terasology.math.geom.Vector3f)26 LocationComponent (org.terasology.logic.location.LocationComponent)17 Vector3i (org.terasology.math.geom.Vector3i)17 PlaySoundEvent (org.terasology.audio.events.PlaySoundEvent)15 StaticSound (org.terasology.audio.StaticSound)13 Block (org.terasology.world.block.Block)11 ClientComponent (org.terasology.network.ClientComponent)7 BlockComponent (org.terasology.world.block.BlockComponent)7 BlockRegionComponent (org.terasology.world.block.regions.BlockRegionComponent)7 EntityBuilder (org.terasology.entitySystem.entity.EntityBuilder)5 CharacterComponent (org.terasology.logic.characters.CharacterComponent)4 OnItemUseEvent (org.terasology.logic.characters.events.OnItemUseEvent)4 ResourceUrn (org.terasology.assets.ResourceUrn)3 Component (org.terasology.entitySystem.Component)3 ItemComponent (org.terasology.logic.inventory.ItemComponent)3 Side (org.terasology.math.Side)3 BoneHealthChangedEvent (org.terasology.anatomy.AnatomySkeleton.event.BoneHealthChangedEvent)2 PartSkeletalDetails (org.terasology.anatomy.component.PartSkeletalDetails)2