Search in sources :

Example 6 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 7 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 8 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)

Example 9 with CharacterMovementComponent

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

the class MovementDebugCommands method hspeed.

@Command(shortDescription = "Go really fast", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String hspeed(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        move.speedMultiplier = 10f;
        move.jumpSpeed = 24f;
        clientComp.character.saveComponent(move);
        return "High-speed 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 10 with CharacterMovementComponent

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

the class MovementDebugCommands method showMovement.

@Command(shortDescription = "Show your Movement stats", requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String showMovement(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    CharacterMovementComponent move = clientComp.character.getComponent(CharacterMovementComponent.class);
    if (move != null) {
        return "Your SpeedMultiplier:" + move.speedMultiplier + " JumpSpeed:" + move.jumpSpeed + " SlopeFactor:" + move.slopeFactor + " RunFactor:" + move.runFactor;
    }
    return "You're dead I guess.";
}
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