use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class MovementDebugCommands method showHeight.
@Command(shortDescription = "Show your Height", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String showHeight(@Sender EntityRef client) {
ClientComponent clientComp = client.getComponent(ClientComponent.class);
CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
float height = move.height;
GazeMountPointComponent gazeMountPointComponent = clientComp.character.getComponent(GazeMountPointComponent.class);
float eyeHeight = gazeMountPointComponent.translate.y;
return "Your height: " + height + " Eye-height: " + eyeHeight;
}
use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class LocalPlayerSystem method update.
@Override
public void update(float delta) {
if (!localPlayer.isValid()) {
return;
}
EntityRef entity = localPlayer.getCharacterEntity();
CharacterMovementComponent characterMovementComponent = entity.getComponent(CharacterMovementComponent.class);
processInput(entity, characterMovementComponent);
updateCamera(characterMovementComponent, localPlayer.getViewPosition(), localPlayer.getViewRotation());
}
use of org.terasology.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.
the class HealthAuthoritySystem method doDamage.
private void doDamage(EntityRef entity, int damageAmount, Prefab damageType, EntityRef instigator, EntityRef directCause) {
HealthComponent health = entity.getComponent(HealthComponent.class);
CharacterMovementComponent characterMovementComponent = entity.getComponent(CharacterMovementComponent.class);
boolean ghost = false;
if (characterMovementComponent != null) {
ghost = (characterMovementComponent.mode == MovementMode.GHOSTING);
}
if ((health != null) && !ghost) {
int damagedAmount = health.currentHealth - Math.max(health.currentHealth - damageAmount, 0);
health.currentHealth -= damagedAmount;
health.nextRegenTick = time.getGameTimeInMs() + TeraMath.floorToInt(health.waitBeforeRegen * 1000);
entity.saveComponent(health);
entity.send(new OnDamagedEvent(damageAmount, damagedAmount, damageType, instigator));
if (health.currentHealth == 0 && health.destroyEntityOnNoHealth) {
entity.send(new DestroyEvent(instigator, directCause, damageType));
}
}
}
Aggregations