use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class MenuControlSystem method onPlayerDeath.
@ReceiveEvent(components = CharacterComponent.class)
public void onPlayerDeath(PlayerDeathEvent event, EntityRef character) {
EntityRef client = character.getComponent(CharacterComponent.class).controller;
if (client.getComponent(ClientComponent.class).local) {
nuiManager.removeOverlay("engine:onlinePlayersOverlay");
nuiManager.pushScreen("engine:deathScreen");
if (event.damageTypeName != null) {
((DeathScreen) nuiManager.getScreen("engine:deathScreen")).setDeathDetails(event.instigatorName, event.damageTypeName);
}
}
}
use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class ThirdPersonRemoteClientSystem method ensureClientSideEntityOnHeldItemMountPoint.
/**
* Ensures held item mount point entity exists, attaches it to the character and sets its transform.
*
* @param event the activation that triggered the need to consider changing a held item
* @param character the character for which we need to consider the held item
* @param remotePersonHeldItemMountPointComponent data for the mount point on the remote character
*/
@ReceiveEvent
public void ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent event, EntityRef character, RemotePersonHeldItemMountPointComponent remotePersonHeldItemMountPointComponent) {
if (relatesToLocalPlayer(character)) {
logger.debug("ensureClientSideEntityOnHeldItemMountPoint found its given character to relate to the local" + " player, ignoring: {}", character);
return;
}
// In case we haven't dealt with a given remote player yet set up a non-persistent mount point
if (!remotePersonHeldItemMountPointComponent.mountPointEntity.exists()) {
EntityBuilder builder = entityManager.newBuilder("engine:RemotePersonHeldItemMountPoint");
builder.setPersistent(false);
remotePersonHeldItemMountPointComponent.mountPointEntity = builder.build();
character.saveComponent(remotePersonHeldItemMountPointComponent);
}
// Link the mount point entity to the camera
Location.removeChild(character, remotePersonHeldItemMountPointComponent.mountPointEntity);
Location.attachChild(character, remotePersonHeldItemMountPointComponent.mountPointEntity, remotePersonHeldItemMountPointComponent.translate, new Quaternionf().rotationYXZ(Math.toRadians(remotePersonHeldItemMountPointComponent.rotateDegrees.y), Math.toRadians(remotePersonHeldItemMountPointComponent.rotateDegrees.x), Math.toRadians(remotePersonHeldItemMountPointComponent.rotateDegrees.z)), remotePersonHeldItemMountPointComponent.scale);
}
use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class ThirdPersonRemoteClientSystem method ensureHeldItemIsMountedOnLoad.
@ReceiveEvent
public void ensureHeldItemIsMountedOnLoad(OnChangedComponent event, EntityRef clientEntity, ClientComponent clientComponent) {
if (relatesToLocalPlayer(clientEntity)) {
logger.debug("ensureHeldItemIsMountedOnLoad found its given clientEntity to relate to the local player, " + "ignoring: {}", clientEntity);
return;
}
if (clientEntity.exists() && clientComponent.character != EntityRef.NULL) {
logger.debug("ensureHeldItemIsMountedOnLoad says a given clientEntity exists, has a character, and isn't " + "related to the local player: {}", clientEntity);
CharacterHeldItemComponent characterHeldItemComponent = clientComponent.character.getComponent(CharacterHeldItemComponent.class);
if (characterHeldItemComponent != null && !(clientComponent.character.equals(localPlayer.getCharacterEntity()))) {
linkHeldItemLocationForRemotePlayer(characterHeldItemComponent.selectedItem, clientComponent.character);
}
} else {
logger.debug("ensureHeldItemIsMountedOnLoad given a remote client, but one that didn't properly exist?");
}
}
use of org.terasology.engine.entitySystem.event.ReceiveEvent in project Terasology by MovingBlocks.
the class FirstPersonClientSystem method ensureClientSideEntityOnHeldItemMountPoint.
// ensures held item mount point entity exists, attaches it to the camera and sets its transform
@ReceiveEvent
public void ensureClientSideEntityOnHeldItemMountPoint(OnActivatedComponent event, EntityRef camera, FirstPersonHeldItemMountPointComponent firstPersonHeldItemMountPointComponent) {
if (!firstPersonHeldItemMountPointComponent.mountPointEntity.exists()) {
EntityBuilder builder = entityManager.newBuilder("engine:FirstPersonHeldItemMountPoint");
builder.setPersistent(false);
firstPersonHeldItemMountPointComponent.mountPointEntity = builder.build();
camera.saveComponent(firstPersonHeldItemMountPointComponent);
}
// link the mount point entity to the camera
Location.removeChild(camera, firstPersonHeldItemMountPointComponent.mountPointEntity);
Location.attachChild(camera, firstPersonHeldItemMountPointComponent.mountPointEntity, firstPersonHeldItemMountPointComponent.translate, new Quaternionf().rotationYXZ(TeraMath.DEG_TO_RAD * firstPersonHeldItemMountPointComponent.rotateDegrees.y, TeraMath.DEG_TO_RAD * firstPersonHeldItemMountPointComponent.rotateDegrees.x, TeraMath.DEG_TO_RAD * firstPersonHeldItemMountPointComponent.rotateDegrees.z), firstPersonHeldItemMountPointComponent.scale);
}
use of org.terasology.engine.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);
}
}
Aggregations