internal void RegisterHandler(ActorEventHandler handler) { if (handlers == null) { handlers = handlersPool.Get(); } handlers.Insert(FindHandlerInsertionPoint(handler.priority), handler); OnCallbackRegistered(handler.eventType); }
internal bool TryGetHandler(Type eventType, out ActorEventHandler result) { foreach (var handler in info.handlers) { if (handler.eventType == eventType) { result = handler; result.component = this; return(true); } } result = new ActorEventHandler(); return(false); }
internal void UnregisterHandler(ActorEventHandler handler) { if (handlers == null) { return; } for (int handlerIndex = handlers.Count - 1; handlerIndex >= 0; handlerIndex--) { if (handlers[handlerIndex].component == handler.component && handlers[handlerIndex].eventType == handler.eventType) { handlers.RemoveAt(handlerIndex); break; } } if (handlers.Count <= 0) { handlersPool.Release(handlers); handlers = null; } OnCallbackUnregistered(handler.eventType); }
internal bool TryGetHandler <T>(out ActorEventHandler result) => TryGetHandler(typeof(T), out result);