using UnityEngine;

namespace ChillConnect
{
    public enum TimerTimeType
    {
        Null = -1,
        Time = 0,
        UnscaledTime = 1,
        RealtimeSinceStartup = 2,
    }

    public sealed class TimerIManager : BaseUnityManager<TimerIManager>
    {
        private GameObject simpleTimersRoot;
        private GameObject timersRoot;
        private GameObject heavyTimersRoot;

        private void InitTimersRoot()
        {
            simpleTimersRoot = new GameObject("SimpleTimers");
            simpleTimersRoot.SetParent(gameObject);

            timersRoot = new GameObject("Timers");
            timersRoot.SetParent(gameObject);

            heavyTimersRoot = new GameObject("HeavyTimers");
            heavyTimersRoot.SetParent(gameObject);
        }

        public EasyTimer CreateSimpleTimer(string name, TimerTimeType type)
        {
            EasyTimer easyTimer = simpleTimersRoot.AddComponent<EasyTimer>();
            easyTimer.SetTimer(name, type);
            return easyTimer;
        }

        public Timer CreateTimer(string name, TimerTimeType type)
        {
            Timer timer = timersRoot.AddComponent<Timer>();
            timer.SetTimer(name, type);
            return timer;
        }

        #region Mgr

        public override void Init()
        {
            base.Init();
            InitTimersRoot();
        }

        #endregion
    }
}