import MenuController from "../../Game/MenuController";
import Controller from "../Controller";
import Manager from "./Manager";

export let InitModules=[
    MenuController
]


export default class ModuleMgr extends Manager{
    static get TypeName():string{return "ModuleMgr"}

    private modules:Array<Controller>=null

    public async start(){
        console.log("开始初始化模块")
        this.modules=new Array()
        let modules=InitModules
        let promises=[]
        for(let mod of modules){
            this.modules.push(mod.Inst)
            promises.push(mod.Inst.init())
        }
        await Promise.all(promises)
        console.log("ModuleMgr")
    }

    public release(){
        console.log("ModuleMgr onRelease")
        for(let mod of this.modules.reverse()){
            mod.release()
        }
        this.modules.length=0
    }
}