Search in sources :

Example 16 with CharacterMovementComponent

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;
}
Also used : GazeMountPointComponent(org.terasology.logic.characters.GazeMountPointComponent) CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 17 with CharacterMovementComponent

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());
}
Also used : CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Example 18 with CharacterMovementComponent

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));
        }
    }
}
Also used : CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent)

Aggregations

CharacterMovementComponent (org.terasology.logic.characters.CharacterMovementComponent)18 Command (org.terasology.logic.console.commandSystem.annotations.Command)11 ClientComponent (org.terasology.network.ClientComponent)11 LocationComponent (org.terasology.logic.location.LocationComponent)3 Vector3f (org.terasology.math.geom.Vector3f)3 CapsuleShape (com.bulletphysics.collision.shapes.CapsuleShape)2 Vector3f (javax.vecmath.Vector3f)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)2 Prefab (org.terasology.entitySystem.prefab.Prefab)2 CharacterTeleportEvent (org.terasology.logic.characters.CharacterTeleportEvent)2 BoxShape (com.bulletphysics.collision.shapes.BoxShape)1 ConvexHullShape (com.bulletphysics.collision.shapes.ConvexHullShape)1 ConvexShape (com.bulletphysics.collision.shapes.ConvexShape)1 CylinderShape (com.bulletphysics.collision.shapes.CylinderShape)1 SphereShape (com.bulletphysics.collision.shapes.SphereShape)1 ObjectArrayList (com.bulletphysics.util.ObjectArrayList)1 TFloatIterator (gnu.trove.iterator.TFloatIterator)1 ArrayList (java.util.ArrayList)1 ResourceUrn (org.terasology.assets.ResourceUrn)1