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;
}
}
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);
}
}
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);
}
}
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();
}
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;
}
}
Aggregations