Search in sources :

Example 16 with Setup

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);
    }));
}
Also used : Routines(com.b3dgs.lionengine.game.feature.Routines) State(com.b3dgs.lionengine.game.feature.state.State) RefreshableModel(com.b3dgs.lionengine.game.feature.RefreshableModel) Routines(com.b3dgs.lionengine.game.feature.Routines) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) ProducibleModel(com.b3dgs.lionengine.game.feature.producible.ProducibleModel) Setup(com.b3dgs.lionengine.game.feature.Setup) RenderableVoid(com.b3dgs.lionengine.graphic.RenderableVoid) AttackerModel(com.b3dgs.lionengine.game.feature.attackable.AttackerModel) FovableModel(com.b3dgs.lionengine.game.feature.tile.map.transition.fog.FovableModel) SelectableModel(com.b3dgs.lionengine.game.feature.collidable.selector.SelectableModel) Mirrorable(com.b3dgs.lionengine.game.feature.Mirrorable) TileCollidable(com.b3dgs.lionengine.game.feature.tile.map.collision.TileCollidable) PathfindableModel(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.PathfindableModel) LaunchableModel(com.b3dgs.lionengine.game.feature.launchable.LaunchableModel) Attacker(com.b3dgs.lionengine.game.feature.attackable.Attacker) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) Body(com.b3dgs.lionengine.game.feature.body.Body) ActionerModel(com.b3dgs.lionengine.game.feature.ActionerModel) Services(com.b3dgs.lionengine.game.feature.Services) RasterableModel(com.b3dgs.lionengine.game.feature.rasterable.RasterableModel) Extractor(com.b3dgs.lionengine.game.feature.tile.map.extractable.Extractor) UpdatableVoid(com.b3dgs.lionengine.UpdatableVoid) SetupSurfaceRastered(com.b3dgs.lionengine.game.feature.rasterable.SetupSurfaceRastered) Locale(java.util.Locale) ProducerModel(com.b3dgs.lionengine.game.feature.producible.ProducerModel) Animatable(com.b3dgs.lionengine.game.feature.Animatable) Producer(com.b3dgs.lionengine.game.feature.producible.Producer) CollidableFramedModel(com.b3dgs.lionengine.game.feature.collidable.framed.CollidableFramedModel) CollidableModel(com.b3dgs.lionengine.game.feature.collidable.CollidableModel) MirrorableModel(com.b3dgs.lionengine.game.feature.MirrorableModel) Renderable(com.b3dgs.lionengine.graphic.Renderable) Rasterable(com.b3dgs.lionengine.game.feature.rasterable.Rasterable) Collidable(com.b3dgs.lionengine.game.feature.collidable.Collidable) Launchable(com.b3dgs.lionengine.game.feature.launchable.Launchable) ExtractableModel(com.b3dgs.lionengine.game.feature.tile.map.extractable.ExtractableModel) DisplayableModel(com.b3dgs.lionengine.game.feature.DisplayableModel) Updatable(com.b3dgs.lionengine.Updatable) Launcher(com.b3dgs.lionengine.game.feature.launchable.Launcher) LayerableModel(com.b3dgs.lionengine.game.feature.LayerableModel) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Pathfindable(com.b3dgs.lionengine.game.feature.tile.map.pathfinding.Pathfindable) BodyModel(com.b3dgs.lionengine.game.feature.body.BodyModel) LauncherModel(com.b3dgs.lionengine.game.feature.launchable.LauncherModel) TileCollidableModel(com.b3dgs.lionengine.game.feature.tile.map.collision.TileCollidableModel) StateHandler(com.b3dgs.lionengine.game.feature.state.StateHandler) ExtractorModel(com.b3dgs.lionengine.game.feature.tile.map.extractable.ExtractorModel) RefreshableModel(com.b3dgs.lionengine.game.feature.RefreshableModel) DisplayableModel(com.b3dgs.lionengine.game.feature.DisplayableModel)

Example 17 with Setup

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;
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup)

Example 18 with Setup

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());
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) Media(com.b3dgs.lionengine.Media) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) MapTile(com.b3dgs.lionengine.game.feature.tile.map.MapTile) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Identifiable(com.b3dgs.lionengine.game.feature.Identifiable) Test(org.junit.jupiter.api.Test)

Example 19 with Setup

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;
}
Also used : TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup)

Example 20 with Setup

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;
}
Also used : CollidableModel(com.b3dgs.lionengine.game.feature.collidable.CollidableModel) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Setup(com.b3dgs.lionengine.game.feature.Setup) UtilSetup(com.b3dgs.lionengine.game.feature.UtilSetup)

Aggregations

Setup (com.b3dgs.lionengine.game.feature.Setup)42 Test (org.junit.jupiter.api.Test)34 Media (com.b3dgs.lionengine.Media)31 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)20 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)18 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)15 Xml (com.b3dgs.lionengine.Xml)11 Featurable (com.b3dgs.lionengine.game.feature.Featurable)11 Transformable (com.b3dgs.lionengine.game.feature.Transformable)11 Services (com.b3dgs.lionengine.game.feature.Services)10 Medias (com.b3dgs.lionengine.Medias)6 UtilAssert.assertEquals (com.b3dgs.lionengine.UtilAssert.assertEquals)6 UtilAssert.assertTrue (com.b3dgs.lionengine.UtilAssert.assertTrue)6 Identifiable (com.b3dgs.lionengine.game.feature.Identifiable)6 Handler (com.b3dgs.lionengine.game.feature.Handler)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5 AfterAll (org.junit.jupiter.api.AfterAll)5 BeforeAll (org.junit.jupiter.api.BeforeAll)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 UtilAssert.assertFalse (com.b3dgs.lionengine.UtilAssert.assertFalse)4