using System; using System.Collections.Generic; using UnityEngine; using Utility; namespace Mono.UI.Core { public class TimeComponent : Singleton { public Queue TimerPool = new Queue(); public List CustomTimers = new List(); public void Init() { } public void AddTimer(float time, Action action) { CustomTimer customTimer; if (TimerPool.Count > 0) { customTimer = TimerPool.Dequeue(); } else { customTimer = new CustomTimer(); } customTimer.CustomInit(time, action); CustomTimers.Add(customTimer); } public void Update() { for (var i = 0; i < CustomTimers.Count; i++) { CustomTimers[i].Update(Time.deltaTime); } } public void Rec(CustomTimer customTimer) { if (CustomTimers.Contains(customTimer)) { CustomTimers.Remove(customTimer); TimerPool.Enqueue(customTimer); } } } }