Search in sources :

Example 6 with WorldWrapper

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

the class MultipleImplementationsSameComponentTest method shouldNotHandleSpecificComponentImplementation.

@Test
public void shouldNotHandleSpecificComponentImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new SecondImplementationSystem());
    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 7 with WorldWrapper

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

the class MultipleImplementationsSameComponentTest method shouldHandleParentComponentWithoutKnowingTheImplementation.

@Test
public void shouldHandleParentComponentWithoutKnowingTheImplementation() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new ParentSpatialSystem());
    worldWrapper.addUpdateSystem(new FirstImplementationSystem());
    worldWrapper.addUpdateSystem(new SecondImplementationSystem());
    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 8 with WorldWrapper

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

the class ContainerSystemTest method shouldNotProcessDisabledChildrenEntity.

@SuppressWarnings("unchecked")
@Test
public void shouldNotProcessDisabledChildrenEntity() {
    World world = new World();
    WorldWrapper worldWrapper = new WorldWrapper(world);
    worldWrapper.addUpdateSystem(new ContainerSystem());
    worldWrapper.addUpdateSystem(new OwnerSystem());
    shouldBeDisabled = false;
    worldWrapper.addUpdateSystem(new EntityProcessingSystem(StoreComponent.class) {

        @Override
        protected void process(Entity e) {
            if (shouldBeDisabled)
                fail("should not process children");
            System.out.println("processing children");
            shouldBeDisabled = true;
        }
    });
    worldWrapper.init();
    Entity e1 = world.createEntity();
    e1.addComponent(new ContainerComponent());
    Entity e2 = world.createEntity();
    e2.addComponent(new OwnerComponent(e1));
    e2.addComponent(new StoreComponent(new EntityStore(null) {
    }));
    worldWrapper.update(1);
    assertTrue(e1.isEnabled());
    assertTrue(e2.isEnabled());
    e1.delete();
    worldWrapper.update(1);
    assertFalse(e1.isEnabled());
    assertFalse(e2.isEnabled());
    worldWrapper.update(1);
}
Also used : Entity(com.artemis.Entity) WorldWrapper(com.gemserk.commons.artemis.WorldWrapper) EntityProcessingSystem(com.artemis.EntityProcessingSystem) OwnerComponent(com.gemserk.commons.artemis.components.OwnerComponent) ContainerComponent(com.gemserk.commons.artemis.components.ContainerComponent) EntityStore(com.gemserk.commons.artemis.utils.EntityStore) World(com.artemis.World) StoreComponent(com.gemserk.commons.artemis.components.StoreComponent) 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