示例#1
0
        public VanillaMod(Mod.Mod mod)
        {
            RealInstance = this;
            this.mod     = mod;

            TridevModHelper.Instance.EventBus.AddSubscription <EventSetup>(mod, EventSubscriptionPriority.Highest, e => OnSetup());
        }
示例#2
0
 public EventSubscription(Type subEventType, EventSubscriptionPriority subPriority,
                          Action <T> subHandler, Mod.Mod subscriber)
 {
     SubEventType = subEventType;
     SubPriority  = subPriority;
     SubHandler   = subHandler;
     Subscriber   = subscriber;
 }
示例#3
0
        /// <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);
        }
示例#4
0
 public TridevMod(Mod.Mod mod)
 {
     this.mod = mod;
 }
示例#5
0
 public ModContainer(Assembly modAssembly, Mod.Mod modDetails, object modInstance)
 {
     this.modAssembly = modAssembly;
     this.modDetails  = modDetails;
     this.modInstance = modInstance;
 }
示例#6
0
 /// <summary>
 /// Gets the mod container associated with the given mod if the mod is currently loaded.
 /// </summary>
 /// <param name="mod">The mod to get.</param>
 /// <returns>The mod container if it's loaded, or null if none was found.</returns>
 public ModContainer GetModContainer(Mod.Mod mod)
 {
     return(this.modContainers.ContainsKey(mod) ? this.modContainers[mod] : null);
 }