Exemplo n.º 1
0
 public static void RemoveListiner(Type type, AbstractEventHandler.OnEvent onEvent, params object[] arg)
 {
     if (CheckIfEditor())
     {
         return;
     }
     Instance.queuedRemoveListeners.Insert(0, new QueuedListener(type, null, onEvent, null, arg));
 }
Exemplo n.º 2
0
 public QueuedListener(Type eventType, Delegate internalDelegate, AbstractEventHandler.OnEvent onEvent, UnityEngine.Object handle, object[] args)
 {
     this.eventType        = eventType;
     this.args             = args;
     this.internalDelegate = internalDelegate;
     this.onEvent          = onEvent;
     this.handle           = handle;
 }
Exemplo n.º 3
0
 public static void RemoveListiner <T>(AbstractEventHandler.OnEvent <T> onEvent, params object[] arg) where T : Event
 {
     if (CheckIfEditor())
     {
         return;
     }
     Instance.queuedRemoveListeners.Insert(0, new QueuedListener(typeof(T), onEvent, null, null, arg));
 }
Exemplo n.º 4
0
 public ListenerWrapper(AbstractEventHandler.OnEvent callback, UnityEngine.Object handle)
 {
     this.callback = callback;
     if (handle != null)
     {
         hasHandle   = true;
         this.handle = handle;
     }
 }
Exemplo n.º 5
0
    public static void AddListenerToHandler <T>(AbstractEventHandler handler, AbstractEventHandler.OnEvent <T> onEvent, params object[] arg) where T : Event
    {
        if (CheckIfEditor())
        {
            return;
        }

        //clear to be removed if being added again
        if (Instance.queuedRemoveListeners.RemoveAll(l => l.internalDelegate == onEvent) <= 0)
        {
            //add the listener to the event handler
            handler.AddListener(onEvent, WrapListener(onEvent), onEvent.Target as UnityEngine.Object, arg);
        }
    }
Exemplo n.º 6
0
    public static void AddListiner <T>(AbstractEventHandler.OnEvent <T> onEvent, UnityEngine.Object handle, params object[] arg) where T : Event
    {
        if (CheckIfEditor())
        {
            return;
        }

        //clear to be removed if being added again
        if (Instance.queuedRemoveListeners.RemoveAll(l => l.internalDelegate == onEvent) <= 0)
        {
            //add the listener to the event handler
            AbstractEventHandler eventHandler;
            if (Instance.eventListeners.TryGetValue(typeof(T), out eventHandler))
            {
                eventHandler.AddListener(onEvent, WrapListener(onEvent), handle, arg);
                return;
            }
            Instance.queuedListeners.Add(new QueuedListener(typeof(T), onEvent, WrapListener(onEvent), handle, arg));
        }
    }
Exemplo n.º 7
0
 public static void AddListiner(Type type, AbstractEventHandler.OnEvent onEvent, UnityEngine.Object handle, params object[] arg)
 {
     if (CheckIfEditor())
     {
         return;
     }
     //clear to be removed if being added again
     if (Instance.queuedRemoveListeners.Any(l => l.onEvent == onEvent))
     {
         Instance.queuedRemoveListeners.RemoveAll(l => l.onEvent == onEvent);
     }
     else
     {
         AbstractEventHandler eventHandler;
         if (Instance.eventListeners.TryGetValue(type, out eventHandler))
         {
             eventHandler.AddListener(null, onEvent, handle, arg);
             return;
         }
         Instance.queuedListeners.Add(new QueuedListener(type, null, onEvent, handle, arg));
     }
 }
Exemplo n.º 8
0
 public ListenerWrapperWeighted(AbstractEventHandler.OnEvent callback, UnityEngine.Object handle, int weight) : base(callback, handle)
 {
     this.weight = weight;
 }
Exemplo n.º 9
0
 public static AbstractEventHandler.OnEvent WrapListener <T>(AbstractEventHandler.OnEvent <T> onEvent) where T : Event
 {
     return(e => onEvent((T)e));
 }
Exemplo n.º 10
0
 public static void AddListiner <T>(AbstractEventHandler.OnEvent <T> onEvent, params object[] arg) where T : Event
 {
     AddListiner(onEvent, onEvent.Target as UnityEngine.Object, arg);
 }
Exemplo n.º 11
0
 public static void AddListiner(Type type, AbstractEventHandler.OnEvent onEvent, params object[] arg)
 {
     AddListiner(type, onEvent, onEvent.Target as UnityEngine.Object, arg);
 }