use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class EntityHelper method addAfter.
/*
* Featurable
*/
@Override
public void addAfter(Services services, Setup setup) {
final Routines routines = addFeatureAndGet(new Routines(services, setup));
updating = extrp -> {
state.update(extrp);
attacker.update(extrp);
extractor.update(extrp);
producer.update(extrp);
launchable.update(extrp);
launcher.update(extrp);
routines.update(extrp);
body.update(extrp);
pathfindable.update(extrp);
tileCollidable.update(extrp);
state.postUpdate();
mirrorable.update(extrp);
animatable.update(extrp);
rasterable.update(extrp);
};
rendering = g -> {
pathfindable.render(g);
rasterable.render(g);
collidable.render(g);
routines.render(g);
};
updatingCurrent = updating;
renderingCurrent = rendering;
addFeature(new RefreshableModel(extrp -> {
checker.update(extrp);
updatingCurrent.update(extrp);
}));
addFeature(new DisplayableModel(g -> {
renderingCurrent.render(g);
}));
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class TileCollidableModelTest method createObject.
/**
* Create object test.
*
* @param featurable Featurable instance.
* @return The object test.
*/
private Transformable createObject(Featurable featurable) {
final Setup setup = new Setup(config);
CollisionCategoryConfig.exports(setup.getRoot(), categoryY);
CollisionCategoryConfig.exports(setup.getRoot(), categoryX);
final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
transformable.setSize(2, 2);
collidable = featurable.addFeatureAndGet(new TileCollidableModel(services, setup));
collidable.setEnabled(true);
assertArrayEquals(Arrays.asList(categoryY, categoryX).toArray(), collidable.getCategories().toArray());
return transformable;
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class ExtractableModelTest method testConfigWithNode.
/**
* Test the extraction config with node.
*/
@Test
void testConfigWithNode() {
final MapTile map = new MapTileGame();
map.create(16, 16, 4, 4);
services.add(map);
final Featurable featurable = new FeaturableModel(services, setup);
featurable.addFeatureAndGet(new TransformableModel(services, setup)).teleport(16, 32);
final Media media = UtilExtractable.createMedia();
final Extractable extractable = new ExtractableModel(services, new Setup(media));
extractable.prepare(featurable);
assertEquals(10, extractable.getResourceQuantity());
assertEquals("gold", extractable.getResourceType());
assertEquals(1, extractable.getInTileX());
assertEquals(2, extractable.getInTileY());
assertEquals(1, extractable.getInTileWidth());
assertEquals(2, extractable.getInTileHeight());
extractable.getFeature(Identifiable.class).notifyDestroyed();
assertTrue(media.getFile().delete());
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class CollidableModelTest method createFeaturable.
/**
* Create a featurable test.
*
* @param config The configuration reference.
* @param services The services reference.
* @return The featurable test.
*/
public static FeaturableModel createFeaturable(Media config, Services services) {
final Setup setup = new Setup(config);
final FeaturableModel featurable = new FeaturableModel(services, setup);
final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
transformable.setLocation(1.0, 2.0);
transformable.setSize(2, 2);
featurable.addFeature(new CollidableModel(services, setup));
return featurable;
}
use of com.b3dgs.lionengine.game.feature.Setup in project lionengine by b3dgs.
the class CollidableFramedModelTest method createFeaturable.
/**
* Create a featurable test.
*
* @param config The configuration reference.
* @param services The services reference.
* @return The featurable test.
*/
public static FeaturableModel createFeaturable(Media config, Services services) {
final Setup setup = new Setup(config);
final FeaturableModel featurable = new FeaturableModel(services, setup);
final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
transformable.setLocation(1.0, 2.0);
featurable.addFeature(new AnimatableModel(services, setup));
featurable.addFeatureAndGet(new CollidableModel(services, setup));
featurable.addFeature(new CollidableFramedModel(services, setup));
return featurable;
}
Aggregations