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;
}
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 "";
}
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";
}
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 "";
}
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 "";
}
Aggregations