public EventSubscription(Type subEventType, EventSubscriptionPriority subPriority, Action <T> subHandler, Mod.Mod subscriber) { SubEventType = subEventType; SubPriority = subPriority; SubHandler = subHandler; Subscriber = subscriber; }
/// <summary> /// Subscribe to an event on the event bus. /// </summary> /// <param name="subscriber">The mod that is subscribing to this event.</param> /// <param name="priority">The event priority.</param> /// <param name="handler">The handler that's called when the event is fired.</param> /// <typeparam name="T">The type of event that the subscription listens for.</typeparam> /// <returns>An EventSubscription if the subscription was added, or null if it failed.</returns> public EventSubscription <T> AddSubscription <T>(Mod.Mod subscriber, EventSubscriptionPriority priority, Action <T> handler) where T : EventBase { var eventType = typeof(T); if (!this.subLists.ContainsKey(eventType)) { this.subLists.Add(eventType, new EventSubscriptionList(eventType)); } var subscription = new EventSubscription <T>(eventType, priority, handler, subscriber); return(this.subLists[eventType].AddSubscription(subscription) ? subscription : null); }