Search in sources :

Example 1 with CreateVisualCharacterEvent

use of org.terasology.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.entitySystem.entity.EntityBuilder) CreateVisualCharacterEvent(org.terasology.logic.characters.events.CreateVisualCharacterEvent) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

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