示例#1
0
 public void DisposeEventIndex(EventIndex index)
 {
     foreach (var kv in eventIndices.Where((kv) => kv.Value == index).ToArray())
     {
         eventIndices.Remove(kv.Key);
     }
 }
示例#2
0
 private void RegisterListener(EventIndex index, IEventListener listener)
 {
     if (index == EventIndex.Null)
     {
         return;
     }
     if (!eventListeners.TryGetValue(index, out List <IEventListener> listeners))
     {
         listeners             = new List <IEventListener>();
         eventListeners[index] = listeners;
     }
     listeners.Add(listener);
 }
示例#3
0
 private void Dispatch(EventIndex index, object eventObject)
 {
     if (index == EventIndex.Null)
     {
         return;
     }
     if (eventListeners.TryGetValue(index, out List <IEventListener> listeners))
     {
         foreach (var listener in listeners)
         {
             listener.OnEvent(eventObject);
         }
     }
 }
示例#4
0
 private void UnregisterListener(EventIndex index, IEventListener listener)
 {
     if (index == EventIndex.Null)
     {
         return;
     }
     if (eventListeners.TryGetValue(index, out List <IEventListener> listeners))
     {
         listeners.Remove(listener);
         if (listeners.Count == 0)
         {
             eventListeners.Remove(index);
             foreach (var r in eventRouters)
             {
                 r.DisposeEventIndex(index);
             }
             defaultEventRouter.DisposeEventIndex(index);
             eventIndexPool.Destroy(index);
         }
     }
 }
示例#5
0
 public abstract void DisposeEventIndex(EventIndex index);