public void Dump(MainLoopEvent mainloopevent) { #if UNITY_EDITOR var en = this.callbackMap.GetEnumerator(); while (en.MoveNext()) { Action <object, int> act = en.Current.Value; if (act != null && callbackListMap[en.Current.Key].Count > 0) { System.Delegate d = act as System.Delegate; Delegate[] delegates = d.GetInvocationList(); for (int i = 0; i < delegates.Length; ++i) { LogMgr.LogWarningFormat(" InstanceCacheDelegate {0} in {1} not clear at {2}", delegates[i].Method.Name, delegates[i].Method.DeclaringType, mainloopevent); } } } var listen = this.callbackListMap.GetEnumerator(); while (listen.MoveNext()) { List <object> list = listen.Current.Value; if (list != null && list.Count > 0) { for (int i = 0; i < list.Count; ++i) { object o = list[i]; LogMgr.LogWarningFormat("InstanceCacheDelegate {0} not clear at {1}", o, mainloopevent); } } } #endif }
private void _tryCall(MainLoopEvent em, int val = -1) { try { int e = (int)em; if (this.methodDic.ContainsKey(e)) { this.methodDic[e].Invoke(val); } if (eventList.ContainsKey(e)) { Action <int> callback = eventList[e]; if (callback != null) { if (FrameWorkConfig.Open_DEBUG) { var list = callback.GetInvocationList(); for (int i = 0; i < list.Length; ++i) { list[i].DynamicInvoke(val); } } else { if (callback != null) { callback(val); } } } else { eventList.Remove(e); } } if (this.attEvents.ContainsKey(e)) { if (attEvents[e] != null) { attEvents[e].Invoke(e); } } } catch (FrameWorkException ex) { LogMgr.LogException(ex); ex.RaiseExcption(); } catch (Exception ex) { LogMgr.LogException(ex); } }
public bool UnRegisterCachedAction(MainLoopEvent em, int id, System.Object ins) { int e = (int)em; if (this.attEvents.ContainsKey(e)) { InstanceCacheDelegate d = this.attEvents[e]; return(d.Remove(id, ins)); } return(false); }
public bool UnRegisterLoopEvent(MainLoopEvent em, Action <int> d) { int e = (int)em; if (eventList.ContainsKey(e)) { this.eventList[e] -= d; return(true); } return(false); }
public bool UnRegisterLoopEvent(MainLoopEvent em, MethodInfo method) { int e = (int)em; if (eventList.ContainsKey(e)) { this.eventList[e] -= (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), method); return(true); } return(false); }
public bool UnRegisterStaticEvent(MainLoopEvent em, MethodInfo method) { int e = (int)em; if (methodDic.ContainsKey(e)) { Action <int> func = (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), method); methodDic[e].Rmove(func); return(true); } return(false); }
public static void DestroyAttEvent(MainLoopEvent loopevent, Type tp, string methodname) { MethodInfo method = tp.GetMethod(methodname, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static); if (method != null) { MainLoop.getInstance().UnRegisterLoopEvent(loopevent, method); } else { LogMgr.LogErrorFormat("cant found {0} in type :{1}", methodname, tp); } }
public void RegisterStaticEvent(MainLoopEvent em, MethodInfo method, int Priority = 0) { int e = (int)em; Action <int> func = (Action <int>)Delegate.CreateDelegate(typeof(Action <int>), method); if (this.methodDic.ContainsKey(e)) { this.methodDic[e].Add(func, Priority); } else { StaticDelegate d = new StaticDelegate(); d.Add(func, Priority); this.methodDic.Add(e, d); } }
public void RegisterCachedAction(MainLoopEvent em, int id, System.Object ins) { int e = (int)em; if (this.attEvents.ContainsKey(e)) { InstanceCacheDelegate d = this.attEvents[e]; d.Add(id, ins); } else { InstanceCacheDelegate d = new InstanceCacheDelegate(); d.Add(id, ins); this.attEvents.Add(e, d); } }
public void PreRegisterCachedAction(MainLoopEvent em, Action <System.Object, int> act) { int e = (int)em; if (this.attEvents.ContainsKey(e)) { InstanceCacheDelegate d = this.attEvents[e]; d.PreAdd(act); } else { InstanceCacheDelegate d = new InstanceCacheDelegate(); d.PreAdd(act); this.attEvents.Add(e, d); } }
public void Dump(MainLoopEvent mainloopevent) { #if UNITY_EDITOR var en = this.cachesMap.GetEnumerator(); while (en.MoveNext()) { Action <int> act = en.Current.Value; if (act != null) { System.Delegate d = act as System.Delegate; Delegate[] delegates = d.GetInvocationList(); for (int i = 0; i < delegates.Length; ++i) { LogMgr.LogWarningFormat(" StaticDelegate {0} in {1} not clear at:{2}", delegates[i].Method.Name, delegates[i].Method.DeclaringType, mainloopevent); } } } #endif }
public void RegisterLoopEvent(MainLoopEvent em, Action <int> d, bool first = false) { int e = (int)em; if (eventList.ContainsKey(e)) { if (!first) { this.eventList[e] += d; } else { Action <int> old = this.eventList[e]; d += old; this.eventList[e] = d; } } else { this.eventList[e] = d; } }
public DelegateMethodAttribute(MainLoopEvent ev, string pname, Type passtp) { this.Invokeopportunity = ev; this.name = pname; this.tp = passtp; }
// // This is called once every main loop frame, outside of object context // internal static void OnMainLoop(ulong frame) { MainLoopEvent?.Invoke(null, new EventArgs()); }