use of com.artemis.World in project commons-gdx by gemserk.
the class ArtemisOutOfBoundsTest method shouldNotFailWhenAskingForComponentOutsideBounds.
@Test
public void shouldNotFailWhenAskingForComponentOutsideBounds() {
World world = new World();
Entity e = world.createEntity();
e.addComponent(new Component1());
e.addComponent(new Component2());
e.addComponent(new Component3());
e.addComponent(new Component4());
e.addComponent(new Component5());
e.addComponent(new Component6());
// e.addComponent(new Component7());
e.addComponent(new Component8());
e.addComponent(new Component9());
e.addComponent(new Component10());
e.addComponent(new Component11());
e.addComponent(new Component12());
e.addComponent(new Component13());
e.addComponent(new Component14());
e.addComponent(new Component15());
e.addComponent(new Component16());
e.addComponent(new ComponentOutOfBounds());
e.refresh();
e.getComponent(Component1.class);
e.getComponent(Component2.class);
e.getComponent(Component3.class);
e.getComponent(Component4.class);
e.getComponent(Component5.class);
e.getComponent(Component6.class);
e.getComponent(Component7.class);
e.getComponent(Component8.class);
e.getComponent(Component9.class);
e.getComponent(Component10.class);
e.getComponent(Component11.class);
e.getComponent(Component12.class);
e.getComponent(Component13.class);
e.getComponent(Component14.class);
e.getComponent(Component15.class);
e.getComponent(Component16.class);
// e.getComponent(ComponentOutOfBounds.class);
ComponentOutOfBounds component = e.getComponent(ComponentOutOfBounds.class);
assertThat(component, IsNull.notNullValue());
Component7 component7 = e.getComponent(Component7.class);
assertThat(component7, IsNull.nullValue());
}
use of com.artemis.World in project commons-gdx by gemserk.
the class ArtemisOutOfBoundsTest method shouldGetComponent.
@Test
public void shouldGetComponent() {
World world = new World();
Entity e = world.createEntity();
e.addComponent(new Component1());
e.refresh();
Component1 component = e.getComponent(Component1.class);
assertThat(component, IsNull.notNullValue());
}
use of com.artemis.World 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());
}
use of com.artemis.World 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.artemis.World in project commons-gdx by gemserk.
the class EntityTemplateTest method weaponInstantiateBullet.
@Deprecated
public void weaponInstantiateBullet() {
EntityTemplate bulletTemplate = new BulletEntityTemplate();
// modifies the template forever, if we are using the same template in different weapons or something similar, then they will be modified as well.
// bulletTemplate.getDefaultParameters().put("damage", new Float(200f));
EntityFactory entityFactory = new EntityFactoryImpl(new World());
Entity bullet = entityFactory.instantiate(bulletTemplate);
DamageComponent damageComponent = bullet.getComponent(DamageComponent.class);
assertThat(damageComponent.getDamage(), IsEqual.equalTo(200f));
}
Aggregations