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();
}
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();
}
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();
}
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;
}
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);
}
}
Aggregations