Package org.terasology.logic.characters

Examples of org.terasology.logic.characters.CharacterComponent


    }

    @Override
    public void renderFirstPerson() {
        CharacterComponent character = localPlayer.getCharacterEntity().getComponent(CharacterComponent.class);
        if (character == null) {
            return;
        }
        CharacterMovementComponent charMoveComp = localPlayer.getCharacterEntity().getComponent(CharacterMovementComponent.class);
        if (charMoveComp == null) {
View Full Code Here


            return;
        }

        int slot = InventoryUtils.getSlotWithItem(item.getOwner(), item);
        if (slot != -1 && item.getOwner().hasComponent(CharacterComponent.class)) {
            CharacterComponent character = item.getOwner().getComponent(CharacterComponent.class);
            if (slot == character.selectedItem) {
                item.getOwner().removeComponent(LightComponent.class);
            }
        }
    }
View Full Code Here

        }
        return location.getWorldRotation();
    }

    public Quat4f getViewRotation() {
        CharacterComponent character = getCharacterEntity().getComponent(CharacterComponent.class);
        if (character == null) {
            return new Quat4f(0, 0, 0, 1);
        }
        Quat4f rot = new Quat4f();
        QuaternionUtil.setEuler(rot, TeraMath.DEG_TO_RAD * character.yaw, TeraMath.DEG_TO_RAD * character.pitch, 0);
View Full Code Here

        QuaternionUtil.setEuler(rot, TeraMath.DEG_TO_RAD * character.yaw, TeraMath.DEG_TO_RAD * character.pitch, 0);
        return rot;
    }

    public Vector3f getViewDirection() {
        CharacterComponent character = getCharacterEntity().getComponent(CharacterComponent.class);
        if (character == null) {
            return Direction.FORWARD.getVector3f();
        }
        Quat4f rot = new Quat4f();
        QuaternionUtil.setEuler(rot, TeraMath.DEG_TO_RAD * character.yaw, TeraMath.DEG_TO_RAD * character.pitch, 0);
View Full Code Here

     * @return true if an activation request got sent. Returns always true if usedItem exists.
     */
    private boolean activateTargetOrOwnedEntity(EntityRef usedOwnedEntity) {
        EntityRef character = getCharacterEntity();
        LocationComponent location = character.getComponent(LocationComponent.class);
        CharacterComponent characterComponent = character.getComponent(CharacterComponent.class);
        Vector3f direction = characterComponent.getLookDirection();
        Vector3f originPos = location.getWorldPosition();
        originPos.y += characterComponent.eyeOffset;
        boolean ownedEntityUsage = usedOwnedEntity.exists();
        int activationId = nextActivationId++;
        Physics physics = CoreRegistry.get(Physics.class);
View Full Code Here

    @ReceiveEvent(components = {InteractionTargetComponent.class}, netFilter = RegisterMode.AUTHORITY)
    public void onActivate(ActivateEvent event, EntityRef target) {
        EntityRef instigator = event.getInstigator();

        CharacterComponent characterComponent = instigator.getComponent(CharacterComponent.class);
        if (characterComponent == null) {
            logger.error("Interaction start request instigator has no character component");
            return;
        }
        if (characterComponent.authorizedInteractionTarget.exists()) {
View Full Code Here

    }

    @ReceiveEvent(components = {InteractionTargetComponent.class})
    public void onActivationPredicted(ActivationPredicted event, EntityRef target) {
        EntityRef character = event.getInstigator();
        CharacterComponent characterComponent = character.getComponent(CharacterComponent.class);
        if (characterComponent == null) {
            return;
        }
        if (characterComponent.predictedInteractionTarget.exists()) {
            InteractionUtil.cancelInteractionAsClient(character);
View Full Code Here

    @ReceiveEvent(components = {InteractionScreenComponent.class})
    public void onInteractionStartPredicted(InteractionStartPredicted event, EntityRef container,
                                   InteractionScreenComponent interactionScreenComponent) {
        EntityRef investigator = event.getInstigator();
        CharacterComponent characterComponent = investigator.getComponent(CharacterComponent.class);
        if (characterComponent == null) {
            logger.error("Interaction start predicted for entity without character component");
            return;
        }
        ClientComponent controller = characterComponent.controller.getComponent(ClientComponent.class);
View Full Code Here

    public static void cancelInteractionAsClient(EntityRef character) {
        cancelInteractionAsClient(character, true);
    }

    static void cancelInteractionAsClient(EntityRef character, boolean notifyServer) {
        CharacterComponent characterComponent = character.getComponent(CharacterComponent.class);
        if (characterComponent == null) {
            logger.error("Interaction instigator has no character component");
            return;
        }
View Full Code Here

        }
    }


    public static void cancelInteractionAsServer(EntityRef character) {
        CharacterComponent characterComponent = character.getComponent(CharacterComponent.class);
        if (characterComponent == null) {
            logger.error("Interaction end request instigator has no character component");
            return;
        }
        int oldInteractionId = characterComponent.authorizedInteractionId;
View Full Code Here

TOP

Related Classes of org.terasology.logic.characters.CharacterComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.