using System.Collections; using System.Collections.Generic; using UnityEngine; namespace YKMoon { /// /// Updatable for NormalUpdater. /// public interface IUpdatable { void Update(float deltaTime, float unscaledDeltaTime); } public class NormalUpdater : IUpdater { private event System.Action updateEvent; /// /// Register update event to this updater. /// /// (float deltaTime, float unscaledDeltaTime) public void Reg(System.Action updateEvent) { this.updateEvent += updateEvent; } /// /// Unregister update event to this updater. /// /// (float deltaTime, float unscaledDeltaTime) public void UnReg(System.Action updateEvent) { this.updateEvent -= updateEvent; } /// /// Register IUpdatable to this updater. /// public void Reg(IUpdatable updatable) { this.updateEvent += updatable.Update; } /// /// Unregister IUpdatable to this updater. /// public void UnReg(IUpdatable updatable) { this.updateEvent -= updatable.Update; } public void Update(float deltaTime, float unscaledDeltaTime) { updateEvent?.Invoke(deltaTime, unscaledDeltaTime); } public void Clear() { updateEvent = null; } } }