예제 #1
0
 /// <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);
     }
 }
예제 #2
0
        public void RunUIEvent(EventMultiArgs args)
        {
            short eventID = (short)args.GetArg <short>("UI_EVENT_ID");

            if (idEventCallback.ContainsKey(eventID))
            {
                idEventCallback[eventID](args);
            }
        }
예제 #3
0
 /// <summary>
 /// 添加缓存的事件
 /// </summary>
 static private void SaveEvent(EventMultiArgs eventObj)
 {
     try
     {
         Monitor.Enter(_eventCachePool);
         _eventCachePool.Enqueue(eventObj);
         Monitor.Pulse(_eventCachePool);
     }
     finally
     {
         Monitor.Exit(_eventCachePool);
     }
 }
예제 #4
0
 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));
     }
 }
예제 #5
0
 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));
     }
 }
예제 #6
0
 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));
     }
 }
예제 #7
0
        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);
            }
        }
예제 #8
0
 /// <summary>
 /// 添加缓存的事件
 /// </summary>
 public void SaveUIEvent(EventMultiArgs eventObj)
 {
     _eventCachePool.Enqueue(eventObj);
 }