Search in sources :

Example 1 with CreateVisualCharacterEvent

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

the class VisualCharacterSystem method createVisualCharacterIfNotOwnCharacter.

void createVisualCharacterIfNotOwnCharacter(EntityRef characterEntity, VisualCharacterComponent visualCharacterComponent) {
    boolean isCharacterOfLocalPlayer = characterEntity.getOwner().equals(localPlayer.getClientEntity());
    if (isCharacterOfLocalPlayer) {
        return;
    }
    CreateVisualCharacterEvent event = new CreateVisualCharacterEvent(entityManager.newBuilder());
    characterEntity.send(event);
    EntityBuilder entityBuilder = event.getVisualCharacterBuilder();
    EntityRef visualCharacterEntity = createAndAttachVisualEntityStrategy.createAndAttachVisualEntity(entityBuilder, characterEntity);
    visualCharacterComponent.visualCharacter = visualCharacterEntity;
    characterEntity.saveComponent(visualCharacterComponent);
}
Also used : EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder) CreateVisualCharacterEvent(org.terasology.engine.logic.characters.events.CreateVisualCharacterEvent) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Aggregations

EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)1 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)1 CreateVisualCharacterEvent (org.terasology.engine.logic.characters.events.CreateVisualCharacterEvent)1