예제 #1
0
 public void RemoveEvent(LEventType t, EventDelegate d)
 {
     if (_map.ContainsKey(t) == false)
     {
         return;
     }
     _map[t].Remove(d);
 }
예제 #2
0
        /// <summary>
        /// 同步广播
        /// </summary>
        /// <param name="type"></param>
        /// <param name="dataHandle"></param>
        public void SyncBroadcast(LEventType type, int dataHandle)
        {
            var actionList = m_syncListeners[type.GetHashCode()];

            for (int i = 0; i < actionList.Count; i++)
            {
                actionList[i].Invoke(dataHandle);
            }
        }
예제 #3
0
        /// <summary>
        /// 异步发送广播
        /// </summary>
        /// <param name="type"></param>
        /// <param name="dataHandle"></param>
        /// <returns></returns>
        public async UniTask AsyncBroadcast(LEventType type, int dataHandle)
        {
            var funcList = m_asyncListeners[type.GetHashCode()];

            for (int i = 0; i < funcList.Count; i++)
            {
                await funcList[i].Invoke(dataHandle);
            }
        }
예제 #4
0
 public void AddEvent(LEventType t, EventDelegate d)
 {
     if (_map.ContainsKey(t) == false)
     {
         _map.Add(t, new List <EventDelegate>());
     }
     if (HasSameRegister(t, d))
     {
         return;
     }
     _map[t].Add(d);
 }
예제 #5
0
        private bool HasSameRegister(LEventType t, EventDelegate d)
        {
            List <EventDelegate> list = _map[t];
            int count = list.Count;

            for (int i = 0; i < count; i++)
            {
                if (list[i] == d)
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #6
0
 public EventAttribute(LEventType type)
 {
     this.EventType = type;
 }
예제 #7
0
 public LEvent(LEventType t, object d = null)
 {
     type = t;
     data = d;
 }
예제 #8
0
 public EventDataInfo(LEventType type, int handle)
 {
     this.EventType = type;
     this.Handle    = handle;
 }
예제 #9
0
 /// <summary>
 /// 先同步 后异步
 /// </summary>
 /// <param name="type"></param>
 /// <param name="dataHandle"></param>
 /// <returns></returns>
 public async UniTask Broadcast(LEventType type, int dataHandle)
 {
     SyncBroadcast(type, dataHandle);
     await AsyncBroadcast(type, dataHandle);
 }
예제 #10
0
 public void RemoveListener(LEventType type, Action <int> action)
 {
     m_syncListeners[type.GetHashCode()].Remove(action);
 }
예제 #11
0
 public void RemoveListener(LEventType type, Func <int, UniTask> func)
 {
     m_asyncListeners[type.GetHashCode()].Remove(func);
 }
예제 #12
0
 public void AddListener(LEventType type, Action <int> action)
 {
     m_syncListeners[type.GetHashCode()].Add(action);
 }
예제 #13
0
 public void AddListener(LEventType type, Func <int, UniTask> func)
 {
     m_asyncListeners[type.GetHashCode()].Add(func);
 }