using System.Collections.Generic;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;

namespace Utility.CustomizeTimeLogic.FxLogic.TimeLineEvent
{
    public class TimeLineSingletonEventManager : Singleton<TimeLineSingletonEventManager>
    {
        private List<ITimeLineEventBasic> singTimeLineEvent = new List<ITimeLineEventBasic>();

        public void AddTimeLineBasic(ITimeLineEventBasic timeLineEventBasic)
        {
            singTimeLineEvent.Add(timeLineEventBasic);
        }

        public void RemoveTimeLineBasic(ITimeLineEventBasic timeLineEventBasic)
        {
            singTimeLineEvent.Remove(timeLineEventBasic);
        }

        public T GetTimeLine<T>() where T : ITimeLineEventBasic
        {
            for (int i = 0; i < singTimeLineEvent.Count; i++)
            {
                if (singTimeLineEvent[i] is T)
                {
                    return (T)singTimeLineEvent[i];
                }
            }

            return default;
        }
    }
}