Search in sources :

Example 11 with CharacterComponent

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

the class BaseInteractionScreen method getInteractionTarget.

protected EntityRef getInteractionTarget() {
    EntityRef characterEntity = localPlayer.getCharacterEntity();
    CharacterComponent characterComponent = characterEntity.getComponent(CharacterComponent.class);
    return characterComponent.predictedInteractionTarget;
}
Also used : CharacterComponent(org.terasology.engine.logic.characters.CharacterComponent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Example 12 with CharacterComponent

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

the class PlayerSystem method restoreCharacter.

private void restoreCharacter(EntityRef entity, EntityRef character) {
    Client clientListener = networkSystem.getOwner(entity);
    System.out.println(clientListener);
    updateRelevanceEntity(entity, clientListener.getViewDistance().getChunkDistance());
    ClientComponent client = entity.getComponent(ClientComponent.class);
    client.character = character;
    entity.saveComponent(client);
    CharacterComponent characterComp = character.getComponent(CharacterComponent.class);
    if (characterComp != null) {
        characterComp.controller = entity;
        character.saveComponent(characterComp);
        character.setOwner(entity);
        if (!character.hasComponent(AliveCharacterComponent.class)) {
            respawnPlayer(entity);
        }
        Location.attachChild(character, entity, new Vector3f(), new Quaternionf());
    } else {
        character.destroy();
        spawnPlayer(entity);
    }
}
Also used : Vector3f(org.joml.Vector3f) Quaternionf(org.joml.Quaternionf) AliveCharacterComponent(org.terasology.engine.logic.characters.AliveCharacterComponent) CharacterComponent(org.terasology.engine.logic.characters.CharacterComponent) Client(org.terasology.engine.network.Client) ClientComponent(org.terasology.engine.network.ClientComponent) AliveCharacterComponent(org.terasology.engine.logic.characters.AliveCharacterComponent)

Aggregations

CharacterComponent (org.terasology.engine.logic.characters.CharacterComponent)12 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)11 Vector3f (org.joml.Vector3f)4 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)3 Quaternionf (org.joml.Quaternionf)2 ClientComponent (org.terasology.engine.network.ClientComponent)2 EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)1 AliveCharacterComponent (org.terasology.engine.logic.characters.AliveCharacterComponent)1 ActivationPredicted (org.terasology.engine.logic.characters.events.ActivationPredicted)1 ActivationRequest (org.terasology.engine.logic.characters.events.ActivationRequest)1 RangeComponent (org.terasology.engine.logic.common.RangeComponent)1 LocationComponent (org.terasology.engine.logic.location.LocationComponent)1 FirstPersonHeldItemMountPointComponent (org.terasology.engine.logic.players.FirstPersonHeldItemMountPointComponent)1 LocalPlayer (org.terasology.engine.logic.players.LocalPlayer)1 PlayerTargetChangedEvent (org.terasology.engine.logic.players.PlayerTargetChangedEvent)1 Client (org.terasology.engine.network.Client)1 HitResult (org.terasology.engine.physics.HitResult)1 Physics (org.terasology.engine.physics.Physics)1 ResourceUrn (org.terasology.gestalt.assets.ResourceUrn)1