static void OnListenerRemoved(GTEventID e) { if (mEvents[e] == null) { mEvents.Remove(e); } }
public static void DelHandler <T, U, V>(GTEventID e, Callback <T, U, V> handler) { if (mEvents.ContainsKey(e) == false) { return; } mEvents[e] = (Callback <T, U, V>)mEvents[e] - handler; OnListenerRemoved(e); }
public static void FireEvent <T, U, V, X>(GTEventID e, T arg1, U arg2, V arg3, X arg4) { Delegate d; if (mEvents.TryGetValue(e, out d)) { Callback <T, U, V, X> callback = d as Callback <T, U, V, X>; if (callback != null) { callback(arg1, arg2, arg3, arg4); } } }
static void OnListenerAdding(GTEventID e, Delegate d) { if (!mEvents.ContainsKey(e)) { mEvents.Add(e, null); } Delegate ed = mEvents[e]; if (ed != null && d.GetType() != ed.GetType()) { string error = string.Format("添加事件监听错误,EventID:{0},添加的事件{1},已存在的事件{2}", e.ToString(), d.GetType().Name, ed.GetType().Name); Debug.LogError(error); } }
public static void FireEvent <T>(GTEventID e, T arg1) { Delegate d; if (mEvents.TryGetValue(e, out d)) { Callback <T> callback = d as Callback <T>; if (callback != null) { callback(arg1); } } }
public static void FireEvent(GTEventID e) { Delegate d; if (mEvents.TryGetValue(e, out d)) { Callback callback = d as Callback; if (callback != null) { callback(); } } }
public static void AddHandler <T, U, V, X>(GTEventID e, Callback <T, U, V, X> handler) { OnListenerAdding(e, handler); mEvents[e] = (Callback <T, U, V, X>)mEvents[e] + handler; }
public static void AddHandler(GTEventID e, Callback handler) { OnListenerAdding(e, handler); mEvents[e] = (Callback)mEvents[e] + handler; }