Search in sources :

Example 6 with MeshComponent

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);
    }
}
Also used : BlockComponent(org.terasology.world.block.BlockComponent) MeshComponent(org.terasology.rendering.logic.MeshComponent) PojoEntityManager(org.terasology.entitySystem.entity.internal.PojoEntityManager) FastRandom(org.terasology.utilities.random.FastRandom) MeshComponent(org.terasology.rendering.logic.MeshComponent) BlockComponent(org.terasology.world.block.BlockComponent) Component(org.terasology.entitySystem.Component) LocationComponent(org.terasology.logic.location.LocationComponent) LocationComponent(org.terasology.logic.location.LocationComponent)

Example 7 with MeshComponent

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);
    }
}
Also used : MeshComponent(org.terasology.rendering.logic.MeshComponent)

Aggregations

MeshComponent (org.terasology.rendering.logic.MeshComponent)7 LocationComponent (org.terasology.logic.location.LocationComponent)5 BlockComponent (org.terasology.world.block.BlockComponent)4 Component (org.terasology.entitySystem.Component)3 FastRandom (org.terasology.utilities.random.FastRandom)3 EntityRef (org.terasology.entitySystem.entity.EntityRef)2 PojoEntityManager (org.terasology.entitySystem.entity.internal.PojoEntityManager)2 ReceiveEvent (org.terasology.entitySystem.event.ReceiveEvent)1 Vector3f (org.terasology.math.geom.Vector3f)1 LightComponent (org.terasology.rendering.logic.LightComponent)1 Block (org.terasology.world.block.Block)1 BlockFamily (org.terasology.world.block.family.BlockFamily)1 BlockRegionComponent (org.terasology.world.block.regions.BlockRegionComponent)1