Search in sources :

Example 21 with EntityBuilder

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

the class PojoEntityPool method create.

@Override
public EntityRef create(Iterable<Component> components, boolean sendLifecycleEvents) {
    EntityBuilder builder = newBuilder();
    builder.addComponents(components);
    builder.setSendLifecycleEvents(sendLifecycleEvents);
    return builder.build();
}
Also used : EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder)

Example 22 with EntityBuilder

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

the class PojoEntityPool method createEntityWithId.

@Override
public EntityRef createEntityWithId(long id, Iterable<Component> components) {
    EntityBuilder builder = newBuilder();
    builder.setId(id);
    builder.addComponents(components);
    return builder.build();
}
Also used : EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder)

Example 23 with EntityBuilder

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

the class PojoEntityPool method create.

private EntityRef create(Prefab prefab, Vector3fc position, Quaternionfc rotation, boolean sendLifecycleEvents) {
    EntityBuilder builder = newBuilder(prefab);
    builder.setSendLifecycleEvents(sendLifecycleEvents);
    LocationComponent loc = builder.getComponent(LocationComponent.class);
    if (loc == null && (position != null || rotation != null)) {
        loc = new LocationComponent();
        builder.addComponent(loc);
    }
    if (position != null) {
        loc.setWorldPosition(position);
    }
    if (rotation != null) {
        loc.setWorldRotation(rotation);
    }
    return builder.build();
}
Also used : EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder) LocationComponent(org.terasology.engine.logic.location.LocationComponent)

Example 24 with EntityBuilder

use of org.terasology.engine.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.engine.entitySystem.entity.EntityBuilder) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Example 25 with EntityBuilder

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

the class BehaviorNodeFactory method refreshPrefabs.

private void refreshPrefabs() {
    Collection<Prefab> prefabs = prefabManager.listPrefabs(BehaviorNodeComponent.class);
    if (prefabs.size() == 0) {
        // called from main menu
        List<String> nodes = Arrays.asList("counter", "timer", "loop", "lookup", "dynselector", "fail", "parallel", "playMusic", "playSound", "running", "selector", "setAnimation", "sequence", "succeed");
        prefabs = Lists.newArrayList();
        for (String node : nodes) {
            prefabs.add(Assets.get(new ResourceUrn("engine:" + node), Prefab.class).orElse(null));
        }
    }
    for (Prefab prefab : prefabs) {
        EntityBuilder entityBuilder = entityManager.newBuilder(prefab);
        entityBuilder.setPersistent(false);
        EntityRef entityRef = entityBuilder.build();
        BehaviorNodeComponent component = entityRef.getComponent(BehaviorNodeComponent.class);
        addToCategory(component);
        nodeComponents.add(component);
    }
}
Also used : EntityBuilder(org.terasology.engine.entitySystem.entity.EntityBuilder) ResourceUrn(org.terasology.gestalt.assets.ResourceUrn) Prefab(org.terasology.engine.entitySystem.prefab.Prefab) EntityRef(org.terasology.engine.entitySystem.entity.EntityRef)

Aggregations

EntityBuilder (org.terasology.engine.entitySystem.entity.EntityBuilder)29 EntityRef (org.terasology.engine.entitySystem.entity.EntityRef)12 NetworkComponent (org.terasology.engine.network.NetworkComponent)7 LocationComponent (org.terasology.engine.logic.location.LocationComponent)6 Vector3f (org.joml.Vector3f)5 Test (org.junit.jupiter.api.Test)5 Quaternionf (org.joml.Quaternionf)4 Prefab (org.terasology.engine.entitySystem.prefab.Prefab)4 ReceiveEvent (org.terasology.engine.entitySystem.event.ReceiveEvent)3 BlockComponent (org.terasology.engine.world.block.BlockComponent)2 Component (org.terasology.gestalt.entitysystem.component.Component)2 Vector3i (org.joml.Vector3i)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1 StaticSound (org.terasology.engine.audio.StaticSound)1 PlaySoundEvent (org.terasology.engine.audio.events.PlaySoundEvent)1 Context (org.terasology.engine.context.Context)1 ContextImpl (org.terasology.engine.context.internal.ContextImpl)1 EntityManager (org.terasology.engine.entitySystem.entity.EntityManager)1