using System.Collections.Generic;

namespace BingoBrain.Core
{
    public sealed class Ard : Singleton<Ard>
    {
        private List<InterfaceManager> allManager = new();

        public void Init()
        {
            foreach (var manager in allManager)
            {
                manager.Init();
            }

            foreach (var manager in allManager)
            {
                manager.StartUp();
            }
        }

        public void SetDar(InterfaceManager interfaceManager)
        {
            if (!allManager.Contains(interfaceManager))
            {
                allManager.Add(interfaceManager);
            }
        }

        public void DisposeAllManager()
        {
            foreach (var manager in allManager)
            {
                manager.DisposeBefore();
            }

            foreach (var manager in allManager)
            {
                manager.Dispose();
            }

            Uvsjk.Destroy(OCConst.MonoManagerGo);
            allManager.Clear();
        }

        public override void Dispose()
        {
            base.Dispose();
            allManager.Clear();
            allManager = null;
        }
    }
}