/// <summary> /// 执行事件(参数:bRunNow确保在主线程中调用时才能为true,进行立即执行,默认为false到下一帧执行,防止子线程中直接执行会报错) /// </summary> /// <param name="id"></param> /// <param name="args"></param> /// <param name="bRunNow"></param> static public void CallEvent(uint id, EventMultiArgs args, bool bRunNow = false) { try { if (idEventCallback.ContainsKey(id)) { if (idEventCallback[id] != null) { if (args == null) { args = new EventMultiArgs(); } args.AddArg("EVENT_ID", id); if (bRunNow) { idEventCallback[id](args); } else { SaveEvent(args); } } } } catch (Exception e) { Debug.LogException(e); } }
public void RunUIEvent(EventMultiArgs args) { short eventID = (short)args.GetArg <short>("UI_EVENT_ID"); if (idEventCallback.ContainsKey(eventID)) { idEventCallback[eventID](args); } }
/// <summary> /// 添加缓存的事件 /// </summary> static private void SaveEvent(EventMultiArgs eventObj) { try { Monitor.Enter(_eventCachePool); _eventCachePool.Enqueue(eventObj); Monitor.Pulse(_eventCachePool); } finally { Monitor.Exit(_eventCachePool); } }
static public int constructor(IntPtr l) { try { EventManager.EventMultiArgs o; o = new EventManager.EventMultiArgs(); pushValue(l, true); pushValue(l, o); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int ContainsKey(IntPtr l) { try { EventManager.EventMultiArgs self = (EventManager.EventMultiArgs)checkSelf(l); System.String a1; checkType(l, 2, out a1); var ret = self.ContainsKey(a1); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int AddArg(IntPtr l) { try { EventManager.EventMultiArgs self = (EventManager.EventMultiArgs)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Object a2; checkType(l, 3, out a2); self.AddArg(a1, a2); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static private void RunEvent(EventMultiArgs args) { uint id = args.GetArg <uint>("EVENT_ID"); try { if (idEventCallback.ContainsKey(id)) { if (idEventCallback[id] != null) { idEventCallback[id](args); } } } catch (Exception e) { Debug.LogException(e); } }
/// <summary> /// 添加缓存的事件 /// </summary> public void SaveUIEvent(EventMultiArgs eventObj) { _eventCachePool.Enqueue(eventObj); }