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