Search in sources :

Example 1 with Featurable

use of com.b3dgs.lionengine.game.feature.Featurable in project lionengine by b3dgs.

the class UtilAssignable method createAssignable.

/**
 * Create the assignable.
 *
 * @param services The services.
 * @return The prepared assignable.
 */
public static AssignableModel createAssignable(Services services) {
    final Featurable featurable = new FeaturableModel();
    featurable.addFeature(new IdentifiableModel());
    final AssignableModel assignable = new AssignableModel(services);
    assignable.prepare(featurable);
    return assignable;
}
Also used : FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) IdentifiableModel(com.b3dgs.lionengine.game.feature.IdentifiableModel) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 2 with Featurable

use of com.b3dgs.lionengine.game.feature.Featurable in project lionengine by b3dgs.

the class UtilExtractable method createExtractable.

/**
 * Create extractable.
 *
 * @return The extractable.
 */
public static Extractable createExtractable() {
    final Services services = new Services();
    services.add(new MapTileGame());
    final Featurable featurable = new FeaturableModel();
    featurable.addFeature(new IdentifiableModel());
    featurable.addFeature(new TransformableModel());
    final Extractable extractable = new ExtractableModel(services);
    extractable.setResourcesQuantity(10);
    extractable.setResourcesType(ResourceType.WOOD);
    extractable.prepare(featurable);
    return extractable;
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) IdentifiableModel(com.b3dgs.lionengine.game.feature.IdentifiableModel) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 3 with Featurable

use of com.b3dgs.lionengine.game.feature.Featurable in project lionengine by b3dgs.

the class SceneRasterable method add.

private void add(SetupSurfaceRastered setup, int offsetX) {
    final SpriteAnimated surface = Drawable.loadSpriteAnimated(setup.getSurface(), 4, 4);
    final Featurable featurable = new FeaturableModel(services, setup);
    featurable.addFeature(new MirrorableModel(services, setup));
    featurable.addFeature(new AnimatableModel(services, setup, surface));
    final Transformable transformable = featurable.addFeatureAndGet(new TransformableModel(services, setup));
    final Rasterable rasterable = new RasterableModel(services, setup);
    rasterable.setOrigin(Origin.MIDDLE);
    rasterable.setFrameOffsets(1, 2);
    featurable.addFeature(rasterable);
    featurable.addFeature(new RefreshableModel(extrp -> {
        transformable.setLocationY(UtilMath.sin(count) * 240);
        surface.setLocation(camera, transformable);
        rasterable.update(extrp);
        surface.update(extrp);
    }));
    featurable.addFeature(new DisplayableModel(g -> rasterable.render(g)));
    transformable.setLocationX(120 + offsetX);
    handler.add(featurable);
}
Also used : Medias(com.b3dgs.lionengine.Medias) ComponentRefreshable(com.b3dgs.lionengine.game.feature.ComponentRefreshable) RefreshableModel(com.b3dgs.lionengine.game.feature.RefreshableModel) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) ComponentDisplayable(com.b3dgs.lionengine.game.feature.ComponentDisplayable) Drawable(com.b3dgs.lionengine.graphic.drawable.Drawable) Resolution(com.b3dgs.lionengine.Resolution) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) Services(com.b3dgs.lionengine.game.feature.Services) RasterableModel(com.b3dgs.lionengine.game.feature.rasterable.RasterableModel) SetupSurfaceRastered(com.b3dgs.lionengine.game.feature.rasterable.SetupSurfaceRastered) Handler(com.b3dgs.lionengine.game.feature.Handler) UtilMath(com.b3dgs.lionengine.UtilMath) MirrorableModel(com.b3dgs.lionengine.game.feature.MirrorableModel) Rasterable(com.b3dgs.lionengine.game.feature.rasterable.Rasterable) Graphic(com.b3dgs.lionengine.graphic.Graphic) Sequence(com.b3dgs.lionengine.graphic.engine.Sequence) DisplayableModel(com.b3dgs.lionengine.game.feature.DisplayableModel) Transformable(com.b3dgs.lionengine.game.feature.Transformable) Engine(com.b3dgs.lionengine.Engine) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) Context(com.b3dgs.lionengine.Context) Tick(com.b3dgs.lionengine.Tick) Origin(com.b3dgs.lionengine.Origin) Featurable(com.b3dgs.lionengine.game.feature.Featurable) Camera(com.b3dgs.lionengine.game.feature.Camera) SpriteAnimated(com.b3dgs.lionengine.graphic.drawable.SpriteAnimated) RefreshableModel(com.b3dgs.lionengine.game.feature.RefreshableModel) DisplayableModel(com.b3dgs.lionengine.game.feature.DisplayableModel) AnimatableModel(com.b3dgs.lionengine.game.feature.AnimatableModel) MirrorableModel(com.b3dgs.lionengine.game.feature.MirrorableModel) TransformableModel(com.b3dgs.lionengine.game.feature.TransformableModel) RasterableModel(com.b3dgs.lionengine.game.feature.rasterable.RasterableModel) SpriteAnimated(com.b3dgs.lionengine.graphic.drawable.SpriteAnimated) Transformable(com.b3dgs.lionengine.game.feature.Transformable) FeaturableModel(com.b3dgs.lionengine.game.feature.FeaturableModel) Rasterable(com.b3dgs.lionengine.game.feature.rasterable.Rasterable) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 4 with Featurable

use of com.b3dgs.lionengine.game.feature.Featurable in project lionengine by b3dgs.

the class LauncherModel method fired.

/**
 * Called when fire is performed.
 *
 * @param initial The fire launch initial speed for force transfer.
 * @throws LionEngineException If the fired object is not a {@link Launchable}.
 */
private void fired(Direction initial) {
    for (int i = 0; i < listenable.size(); i++) {
        listenable.get(i).notifyFired();
    }
    for (final LaunchableConfig launchableConfig : launchables) {
        final Media media = Medias.create(launchableConfig.getMedia());
        final Featurable featurable = factory.create(media);
        try {
            final Launchable launchable = featurable.getFeature(Launchable.class);
            if (launchableConfig.getDelay() > 0) {
                delayed.add(new DelayedLaunch(source, launchableConfig, initial, featurable, launchable));
            } else {
                launch(launchableConfig, initial, featurable, launchable);
            }
        } catch (final LionEngineException exception) {
            featurable.getFeature(Identifiable.class).destroy();
            throw exception;
        }
    }
}
Also used : LionEngineException(com.b3dgs.lionengine.LionEngineException) Media(com.b3dgs.lionengine.Media) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Example 5 with Featurable

use of com.b3dgs.lionengine.game.feature.Featurable in project lionengine by b3dgs.

the class Hud method createMenu.

/**
 * Create menu from action and add to active menus.
 *
 * @param action The action used.
 * @return The created menu.
 */
private Actionable createMenu(ActionRef action) {
    Actionable menu = menus.get(action);
    if (menu == null) {
        final Featurable featurable = factory.create(Medias.create(PATH.split(action.getPath())));
        handler.add(featurable);
        menu = featurable.getFeature(Actionable.class);
        menus.put(action, menu);
    }
    menu.setEnabled(true);
    active.add(menu);
    return menu;
}
Also used : Actionable(com.b3dgs.lionengine.game.feature.Actionable) Featurable(com.b3dgs.lionengine.game.feature.Featurable)

Aggregations

Featurable (com.b3dgs.lionengine.game.feature.Featurable)35 Test (org.junit.jupiter.api.Test)19 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)18 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)10 AtomicReference (java.util.concurrent.atomic.AtomicReference)9 Setup (com.b3dgs.lionengine.game.feature.Setup)8 Media (com.b3dgs.lionengine.Media)7 Identifiable (com.b3dgs.lionengine.game.feature.Identifiable)6 Transformable (com.b3dgs.lionengine.game.feature.Transformable)5 Services (com.b3dgs.lionengine.game.feature.Services)4 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)4 Animation (com.b3dgs.lionengine.Animation)3 Medias (com.b3dgs.lionengine.Medias)2 ViewerMock (com.b3dgs.lionengine.ViewerMock)2 AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)2 Camera (com.b3dgs.lionengine.game.feature.Camera)2 IdentifiableModel (com.b3dgs.lionengine.game.feature.IdentifiableModel)2 LayerableModel (com.b3dgs.lionengine.game.feature.LayerableModel)2 MirrorableModel (com.b3dgs.lionengine.game.feature.MirrorableModel)2 UtilSetup (com.b3dgs.lionengine.game.feature.UtilSetup)2