Example #1
0
 static public int constructor(IntPtr l)
 {
     try {
         EventManager.EventID o;
         o = new EventManager.EventID();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #2
0
 /// <summary>
 /// Register to listen for eventID
 /// </summary>
 /// <param name="eventID">EventID that object want to listen</param>
 /// <param name="callback">Callback will be invoked when this eventID be raised</param>
 public static void RegisterListener(EventID eventID, Action <Component, object> callback)
 {
     #region
     // check if listener exist in distionary
     //if (_listenersDict.ContainsKey(eventID))
     //{
     //    // add callback to our collection
     //    _listenersDict[eventID].Add(callback);
     //}
     //else
     if (!_listenersDict.ContainsKey(eventID))
     {
         // add new key-value pair
         var newList = new List <Action <Component, object> >();
         newList.Add(callback);
         _listenersDict.Add(eventID, newList);
     }
     #endregion
 }
Example #3
0
        /// <summary>
        /// Removes the listener. Use to Unregister listener
        /// </summary>
        /// <param name="eventID">EventID.</param>
        /// <param name="callback">Callback.</param>
        public static void RemoveListener(EventID eventID, Action <Component, object> callback)
        {
            #region
            _listenersDict.Remove(eventID);

            //List<Action<Component, object>> actionList;
            //if (_listenersDict.TryGetValue(eventID, out actionList))
            //{
            //    if (actionList.Contains(callback))
            //    {
            //        actionList.Remove(callback);
            //        if (actionList.Count == 0)// no listener remain for this event
            //        {
            //            _listenersDict.Remove(eventID);
            //        }
            //    }
            //}
            //else
            //{
            //    // the listeners not exist
            //    Debug.LogWarningFormat(null, "RemoveListener, event : {0}, no listener found", eventID.ToString());
            //}
            #endregion
        }
Example #4
0
 /// Post event with no param (param = null)
 public static void PostEvent(this MonoBehaviour sender, EventID eventID)
 {
     EventDispatcher.PostEvent(eventID, sender, null);
 }
Example #5
0
 /// Post event with param
 public static void PostEvent(this MonoBehaviour sender, EventID eventID, object param)
 {
     EventDispatcher.PostEvent(eventID, sender, param);
 }
Example #6
0
 public static void RemoveListener(this MonoBehaviour sender, EventID eventID, Action <Component, object> callback)
 {
     EventDispatcher.RemoveListener(eventID, callback);
 }