Search in sources :

Example 1 with CharacterMovementComponent

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

the class MovementDebugCommands method playerHeight.

@Command(shortDescription = "Sets the height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerHeight(@Sender EntityRef entity, @CommandParam("height") float newHeight) {
    if (newHeight > 0.5 && newHeight <= 20) {
        ClientComponent client = entity.getComponent(ClientComponent.class);
        if (client != null) {
            EntityRef character = client.character;
            CharacterMovementComponent movement = client.character.getComponent(CharacterMovementComponent.class);
            if (movement != null) {
                float currentHeight = movement.height;
                ScaleToRequest scaleRequest = new ScaleToRequest(newHeight);
                character.send(scaleRequest);
                return "Height of player set to " + newHeight + " (was " + currentHeight + ")";
            }
        }
    } else {
        return "Invalid input. Accepted values: [1 to 25]";
    }
    return "";
}
Also used : CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.engine.network.ClientComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ScaleToRequest(org.terasology.engine.logic.characters.events.ScaleToRequest) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 2 with CharacterMovementComponent

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

the class MovementDebugCommands method hjump.

@Command(shortDescription = "Jump really high", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String hjump(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        move.jumpSpeed = 75f;
        clientComp.character.saveComponent(move);
        return "High-jump mode activated";
    }
    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 3 with CharacterMovementComponent

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

the class MovementDebugCommands method teleportAllPlayersToPlayer.

@Command(shortDescription = "Teleport all users to specified user", runOnServer = true, requiredPermission = PermissionManager.USER_MANAGEMENT_PERMISSION)
public String teleportAllPlayersToPlayer(@CommandParam("username") String username) {
    Vector3f vPlayerLocation = new Vector3f();
    boolean bPlayerLocationWasFound = false;
    EntityRef playerEntity = null;
    for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
        EntityRef clientInfo = clientEntity.getComponent(ClientComponent.class).clientInfo;
        DisplayNameComponent name = clientInfo.getComponent(DisplayNameComponent.class);
        if (username.equalsIgnoreCase(name.name)) {
            LocationComponent locationComponent = clientEntity.getComponent(LocationComponent.class);
            if (locationComponent != null) {
                vPlayerLocation = locationComponent.getWorldPosition(new Vector3f());
                bPlayerLocationWasFound = true;
                playerEntity = clientEntity;
            }
            break;
        }
    }
    if (!bPlayerLocationWasFound) {
        throw new IllegalArgumentException("No such user '" + username + "'");
    }
    MovementMode playerMovementMode = MovementMode.NONE;
    ClientComponent clientInfo = playerEntity.getComponent(ClientComponent.class);
    if (clientInfo != null) {
        CharacterMovementComponent playerMovementComponent = clientInfo.character.getComponent(CharacterMovementComponent.class);
        if (playerMovementComponent != null) {
            playerMovementMode = playerMovementComponent.mode;
        }
    }
    for (EntityRef clientEntity : entityManager.getEntitiesWith(ClientComponent.class)) {
        ClientComponent clientComp = clientEntity.getComponent(ClientComponent.class);
        if (clientComp != null) {
            clientComp.character.send(new CharacterTeleportEvent(vPlayerLocation));
            CharacterMovementComponent characterMovementComponent = clientComp.character.getComponent(CharacterMovementComponent.class);
            if (characterMovementComponent != null && playerMovementMode != MovementMode.NONE && playerMovementMode != characterMovementComponent.mode) {
                clientComp.character.send(new SetMovementModeEvent(playerMovementMode));
            }
        }
    }
    return "All possible players teleported to " + username + " and set to " + playerMovementMode;
}
Also used : DisplayNameComponent(org.terasology.engine.logic.common.DisplayNameComponent) SetMovementModeEvent(org.terasology.engine.logic.characters.events.SetMovementModeEvent) CharacterTeleportEvent(org.terasology.engine.logic.characters.CharacterTeleportEvent) MovementMode(org.terasology.engine.logic.characters.MovementMode) Vector3f(org.joml.Vector3f) CharacterMovementComponent(org.terasology.engine.logic.characters.CharacterMovementComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef) ClientComponent(org.terasology.engine.network.ClientComponent) LocationComponent(org.terasology.engine.logic.location.LocationComponent) Command(org.terasology.engine.logic.console.commandSystem.annotations.Command)

Example 4 with CharacterMovementComponent

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

the class MovementDebugCommands method setJumpSpeed.

@Command(shortDescription = "Set jump speed", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String setJumpSpeed(@Sender EntityRef client, @CommandParam("amount") float amount) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        float oldSpeed = move.jumpSpeed;
        move.jumpSpeed = amount;
        clientComp.character.saveComponent(move);
        return "Jump speed set to " + amount + " (was " + oldSpeed + ")";
    }
    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 5 with CharacterMovementComponent

use of org.terasology.engine.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.engine.logic.characters.GazeMountPointComponent) 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