Search in sources :

Example 11 with CharacterMovementComponent

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

the class HierarchicalAISystem method onBump.

// TODO change eating thingy to use this
@ReceiveEvent(components = { HierarchicalAIComponent.class })
public void onBump(HorizontalCollisionEvent event, EntityRef entity) {
    CharacterMovementComponent moveComp = entity.getComponent(CharacterMovementComponent.class);
    if (moveComp != null && moveComp.grounded) {
        moveComp.jump = true;
        entity.saveComponent(moveComp);
    }
}
Also used : CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Example 12 with CharacterMovementComponent

use of org.terasology.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.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 13 with CharacterMovementComponent

use of org.terasology.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.logic.characters.CharacterMovementComponent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 14 with CharacterMovementComponent

use of org.terasology.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 = Vector3f.zero();
    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();
                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.logic.common.DisplayNameComponent) SetMovementModeEvent(org.terasology.logic.characters.events.SetMovementModeEvent) CharacterTeleportEvent(org.terasology.logic.characters.CharacterTeleportEvent) MovementMode(org.terasology.logic.characters.MovementMode) Vector3f(org.terasology.math.geom.Vector3f) CharacterMovementComponent(org.terasology.logic.characters.CharacterMovementComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) LocationComponent(org.terasology.logic.location.LocationComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 15 with CharacterMovementComponent

use of org.terasology.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.logic.characters.CharacterMovementComponent) ResourceUrn(org.terasology.assets.ResourceUrn) ClientComponent(org.terasology.network.ClientComponent) Prefab(org.terasology.entitySystem.prefab.Prefab) Command(org.terasology.logic.console.commandSystem.annotations.Command)

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