Search in sources :

Example 46 with ClientComponent

use of org.terasology.network.ClientComponent 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 47 with ClientComponent

use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method pushCharacterCommand.

@Command(value = "pushCharacter", shortDescription = "Pushes you in the direction (x, y, z)", runOnServer = true)
public String pushCharacterCommand(@Sender EntityRef sender, @CommandParam("x") float x, @CommandParam("y") float y, @CommandParam("z") float z) {
    ClientComponent clientComponent = sender.getComponent(ClientComponent.class);
    clientComponent.character.send(new CharacterImpulseEvent(new Vector3f(x, y, z)));
    return "Pushing character with " + x + " " + y + " " + z;
}
Also used : Vector3f(org.terasology.math.geom.Vector3f) ClientComponent(org.terasology.network.ClientComponent) CharacterImpulseEvent(org.terasology.logic.characters.CharacterImpulseEvent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 48 with ClientComponent

use of org.terasology.network.ClientComponent in project Terasology by MovingBlocks.

the class MovementDebugCommands method flight.

@Command(shortDescription = "Grants flight", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String flight(@Sender EntityRef client) {
    ClientComponent clientComp = client.getComponent(ClientComponent.class);
    clientComp.character.send(new SetMovementModeEvent(MovementMode.FLYING));
    return "Flight mode toggled";
}
Also used : SetMovementModeEvent(org.terasology.logic.characters.events.SetMovementModeEvent) ClientComponent(org.terasology.network.ClientComponent) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 49 with ClientComponent

use of org.terasology.network.ClientComponent 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 50 with ClientComponent

use of org.terasology.network.ClientComponent 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)

Aggregations

ClientComponent (org.terasology.network.ClientComponent)64 Command (org.terasology.logic.console.commandSystem.annotations.Command)37 EntityRef (org.terasology.entitySystem.entity.EntityRef)28 LocationComponent (org.terasology.logic.location.LocationComponent)13 Vector3f (org.terasology.math.geom.Vector3f)13 CharacterMovementComponent (org.terasology.logic.characters.CharacterMovementComponent)11 DisplayNameComponent (org.terasology.logic.common.DisplayNameComponent)10 ConsoleCommand (org.terasology.logic.console.commandSystem.ConsoleCommand)8 CharacterTeleportEvent (org.terasology.logic.characters.CharacterTeleportEvent)7 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)5 Prefab (org.terasology.entitySystem.prefab.Prefab)5 LocalPlayer (org.terasology.logic.players.LocalPlayer)4 Quat4f (org.terasology.math.geom.Quat4f)4 ComponentSystemManager (org.terasology.engine.ComponentSystemManager)3 SetMovementModeEvent (org.terasology.logic.characters.events.SetMovementModeEvent)3 DropItemEvent (org.terasology.logic.inventory.events.DropItemEvent)3 Client (org.terasology.network.Client)3 ResourceUrn (org.terasology.assets.ResourceUrn)2 EngineEntityManager (org.terasology.entitySystem.entity.internal.EngineEntityManager)2 EventSystem (org.terasology.entitySystem.event.internal.EventSystem)2