Search in sources :

Example 11 with CharacterMovementComponent

use of org.terasology.engine.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.

the class PlayerFactory method getHeightOf.

private float getHeightOf(ComponentContainer prefab) {
    CharacterMovementComponent movementComponent = prefab.getComponent(CharacterMovementComponent.class);
    if (movementComponent != null) {
        return movementComponent.height;
    }
    logger.warn("entity {} does not have a CharacterMovementComponent - using default height", prefab);
    return 1.0f;
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent)

Example 12 with CharacterMovementComponent

use of org.terasology.engine.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method sleigh.

@Command(shortDescription = "Toggles the maximum slope the player can walk up", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String sleigh(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        float oldFactor = move.slopeFactor;
        if (move.slopeFactor > 0.7f) {
            move.slopeFactor = 0.6f;
        } else {
            move.slopeFactor = 0.9f;
        }
        clientComp.character.saveComponent(move);
        return "Slope factor is now " + move.slopeFactor + " (was " + oldFactor + ")";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 13 with CharacterMovementComponent

use of org.terasology.engine.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method restoreSpeed.

@Command(shortDescription = "Restore normal speed values", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String restoreSpeed(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    Optional<Prefab> prefab = Assets.get(new ResourceUrn("engine:player"), Prefab.class);
    CharacterMovementComponent moveDefault = prefab.get().getComponent(CharacterMovementComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null && moveDefault != null) {
        move.jumpSpeed = moveDefault.jumpSpeed;
        move.speedMultiplier = moveDefault.speedMultiplier;
        move.runFactor = moveDefault.runFactor;
        move.stepHeight = moveDefault.stepHeight;
        move.slopeFactor = moveDefault.slopeFactor;
        move.distanceBetweenFootsteps = moveDefault.distanceBetweenFootsteps;
        clientComp.character.saveComponent(move);
    }
    return "Normal speed values restored";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) ClientComponent(org.terasology.engine.network.ClientComponent) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 14 with CharacterMovementComponent

use of org.terasology.engine.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method stepHeight.

@Command(shortDescription = "Sets the height the player can step up", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String stepHeight(@Sender EntityRef client, @CommandParam("height") float amount) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        float prevStepHeight = move.stepHeight;
        move.stepHeight = amount;
        clientComp.character.saveComponent(move);
        return "Ground friction set to " + amount + " (was " + prevStepHeight + ")";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 15 with CharacterMovementComponent

use of org.terasology.engine.logic.characters.CharacterMovementComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method setSpeedMultiplier.

@Command(shortDescription = "Set speed multiplier", helpText = "Set speedMultiplier", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setSpeedMultiplier(@Sender EntityRef client, @CommandParam("amount") float amount) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        float oldSpeedMultipler = move.speedMultiplier;
        move.speedMultiplier = amount;
        clientComp.character.saveComponent(move);
        return "Speed multiplier set to " + amount + " (was " + oldSpeedMultipler + ")";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.engine.network.ClientComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Aggregations

CharacterMovementComponent (org.terasology.engine.logic.characters.CharacterMovementComponent)15 Command (org.terasology.engine.logic.console.commandSystem.annotations.Command)11 ClientComponent (org.terasology.engine.network.ClientComponent)11 Vector3f (org.joml.Vector3f)4 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)3 com.badlogic.gdx.physics.bullet.collision.btCapsuleShape (com.badlogic.gdx.physics.bullet.collision.btCapsuleShape)2 LocationComponent (org.terasology.engine.logic.location.LocationComponent)2 com.badlogic.gdx.physics.bullet.collision.btBoxShape (com.badlogic.gdx.physics.bullet.collision.btBoxShape)1 com.badlogic.gdx.physics.bullet.collision.btConvexHullShape (com.badlogic.gdx.physics.bullet.collision.btConvexHullShape)1 com.badlogic.gdx.physics.bullet.collision.btConvexShape (com.badlogic.gdx.physics.bullet.collision.btConvexShape)1 com.badlogic.gdx.physics.bullet.collision.btCylinderShape (com.badlogic.gdx.physics.bullet.collision.btCylinderShape)1 com.badlogic.gdx.physics.bullet.collision.btManifoldPoint (com.badlogic.gdx.physics.bullet.collision.btManifoldPoint)1 com.badlogic.gdx.physics.bullet.collision.btSphereShape (com.badlogic.gdx.physics.bullet.collision.btSphereShape)1 FloatBuffer (java.nio.FloatBuffer)1 Quaternionf (org.joml.Quaternionf)1 Vector3fc (org.joml.Vector3fc)1 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)1 CharacterTeleportEvent (org.terasology.engine.logic.characters.CharacterTeleportEvent)1 GazeMountPointComponent (org.terasology.engine.logic.characters.GazeMountPointComponent)1 MovementMode (org.terasology.engine.logic.characters.MovementMode)1