Search in sources :

Example 1 with AssetConsumer

use of com.bladecoder.engine.assets.AssetConsumer in project bladecoder-adventure-engine by bladecoder.

the class MoveToSceneAction method run.

@Override
public boolean run(VerbRunner cb) {
    final Scene s = actor.getScene();
    final String actorId = actor.getActorId();
    final World w = World.getInstance();
    if (actorId == null) {
        // if called in a scene verb and no actor is specified, we do nothing
        EngineLogger.error(getClass() + ": No actor specified");
        return false;
    }
    InteractiveActor a = (InteractiveActor) s.getActor(actorId, false);
    s.removeActor(a);
    if (s == w.getCurrentScene() && a instanceof Disposable)
        ((Disposable) a).dispose();
    Scene ts = null;
    if (scene == null)
        ts = w.getCurrentScene();
    else
        ts = w.getScene(scene);
    // the scene is cached.
    if ((ts == w.getCurrentScene() || w.getCachedScene(ts.getId()) != null) && a instanceof AssetConsumer) {
        ((AssetConsumer) a).loadAssets();
        EngineAssetManager.getInstance().finishLoading();
        ((AssetConsumer) a).retrieveAssets();
    }
    ts.addActor(a);
    return false;
}
Also used : Disposable(com.badlogic.gdx.utils.Disposable) InteractiveActor(com.bladecoder.engine.model.InteractiveActor) AssetConsumer(com.bladecoder.engine.assets.AssetConsumer) Scene(com.bladecoder.engine.model.Scene) World(com.bladecoder.engine.model.World)

Aggregations

Disposable (com.badlogic.gdx.utils.Disposable)1 AssetConsumer (com.bladecoder.engine.assets.AssetConsumer)1 InteractiveActor (com.bladecoder.engine.model.InteractiveActor)1 Scene (com.bladecoder.engine.model.Scene)1 World (com.bladecoder.engine.model.World)1