Search in sources :

Example 31 with World

use of com.artemis.World in project commons-gdx by gemserk.

the class GetComponentPerformanceTest method testTimeWithGetComponentUsingTypeAndCacheClass.

public long testTimeWithGetComponentUsingTypeAndCacheClass(int iterations) {
    World world = new World();
    Entity e = world.createEntity();
    e.addComponent(new MyTestComponent());
    e.refresh();
    ComponentType myTestComponentType = ComponentTypeManager.getTypeFor(MyTestComponent.class);
    Class<MyTestComponent> myTestComponentClass = MyTestComponent.class;
    long startNanoTime = System.nanoTime();
    for (int i = 0; i < iterations; i++) {
        // MyTestComponent myTestComponent = myTestComponentClass.cast(e.getComponent(myTestComponentType.getId()));
        myTestComponentClass.cast(e.getComponent(myTestComponentType.getId()));
    }
    return System.nanoTime() - startNanoTime;
}
Also used : Entity(com.artemis.Entity) ComponentType(com.artemis.ComponentType) World(com.artemis.World)

Example 32 with World

use of com.artemis.World in project commons-gdx by gemserk.

the class GetComponentPerformanceTest method testTimeWithGetComponentFromClassWithClassCache.

public long testTimeWithGetComponentFromClassWithClassCache(int iterations) {
    World world = new World();
    Entity e = world.createEntity();
    e.addComponent(new MyTestComponent());
    e.refresh();
    Class<MyTestComponent> myTestComponentClass = MyTestComponent.class;
    long startNanoTime = System.nanoTime();
    for (int i = 0; i < iterations; i++) {
        // MyTestComponent myTestComponent = e.getComponent(myTestComponentClass);
        e.getComponent(myTestComponentClass);
    }
    return System.nanoTime() - startNanoTime;
}
Also used : Entity(com.artemis.Entity) World(com.artemis.World)

Example 33 with World

use of com.artemis.World in project commons-gdx by gemserk.

the class GetComponentPerformanceTest method testTimeWithGetComponentUsingTypeAndClass.

public long testTimeWithGetComponentUsingTypeAndClass(int iterations) {
    World world = new World();
    Entity e = world.createEntity();
    e.addComponent(new MyTestComponent());
    e.refresh();
    ComponentType myTestComponentType = ComponentTypeManager.getTypeFor(MyTestComponent.class);
    long startNanoTime = System.nanoTime();
    for (int i = 0; i < iterations; i++) {
        // MyTestComponent myTestComponent = MyTestComponent.class.cast(e.getComponent(myTestComponentType.getId()));
        MyTestComponent.class.cast(e.getComponent(myTestComponentType.getId()));
    }
    return System.nanoTime() - startNanoTime;
}
Also used : Entity(com.artemis.Entity) ComponentType(com.artemis.ComponentType) World(com.artemis.World)

Example 34 with World

use of com.artemis.World in project commons-gdx by gemserk.

the class OrderedByLayerEntitiesTest method shouldReturnSubEntityBeforeAnotherEntityIfParentEntityBeforeThatOne.

@Test
public void shouldReturnSubEntityBeforeAnotherEntityIfParentEntityBeforeThatOne() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    Entity e3 = world.createEntity();
    e1.addComponent(new RenderableComponent(5, 0));
    e2.addComponent(new RenderableComponent(5));
    e3.addComponent(new RenderableComponent(5, 1, true));
    e3.addComponent(new OwnerComponent(e1));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    orderedByLayerEntities.add(e3);
    assertSame(orderedByLayerEntities.get(0), e1);
    assertSame(orderedByLayerEntities.get(1), e3);
    assertSame(orderedByLayerEntities.get(2), e2);
}
Also used : Entity(com.artemis.Entity) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) RenderableComponent(com.gemserk.commons.artemis.components.RenderableComponent) World(com.artemis.World) Test(org.junit.Test)

Example 35 with World

use of com.artemis.World in project commons-gdx by gemserk.

the class OrderedByLayerEntitiesTest method bugEntityWithNullOwner.

@Test
public void bugEntityWithNullOwner() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    e1.addComponent(new RenderableComponent(5));
    e2.addComponent(new RenderableComponent(5));
    e2.addComponent(new OwnerComponent(null));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    assertSame(orderedByLayerEntities.get(0), e1);
    assertSame(orderedByLayerEntities.get(1), e2);
}
Also used : Entity(com.artemis.Entity) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) RenderableComponent(com.gemserk.commons.artemis.components.RenderableComponent) World(com.artemis.World) Test(org.junit.Test)

Aggregations

World (com.artemis.World)39 Entity (com.artemis.Entity)38 Test (org.junit.Test)31 RenderableComponent (com.gemserk.commons.artemis.components.RenderableComponent)15 OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)14 WorldWrapper (com.gemserk.commons.artemis.WorldWrapper)8 EntityFactory (com.gemserk.commons.artemis.templates.EntityFactory)6 EntityFactoryImpl (com.gemserk.commons.artemis.templates.EntityFactoryImpl)6 EntityTemplate (com.gemserk.commons.artemis.templates.EntityTemplate)6 ContainerComponent (com.gemserk.commons.artemis.components.ContainerComponent)3 SpatialComponent (com.gemserk.commons.artemis.components.SpatialComponent)3 ParametersWrapper (com.gemserk.componentsengine.utils.ParametersWrapper)3 ComponentType (com.artemis.ComponentType)2 Spatial (com.gemserk.commons.gdx.games.Spatial)2 Container (com.gemserk.componentsengine.utils.Container)2 ComponentMapper (com.artemis.ComponentMapper)1 EntityProcessingSystem (com.artemis.EntityProcessingSystem)1 WorldConfigurationBuilder (com.artemis.WorldConfigurationBuilder)1 ScriptComponent (com.gemserk.commons.artemis.components.ScriptComponent)1 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)1