export class SceneManager {
    constructor() {
        this.scenes = new Map();
    }
    init() {
        if (this.defaultScene) {
            this.switchTo(this.defaultScene);
        }
    }
    addScene(scene) {
        this.scenes.set(scene.id, scene);
    }
    removeScene(scene) {
        if (scene === this.currentScene)
            this.currentScene.onDeactivate();
        this.scenes.delete(scene.id);
    }
    switchTo(scene) {
        if (scene === this.currentScene)
            return;
        let data;
        if (this.currentScene) {
            this.currentScene.onDeactivate();
            data = this.currentScene.data;
        }
        this.currentScene = this.scenes.get(scene.id);
        this.currentScene.onSwitch(data);
        this.currentScene.onActivate(this);
    }
    setDefaultScene(scene) {
        this.defaultScene = scene;
    }
}
