import { AssetManager } from '../asset-manager';
import { Input } from '../input';
import Resonator from '../resonator';
import { SceneManager } from '../scene/manager';
import { Scheduler } from '../scheduler';
import { TTS } from '../tts';
import { AriaOutput } from '../tts/outputs/aria';
import { HTTPLoader } from '../resonator/loaders/http-loader';
import { EventBus } from '../event-bus';
export class Game extends EventBus {
    constructor() {
        super();
        this.init();
    }
    init() {
        this.assetManager = new AssetManager('game', '');
        this.assetLoader = new HTTPLoader();
        this.resonator = new Resonator(this.assetLoader);
        this.input = new Input(['keyboard'], document.body);
        this.tts = new TTS(new AriaOutput());
        this.sceneManager = new SceneManager();
        this.scheduler = new Scheduler(60);
        this.emit('ready');
    }
    start() {
        this.scheduler.start();
        this.scheduler.subscribe('update.logic', (dt) => {
            this.sceneManager.currentScene.update(dt);
            this.world.update(dt);
        });
        this.scheduler.subscribe('update.draw', (dt) => this.sceneManager.currentScene.updateDraw());
        this.sceneManager.init();
    }
    addScene(scene) {
        this.sceneManager.addScene(scene);
    }
    addDefaultScene(scene) {
        this.sceneManager.addScene(scene);
        this.sceneManager.setDefaultScene(scene);
    }
    setWorld(world) {
        this.world = world;
    }
}
