using System; using System.Collections.Generic; using UnityEngine; namespace Chronos { /// /// A Clock that affects all Timeline and other global clocks configured as its children. /// [AddComponentMenu("Time/Global Clock")] [HelpURL("http://ludiq.io/chronos/documentation#GlobalClock")] public class GlobalClock : Clock { public GlobalClock() { clocks = new HashSet(); timelines = new HashSet(); } #region Fields protected HashSet clocks; protected HashSet timelines; #endregion #region Properties [SerializeField] private string _key; /// /// The unique key of the global clock. /// public string key { get { return _key; } internal set { _key = value; } } #endregion internal virtual void Register(Timeline timeline) { if (timeline == null) throw new ArgumentNullException("timeline"); timelines.Add(timeline); } internal virtual void Unregister(Timeline timeline) { if (timeline == null) throw new ArgumentNullException("timeline"); timelines.Remove(timeline); } internal virtual void Register(Clock clock) { if (clock == null) throw new ArgumentNullException("clock"); clocks.Add(clock); } internal virtual void Unregister(Clock clock) { if (clock == null) throw new ArgumentNullException("clock"); clocks.Remove(clock); } } }