Ejemplo n.º 1
0
 public static void RegisterListener(Action <PathfinderEvent> listener, string debugName = null, int?priority = null)
 {
     InternalUtility.ValidateNoId(log: false);
     RegisterExpressionListener(listener.Method.GetParameters()[0].ParameterType,
                                new ListenerObject(listener.Method, new ListenerOptions {
         DebugName = debugName, PriorityStore = priority
     }));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Registers an event listener by compile time type.
 /// </summary>
 /// <param name="listener">The listener function that will be executed on an event call</param>
 /// <param name="debugName">Name to assign for debug purposes</param>
 /// <typeparam name="T">The PathfinderEvent Compile time Type to listen for</typeparam>
 public static void RegisterListener <T>(Action <T> listener, string debugName, int?priority)
     where T : PathfinderEvent
 {
     InternalUtility.ValidateNoId(log: false);
     RegisterExpressionListener(typeof(T), new ListenerObject(listener.Method,
                                                              new ListenerOptions {
         DebugName = debugName, PriorityStore = priority
     }));
 }
Ejemplo n.º 3
0
        private static void RegisterExpressionListener(Type pathfinderEventType, ListenerObject listenerObj)
        {
            InternalUtility.ValidateNoId("Event Listener", listenerObj.Options.DebugName, $" with priority {listenerObj.Options.Priority}");
            if (!eventListeners.ContainsKey(pathfinderEventType))
            {
                eventListeners.Add(pathfinderEventType, new List <ListenerObject>());
            }
            var list = eventListeners[pathfinderEventType];

            list.Add(listenerObj);
            list.Sort((x, y) => y.Options.Priority - x.Options.Priority);
        }
Ejemplo n.º 4
0
 public static void RegisterListener(Type pathfinderEventType, Action <PathfinderEvent> listener, ListenerOptions options)
 {
     InternalUtility.ValidateNoId(log: false);
     RegisterExpressionListener(pathfinderEventType, new ListenerObject(listener.Method, options));
 }
Ejemplo n.º 5
0
 public static void RegisterListener <T>(Action <T> listener, ListenerOptions options)
     where T : PathfinderEvent
 {
     InternalUtility.ValidateNoId(log: false);
     RegisterExpressionListener(typeof(T), new ListenerObject(listener.Method, options));
 }
Ejemplo n.º 6
0
 public static void RegisterListener <T>(Action <T> listener, string debugName = null)
     where T : PathfinderEvent
 {
     InternalUtility.ValidateNoId(log: false);
     RegisterListener(listener, debugName, null);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Registers an event listener by runtime type.
 /// </summary>
 /// <param name="pathfinderEventType">The PathfinderEvent Runtime Type to register for</param>
 /// <param name="listener">The listener function that will be executed on an event call</param>
 /// <param name="debugName">Name to assign for debug purposes</param>
 public static void RegisterListener(Type pathfinderEventType, Action <PathfinderEvent> listener, string debugName = null)
 {
     InternalUtility.ValidateNoId(log: false);
     RegisterListener(pathfinderEventType, listener, debugName);
 }