use of com.gemserk.commons.artemis.components.OwnerComponent in project commons-gdx by gemserk.
the class ContainerSystemTest method shouldBeAddedToParentContainer.
@Test
public void shouldBeAddedToParentContainer() {
World world = new World();
WorldWrapper worldWrapper = new WorldWrapper(world);
worldWrapper.addUpdateSystem(new ContainerSystem());
worldWrapper.addUpdateSystem(new OwnerSystem());
worldWrapper.init();
Entity e1 = world.createEntity();
e1.addComponent(new ContainerComponent());
e1.refresh();
Entity e2 = world.createEntity();
e2.addComponent(new OwnerComponent(e1));
e2.refresh();
worldWrapper.update(10);
ContainerComponent containerComponent = e1.getComponent(ContainerComponent.class);
assertThat(containerComponent.getChildren().contains(e2), IsEqual.equalTo(true));
}
use of com.gemserk.commons.artemis.components.OwnerComponent in project commons-gdx by gemserk.
the class OrderedByLayerEntitiesTest method shouldReturnSubEntityBeforeParentEntityIfLesserSubLayer.
@Test
public void shouldReturnSubEntityBeforeParentEntityIfLesserSubLayer() {
World world = new World();
Entity e1 = world.createEntity();
Entity e3 = world.createEntity();
e1.addComponent(new RenderableComponent(5, 0));
e3.addComponent(new RenderableComponent(5, -1, true));
e3.addComponent(new OwnerComponent(e1));
orderedByLayerEntities.add(e1);
orderedByLayerEntities.add(e3);
assertSame(orderedByLayerEntities.get(0), e3);
assertSame(orderedByLayerEntities.get(1), e1);
}
use of com.gemserk.commons.artemis.components.OwnerComponent in project commons-gdx by gemserk.
the class OrderedByLayerEntitiesTest method testSubEntitiesAfterAnotherEntityIfParentIsAfter2.
@Test
public void testSubEntitiesAfterAnotherEntityIfParentIsAfter2() {
World world = new World();
Entity e1 = world.createEntity();
Entity e2 = world.createEntity();
Entity e3 = world.createEntity();
e1.addComponent(new RenderableComponent(5));
e2.addComponent(new RenderableComponent(5));
e3.addComponent(new RenderableComponent(5, 2, true));
e3.addComponent(new OwnerComponent(e1));
orderedByLayerEntities.add(e2);
orderedByLayerEntities.add(e1);
orderedByLayerEntities.add(e3);
assertSame(orderedByLayerEntities.get(0), e1);
assertSame(orderedByLayerEntities.get(1), e3);
assertSame(orderedByLayerEntities.get(2), e2);
}
use of com.gemserk.commons.artemis.components.OwnerComponent in project commons-gdx by gemserk.
the class OrderedByLayerEntitiesTest method testTwoSubEntities2.
@Test
public void testTwoSubEntities2() {
World world = new World();
Entity e1 = world.createEntity();
Entity e3 = world.createEntity();
Entity e4 = world.createEntity();
e1.addComponent(new RenderableComponent(5, 0));
e3.addComponent(new RenderableComponent(5, 6, true));
e4.addComponent(new RenderableComponent(5, 8, true));
e3.addComponent(new OwnerComponent(e1));
e4.addComponent(new OwnerComponent(e1));
orderedByLayerEntities.add(e1);
orderedByLayerEntities.add(e3);
orderedByLayerEntities.add(e4);
assertSame(orderedByLayerEntities.get(0), e1);
assertSame(orderedByLayerEntities.get(1), e3);
assertSame(orderedByLayerEntities.get(2), e4);
}
use of com.gemserk.commons.artemis.components.OwnerComponent in project commons-gdx by gemserk.
the class OrderedByLayerEntitiesTest method bugEntityWithNullOwner2.
@Test
public void bugEntityWithNullOwner2() {
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(e2);
orderedByLayerEntities.add(e1);
assertSame(orderedByLayerEntities.get(0), e1);
assertSame(orderedByLayerEntities.get(1), e2);
}
Aggregations