Search in sources :

Example 11 with RenderableComponent

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

the class RenderableSystem method disabled.

@Override
protected void disabled(Entity e) {
    RenderableComponent renderableComponent = RenderableComponent.get(e);
    Renderable renderable = renderableComponent.renderable;
    // remove the order
    for (int i = 0; i < renderLayers.size(); i++) {
        RenderLayer renderLayer = renderLayers.get(i);
        if (renderLayer.belongs(renderable)) {
            renderLayer.remove(renderable);
            return;
        }
    }
}
Also used : Renderable(com.gemserk.commons.artemis.render.Renderable) RenderableComponent(com.gemserk.commons.artemis.components.RenderableComponent)

Example 12 with RenderableComponent

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

the class OrderedByLayerEntitiesTest method testOrderByInsertionOrder.

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

Example 13 with RenderableComponent

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

the class OrderedByLayerEntitiesTest method shouldReturnSubEntityBeforeAnotherEntityIfParentEntityBeforeThatOne2.

@Test
public void shouldReturnSubEntityBeforeAnotherEntityIfParentEntityBeforeThatOne2() {
    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), e3);
    assertSame(orderedByLayerEntities.get(1), e1);
    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 14 with RenderableComponent

use of com.gemserk.commons.artemis.components.RenderableComponent 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 15 with RenderableComponent

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

RenderableComponent (com.gemserk.commons.artemis.components.RenderableComponent)18 Entity (com.artemis.Entity)16 World (com.artemis.World)15 Test (org.junit.Test)15 OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)13 Renderable (com.gemserk.commons.artemis.render.Renderable)2