use of com.gemserk.componentsengine.utils.Container in project commons-gdx by gemserk.
the class EntityTemplateTest method test.
@Test
public void test() {
EntityTemplate customShipTemplate = new ShipEntityTemplate() {
{
parameters.put("x", 100f);
parameters.put("y", 200f);
parameters.put("health", new Container(53f, 250f));
}
};
EntityFactory entityFactory = new EntityFactoryImpl(new World());
Entity entity = entityFactory.instantiate(customShipTemplate);
SpatialComponent spatialComponent = entity.getComponent(SpatialComponent.class);
Spatial spatial = spatialComponent.getSpatial();
assertThat(spatial.getX(), IsEqual.equalTo(100f));
assertThat(spatial.getY(), IsEqual.equalTo(200f));
HealthComponent healthComponent = entity.getComponent(HealthComponent.class);
Container health = healthComponent.getHealth();
assertThat(health.getCurrent(), IsEqual.equalTo(53f));
assertThat(health.getTotal(), IsEqual.equalTo(250f));
}
use of com.gemserk.componentsengine.utils.Container in project commons-gdx by gemserk.
the class EntityTemplateTest method testModifyPositionByHand.
@Test
public void testModifyPositionByHand() {
// default parameters through a custom template, could be created when the level starts with custom level information
EntityTemplate customShipTemplate = new ShipEntityTemplate() {
{
parameters.put("health", new Container(250f, 250f));
}
};
EntityFactory entityFactory = new EntityFactoryImpl(new World());
Entity entity = entityFactory.instantiate(customShipTemplate);
SpatialComponent spatialComponent = entity.getComponent(SpatialComponent.class);
Spatial spatial = spatialComponent.getSpatial();
spatial.setPosition(100f, 100f);
}
Aggregations