import { _decorator, ccenum, Component, Node } from 'cc';
import { ManagerType, TopLevelManager } from './TopLevelManager';
const { ccclass, property } = _decorator;

@ccclass('MainManager')
export class MainManager extends Component 
{
    @property({type: [TopLevelManager]})
    private managers: TopLevelManager[] = [];
    
    public fn_GetMainManager<T>(managerType: ManagerType) : T // TopLevelManager
    {
        return this.managers.find(manager => manager.managerType == managerType) as T;
    }

    public InitManagers()
    {
        this.managers.forEach(manager => manager.fn_InitMainManager(this));
    }
}

