Search in sources :

Example 1 with EntityBuilder

use of org.terasology.entitySystem.entity.EntityBuilder in project Terasology by MovingBlocks.

the class NetworkEntitySerializer method deserialize.

public EntityRef deserialize(EntityData.PackedEntity entityData) {
    EntityBuilder target;
    if (entityData.hasParentPrefabUri()) {
        target = entityManager.newBuilder(entityData.getParentPrefabUri());
    } else {
        target = entityManager.newBuilder();
    }
    deserializeOnto(target, entityData);
    if (entityData.hasId()) {
        return entityManager.createEntityWithId(entityData.getId(), target.iterateComponents());
    } else {
        return target.build();
    }
}
Also used : EntityBuilder(org.terasology.entitySystem.entity.EntityBuilder)

Example 2 with EntityBuilder

use of org.terasology.entitySystem.entity.EntityBuilder in project Terasology by MovingBlocks.

the class CameraClientSystem method ensureCameraEntityCreated.

private void ensureCameraEntityCreated() {
    if (!localPlayer.getCameraEntity().exists()) {
        ClientComponent clientComponent = localPlayer.getClientEntity().getComponent(ClientComponent.class);
        // create the camera from the prefab
        EntityBuilder builder = entityManager.newBuilder("engine:camera");
        builder.setPersistent(false);
        clientComponent.camera = builder.build();
        localPlayer.getClientEntity().saveComponent(clientComponent);
    }
}
Also used : EntityBuilder(org.terasology.entitySystem.entity.EntityBuilder) ClientComponent(org.terasology.network.ClientComponent)

Example 3 with EntityBuilder

use of org.terasology.entitySystem.entity.EntityBuilder in project Terasology by MovingBlocks.

the class FirstPersonClientSystem method getHandEntity.

private EntityRef getHandEntity() {
    if (handEntity == null) {
        // create the hand entity
        EntityBuilder entityBuilder = entityManager.newBuilder("engine:hand");
        entityBuilder.setPersistent(false);
        handEntity = entityBuilder.build();
    }
    return handEntity;
}
Also used : EntityBuilder(org.terasology.entitySystem.entity.EntityBuilder)

Example 4 with EntityBuilder

use of org.terasology.entitySystem.entity.EntityBuilder in project Terasology by MovingBlocks.

the class PlayerFactory method findSpawnPositionFromLocationComponent.

public Vector3f findSpawnPositionFromLocationComponent(LocationComponent locationComponent) {
    EntityBuilder builder = entityManager.newBuilder("engine:player");
    // spawn a little bit above the ground
    float extraSpace = 0.5f;
    float entityHeight = getHeightOf(builder) + extraSpace;
    // TODO: Handle Optional being empty
    return findSpawnPos(locationComponent.getWorldPosition(), entityHeight).get();
}
Also used : EntityBuilder(org.terasology.entitySystem.entity.EntityBuilder)

Example 5 with EntityBuilder

use of org.terasology.entitySystem.entity.EntityBuilder in project Terasology by MovingBlocks.

the class GazeAuthoritySystem method createGazeEntity.

private EntityRef createGazeEntity() {
    EntityBuilder gazeContainerBuilder = entityManager.newBuilder("engine:gaze");
    EntityRef gazeEntity = gazeContainerBuilder.build();
    return gazeEntity;
}
Also used : EntityBuilder(org.terasology.entitySystem.entity.EntityBuilder) EntityRef(org.terasology.entitySystem.entity.EntityRef)

Aggregations

EntityBuilder (org.terasology.entitySystem.entity.EntityBuilder)34 EntityRef (org.terasology.entitySystem.entity.EntityRef)16 LocationComponent (org.terasology.logic.location.LocationComponent)10 NetworkComponent (org.terasology.network.NetworkComponent)7 Test (org.junit.Test)5 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)5 Prefab (org.terasology.entitySystem.prefab.Prefab)5 Vector3f (org.terasology.math.geom.Vector3f)5 Vector3i (org.terasology.math.geom.Vector3i)5 Component (org.terasology.entitySystem.Component)4 DoDamageEvent (org.terasology.logic.health.DoDamageEvent)3 ItemComponent (org.terasology.logic.inventory.ItemComponent)3 Quat4f (org.terasology.math.geom.Quat4f)3 Block (org.terasology.world.block.Block)3 PlaySoundEvent (org.terasology.audio.events.PlaySoundEvent)2 DisplayNameComponent (org.terasology.logic.common.DisplayNameComponent)2 LightComponent (org.terasology.rendering.logic.LightComponent)2 BlockComponent (org.terasology.world.block.BlockComponent)2 Before (org.junit.Before)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1