use of org.terasology.rendering.logic.MeshComponent in project Terasology by MovingBlocks.
the class IterateSingleComponentBenchmark method setup.
@Override
public void setup() {
FastRandom rand = new FastRandom(0L);
rawEntityData = Lists.newArrayList();
for (int i = 0; i < 1000; ++i) {
List<Component> entityData = Lists.newArrayList();
if (rand.nextFloat() < 0.75f) {
entityData.add(new LocationComponent());
}
if (rand.nextFloat() < 0.5f) {
entityData.add(new MeshComponent());
}
if (rand.nextFloat() < 0.25f) {
entityData.add(new BlockComponent());
}
rawEntityData.add(entityData);
}
entityManager = new PojoEntityManager();
for (List<Component> rawEntity : rawEntityData) {
entityManager.create(rawEntity);
}
}
use of org.terasology.rendering.logic.MeshComponent in project Terasology by MovingBlocks.
the class ItemCommonSystem method addOrUpdateItemMeshComponent.
public static void addOrUpdateItemMeshComponent(ItemComponent itemComponent, MutableComponentContainer entity) {
if (itemComponent != null) {
MeshComponent meshComponent = null;
if (entity.hasComponent(MeshComponent.class)) {
meshComponent = entity.getComponent(MeshComponent.class);
} else {
meshComponent = new MeshComponent();
}
meshComponent.material = Assets.getMaterial("engine:droppedItem").get();
if (itemComponent.icon != null) {
meshComponent.mesh = IconMeshFactory.getIconMesh(itemComponent.icon);
}
entity.addOrSaveComponent(meshComponent);
}
}
Aggregations