/// <summary> /// Schedules a patch method instance to be run. /// </summary> /// <param name="when">When to run the patch.</param> /// <param name="instance">The patch method instance to run.</param> internal static void AddHandler(uint when, IPatchMethodInstance instance) { if (when == RunAt.Immediately) { // Now now now! instance.Run(GetImmediateInstance()); } else { lock (PSharedData.GetLock(PRegistry.KEY_POSTLOAD_LOCK)) { InitMaster(); if (patches == null) { patches = new Dictionary <uint, PrivateRunList>(8); } if (!patches.TryGetValue(when, out PrivateRunList atTime)) { patches.Add(when, atTime = new List <IPatchMethodInstance>(16)); // Register our mod in the master list if (!master.TryGetValue(when, out SharedRunList existing)) { master.Add(when, existing = new List <Action <uint> >(8)); } existing.Add(RunThisMod); } atTime.Add(instance); } } }
/// <summary> /// Schedules a patch method instance to be run. /// </summary> /// <param name="when">When to run the patch.</param> /// <param name="instance">The patch method instance to run.</param> /// <param name="harmony">The Harmony instance to use for patching.</param> private void AddHandler(uint when, IPatchMethodInstance instance) { if (!patches.TryGetValue(when, out PrivateRunList atTime)) { patches.Add(when, atTime = new List <IPatchMethodInstance>(16)); } atTime.Add(instance); }