Search in sources :

Example 1 with GazeMountPointComponent

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

Example 2 with GazeMountPointComponent

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

the class MovementDebugCommands method playerEyeHeight.

@Command(shortDescription = "Sets the eye-height of the player", runOnServer = true, requiredPermission = PermissionManager.CHEAT_PERMISSION)
public String playerEyeHeight(@Sender EntityRef client, @CommandParam("eye-height") float amount) {
    EntityRef player = client.getComponent(ClientComponent.class).character;
    try {
        GazeMountPointComponent gazeMountPointComponent = player.getComponent(GazeMountPointComponent.class);
        if (gazeMountPointComponent != null) {
            float prevHeight = gazeMountPointComponent.translate.y;
            gazeMountPointComponent.translate.y = amount;
            Location.removeChild(player, gazeMountPointComponent.gazeEntity);
            Location.attachChild(player, gazeMountPointComponent.gazeEntity, gazeMountPointComponent.translate, new Quat4f(Quat4f.IDENTITY));
            player.saveComponent(gazeMountPointComponent);
            return "Eye-height of player set to " + amount + " (was " + prevHeight + ")";
        }
        return "";
    } catch (NullPointerException e) {
        e.printStackTrace();
        return "";
    }
}
Also used : GazeMountPointComponent(org.terasology.logic.characters.GazeMountPointComponent) EntityRef(org.terasology.entitySystem.entity.EntityRef) ClientComponent(org.terasology.network.ClientComponent) Quat4f(org.terasology.math.geom.Quat4f) Command(org.terasology.logic.console.commandSystem.annotations.Command)

Example 3 with GazeMountPointComponent

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

the class LocalPlayerSystem method onPlayerSpawn.

@ReceiveEvent
public void onPlayerSpawn(OnPlayerSpawnedEvent event, EntityRef character) {
    if (character.equals(localPlayer.getCharacterEntity())) {
        // Change height as per PlayerSettings
        Float height = config.getPlayer().getHeight();
        movementDebugCommands.playerHeight(localPlayer.getClientEntity(), height);
        // Change eyeHeight as per PlayerSettings
        Float eyeHeight = config.getPlayer().getEyeHeight();
        GazeMountPointComponent gazeMountPointComponent = character.getComponent(GazeMountPointComponent.class);
        gazeMountPointComponent.translate = new Vector3f(0, eyeHeight, 0);
        // Trigger updating the player camera position as soon as the local player is spawned.
        // This is not done while the game is still loading, since systems are not updated.
        // RenderableWorldImpl pre-generates chunks around the player camera and therefore needs
        // the correct location.
        lookYaw = 0f;
        lookPitch = 0f;
        update(0);
    }
}
Also used : GazeMountPointComponent(org.terasology.logic.characters.GazeMountPointComponent) Vector3f(org.terasology.math.geom.Vector3f) ReceiveEvent(org.terasology.entitySystem.event.ReceiveEvent)

Aggregations

GazeMountPointComponent (org.terasology.logic.characters.GazeMountPointComponent)3 Command (org.terasology.logic.console.commandSystem.annotations.Command)2 ClientComponent (org.terasology.network.ClientComponent)2 EntityRef (org.terasology.entitySystem.entity.EntityRef)1 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)1 CharacterMovementComponent (org.terasology.logic.characters.CharacterMovementComponent)1 Quat4f (org.terasology.math.geom.Quat4f)1 Vector3f (org.terasology.math.geom.Vector3f)1