Search in sources :

Example 46 with Entity

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

the class EntityStore method refreshPool.

public int refreshPool() {
    int size = freedThisFrame.size;
    if (size <= 0)
        return 0;
    Entity[] entities = freedThisFrame.items;
    for (int i = 0; i < size; i++) {
        Entity entity = entities[i];
        super.free(entity);
    }
    freedThisFrame.clear();
    return size;
}
Also used : Entity(com.artemis.Entity)

Example 47 with Entity

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

the class GetComponentPerformanceTest method testTimeWithGetComponentFromClass.

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

Example 48 with Entity

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

the class GetComponentPerformanceTest method testTimeWithGetComponentFromMapper.

public long testTimeWithGetComponentFromMapper(int iterations) {
    World world = new World();
    Entity e = world.createEntity();
    e.addComponent(new MyTestComponent());
    e.refresh();
    ComponentMapper<MyTestComponent> myTestComponentMapper = new ComponentMapper<MyTestComponent>(MyTestComponent.class, world.getEntityManager());
    long startNanoTime = System.nanoTime();
    for (int i = 0; i < iterations; i++) {
        myTestComponentMapper.get(e);
    // MyTestComponent myTestComponent = myTestComponentMapper.get(e);
    }
    return System.nanoTime() - startNanoTime;
}
Also used : Entity(com.artemis.Entity) ComponentMapper(com.artemis.ComponentMapper) World(com.artemis.World)

Example 49 with Entity

use of com.artemis.Entity 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 50 with Entity

use of com.artemis.Entity 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)

Aggregations

Entity (com.artemis.Entity)59 World (com.artemis.World)38 Test (org.junit.Test)31 RenderableComponent (com.gemserk.commons.artemis.components.RenderableComponent)16 OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)15 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 Spatial (com.gemserk.commons.gdx.games.Spatial)6 SpatialComponent (com.gemserk.commons.artemis.components.SpatialComponent)5 Body (com.badlogic.gdx.physics.box2d.Body)4 ContainerComponent (com.gemserk.commons.artemis.components.ContainerComponent)4 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)4 ParametersWrapper (com.gemserk.componentsengine.utils.ParametersWrapper)3 ComponentType (com.artemis.ComponentType)2 PreviousStateSpatialComponent (com.gemserk.commons.artemis.components.PreviousStateSpatialComponent)2 SpriteComponent (com.gemserk.commons.artemis.components.SpriteComponent)2 Script (com.gemserk.commons.artemis.scripts.Script)2 Container (com.gemserk.componentsengine.utils.Container)2