private void _Publish(ManagerEvents managerEvent, object[] arguments) { if (_highSubscriptionsCache.ContainsKey(managerEvent)) { Subscription <TManager>[] array = _highSubscriptionsCache[managerEvent]; foreach (Subscription <TManager> subscription in array) { subscription(arguments); } } if (_mediumSubscriptionsCache.ContainsKey(managerEvent)) { Subscription <TManager>[] array2 = _mediumSubscriptionsCache[managerEvent]; foreach (Subscription <TManager> subscription2 in array2) { subscription2(arguments); } } if (_lowSubscriptionsCache.ContainsKey(managerEvent)) { Subscription <TManager>[] array3 = _lowSubscriptionsCache[managerEvent]; foreach (Subscription <TManager> subscription3 in array3) { subscription3(arguments); } } CoreManager.Log(LogLevel.Info, $"Published! ManagerEvent: \"{managerEvent}\"", arguments); }
internal void _Destroy() { Listen(false); CoreManager.Log(LogLevel.Info, "Listen status: False"); Object.Destroy(this); }
public void Unsubscribe(ManagerEvents managerEvent, Subscription <TManager> subscription, Priority priority = Priority.Medium) { switch (priority) { default: if (_mediumSubscriptions.ContainsKey(managerEvent)) { _mediumSubscriptions[managerEvent].Remove(subscription); _mediumSubscriptionsCache[managerEvent] = _mediumSubscriptions[managerEvent].ToArray(); } break; case Priority.Low: if (_lowSubscriptions.ContainsKey(managerEvent)) { _lowSubscriptions[managerEvent].Remove(subscription); _lowSubscriptionsCache[managerEvent] = _lowSubscriptions[managerEvent].ToArray(); } break; case Priority.High: if (_highSubscriptions.ContainsKey(managerEvent)) { _highSubscriptions[managerEvent].Remove(subscription); _highSubscriptionsCache[managerEvent] = _highSubscriptions[managerEvent].ToArray(); } break; } CoreManager.Log(LogLevel.Info, $"{subscription.Target} Unsubscribed! ManagerEvent: \"{ managerEvent}\" Priority: {priority.ToString()}"); }
protected bool Push(ManagerEvents managerEvent, params object[] arguments) { TManager manager = Manager; bool published = manager._OnPull(this, managerEvent, arguments); CoreManager.Log(LogLevel.Info, $"Push status: {published} , ManagerEvent: \"{managerEvent}\"", arguments); return(published); }
private void ChangedActiveScene(Scene current, Scene next) { if (_IsSingletonManager) { return; } CoreManager.Log(LogLevel.Warning, "_IsSingletonManager is false!"); Destroy(); }
internal void _UnregisterActor <TActor>(TActor actor) where TActor : Actor <TManager> { Type type = ((object)actor).GetType(); if (!_actors.ContainsKey(type)) { return; } _actors[type].Remove(actor); _actorsCache[type] = _actors[type].ToArray(); _sActors.Remove(actor); Actors = _sActors.ToArray(); actor._IsRegistered = false; actor._Destroy(); CoreManager.Log(LogLevel.Info, $"{type} Unregistered!"); }
internal override bool _Awake() { if (Manager == null) { Manager = CoreManager._Instance._GetManager <TManager>(); } if (Manager == null) { Object.Destroy(this); return(false); } TManager manager = Manager; manager._RegisterActor(this); Listen(true); CoreManager.Log(LogLevel.Info, "Listen status: True"); return(true); }
internal void _RegisterActor <TActor>(TActor actor) where TActor : Actor <TManager> { Type type = ((object)actor).GetType(); if (!_actors.ContainsKey(type)) { _actors.Add(type, new List <object>()); } if (!_actorsCache.ContainsKey(type)) { _actorsCache.Add(type, null); } _actors[type].Add(actor); _actorsCache[type] = _actors[type].ToArray(); _sActors.Add(actor); Actors = _sActors.ToArray(); actor._IsRegistered = true; CoreManager.Log(LogLevel.Info, $"{type} Registered!"); }
protected void Destroy() { CoreManager.Log(LogLevel.Warning, "Actor destroying..."); _Destroy(); }
internal override void _Start() { Listen(true); CoreManager.Log(LogLevel.Info, "Listen status: True"); }