Search in sources :

Example 1 with WorldWrapper

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

the class ContainerSystemTest method shouldRemoveChildrenIfParentRemoved.

@Test
public void shouldRemoveChildrenIfParentRemoved() {
    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);
    world.deleteEntity(e1);
    worldWrapper.update(1);
    worldWrapper.update(1);
    Entity e3 = world.getEntity(e2.getId());
    assertThat(e3, IsNull.nullValue());
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) ContainerComponent(com.gemserk.commons.artemis.components.ContainerComponent) World(com.artemis.World) Test(org.junit.Test)

Example 2 with WorldWrapper

use of com.gemserk.commons.artemis.WorldWrapper 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));
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) ContainerComponent(com.gemserk.commons.artemis.components.ContainerComponent) World(com.artemis.World) Test(org.junit.Test)

Example 3 with WorldWrapper

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

the class MultipleImplementationsSameComponentTest method shouldHandleSpecificComponentImplementation.

@Test
public void shouldHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new FirstImplementationSystem());
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new FirstImplementationComponent());
    e1.refresh();
    worldWrapper.update(100);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) World(com.artemis.World) Test(org.junit.Test)

Example 4 with WorldWrapper

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

the class MultipleImplementationsSameComponentWorkaroundTest method shouldHandleSpecificComponentImplementation.

@Test
public void shouldHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new SpatialSystem());
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new SpatialComponent(new SpatialFirstImpl()));
    e1.refresh();
    worldWrapper.update(100);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) World(com.artemis.World) Test(org.junit.Test)

Example 5 with WorldWrapper

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

the class MultipleImplementationsSameComponentWorkaroundTest method shouldNotHandleSpecificComponentImplementation.

@Test
public void shouldNotHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new SpatialSystem());
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new SpatialComponent(new SpatialSecondImpl()));
    e1.refresh();
    worldWrapper.update(100);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) World(com.artemis.World) Test(org.junit.Test)

Aggregations

Entity (com.artemis.Entity)8 World (com.artemis.World)8 WorldWrapper (com.gemserk.commons.artemis.WorldWrapper)8 Test (org.junit.Test)8 ContainerComponent (com.gemserk.commons.artemis.components.ContainerComponent)3 OwnerComponent (com.gemserk.commons.artemis.components.OwnerComponent)3 EntityProcessingSystem (com.artemis.EntityProcessingSystem)1 StoreComponent (com.gemserk.commons.artemis.components.StoreComponent)1 EntityStore (com.gemserk.commons.artemis.utils.EntityStore)1