use of com.artemis.Entity 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);
}
use of com.artemis.Entity 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);
}
use of com.artemis.Entity 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);
}
use of com.artemis.Entity 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);
}
use of com.artemis.Entity in project commons-gdx by gemserk.
the class EntityTemplateTest method shouldUseDefaultParametersIfParameterMissingFromCustomParameters.
@Test
public void shouldUseDefaultParametersIfParameterMissingFromCustomParameters() {
ParametersWrapper weaponBulletParameters = new ParametersWrapper();
// damage and position parameters are missing, but they are on default parameters
EntityTemplate bulletTemplate = new BulletEntityTemplate();
EntityFactory entityFactory = new EntityFactoryImpl(new World());
Entity bullet = entityFactory.instantiate(bulletTemplate, weaponBulletParameters);
DamageComponent damageComponent = bullet.getComponent(DamageComponent.class);
assertThat(damageComponent.getDamage(), IsEqual.equalTo(5f));
}
Aggregations