public void RemoveEvent(LEventType t, EventDelegate d) { if (_map.ContainsKey(t) == false) { return; } _map[t].Remove(d); }
/// <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); } }
/// <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); } }
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); }
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); }
public EventAttribute(LEventType type) { this.EventType = type; }
public LEvent(LEventType t, object d = null) { type = t; data = d; }
public EventDataInfo(LEventType type, int handle) { this.EventType = type; this.Handle = handle; }
/// <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); }
public void RemoveListener(LEventType type, Action <int> action) { m_syncListeners[type.GetHashCode()].Remove(action); }
public void RemoveListener(LEventType type, Func <int, UniTask> func) { m_asyncListeners[type.GetHashCode()].Remove(func); }
public void AddListener(LEventType type, Action <int> action) { m_syncListeners[type.GetHashCode()].Add(action); }
public void AddListener(LEventType type, Func <int, UniTask> func) { m_asyncListeners[type.GetHashCode()].Add(func); }