Search in sources :

Example 16 with OwnerComponent

use of com.gemserk.commons.artemis.components.OwnerComponent 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)

Example 17 with OwnerComponent

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

the class OrderedByLayerEntitiesTest method testSubEntitiesAfterAnotherEntityIfParentIsAfter.

@Test
public void testSubEntitiesAfterAnotherEntityIfParentIsAfter() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    Entity e3 = world.createEntity();
    e1.addComponent(new RenderableComponent(6, 0));
    e2.addComponent(new RenderableComponent(5));
    e3.addComponent(new RenderableComponent(6, 1, true));
    e3.addComponent(new OwnerComponent(e1));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    orderedByLayerEntities.add(e3);
    assertSame(orderedByLayerEntities.get(0), e2);
    assertSame(orderedByLayerEntities.get(1), e1);
    assertSame(orderedByLayerEntities.get(2), e3);
}
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 18 with OwnerComponent

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

the class OrderedByLayerEntitiesTest method testTwoSubEntitiesOrder.

@Test
public void testTwoSubEntitiesOrder() {
    World world = new World();
    Entity e1 = world.createEntity();
    Entity e2 = world.createEntity();
    Entity e3 = world.createEntity();
    Entity e4 = world.createEntity();
    e1.addComponent(new RenderableComponent(5));
    e2.addComponent(new RenderableComponent(6));
    e3.addComponent(new RenderableComponent(5, -1, true));
    e4.addComponent(new RenderableComponent(5, -1, true));
    e3.addComponent(new OwnerComponent(e1));
    e4.addComponent(new OwnerComponent(e2));
    orderedByLayerEntities.add(e1);
    orderedByLayerEntities.add(e2);
    orderedByLayerEntities.add(e3);
    orderedByLayerEntities.add(e4);
    assertSame(orderedByLayerEntities.get(0), e3);
    assertSame(orderedByLayerEntities.get(1), e1);
    assertSame(orderedByLayerEntities.get(2), e4);
    assertSame(orderedByLayerEntities.get(3), 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

OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)18 Entity (com.artemis.Entity)15 World (com.artemis.World)14 Test (org.junit.Test)14 RenderableComponent (com.gemserk.commons.artemis.components.RenderableComponent)13 ContainerComponent (com.gemserk.commons.artemis.components.ContainerComponent)5 WorldWrapper (com.gemserk.commons.artemis.WorldWrapper)3 EntityProcessingSystem (com.artemis.EntityProcessingSystem)1 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)1 Renderable (com.gemserk.commons.artemis.render.Renderable)1 EntityStore (com.gemserk.commons.artemis.utils.EntityStore)1