Search in sources :

Example 1 with RefreshableModel

use of com.b3dgs.lionengine.game.feature.RefreshableModel 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 2 with RefreshableModel

use of com.b3dgs.lionengine.game.feature.RefreshableModel 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)

Aggregations

AnimatableModel (com.b3dgs.lionengine.game.feature.AnimatableModel)2 DisplayableModel (com.b3dgs.lionengine.game.feature.DisplayableModel)2 FeaturableModel (com.b3dgs.lionengine.game.feature.FeaturableModel)2 MirrorableModel (com.b3dgs.lionengine.game.feature.MirrorableModel)2 RefreshableModel (com.b3dgs.lionengine.game.feature.RefreshableModel)2 Services (com.b3dgs.lionengine.game.feature.Services)2 TransformableModel (com.b3dgs.lionengine.game.feature.TransformableModel)2 Rasterable (com.b3dgs.lionengine.game.feature.rasterable.Rasterable)2 RasterableModel (com.b3dgs.lionengine.game.feature.rasterable.RasterableModel)2 SetupSurfaceRastered (com.b3dgs.lionengine.game.feature.rasterable.SetupSurfaceRastered)2 Context (com.b3dgs.lionengine.Context)1 Engine (com.b3dgs.lionengine.Engine)1 Medias (com.b3dgs.lionengine.Medias)1 Origin (com.b3dgs.lionengine.Origin)1 Resolution (com.b3dgs.lionengine.Resolution)1 Tick (com.b3dgs.lionengine.Tick)1 Updatable (com.b3dgs.lionengine.Updatable)1 UpdatableVoid (com.b3dgs.lionengine.UpdatableVoid)1 UtilMath (com.b3dgs.lionengine.UtilMath)1 ActionerModel (com.b3dgs.lionengine.game.feature.ActionerModel)1