예제 #1
0
 /// <summary>
 /// Runs all patches for the specified time.
 /// </summary>
 /// <param name="when">The time to run the patch.</param>
 private static void RunThisMod(uint when)
 {
     if (patches.TryGetValue(when, out PrivateRunList toRun))
     {
         // Create Harmony instance for the patches
         var instance = HarmonyInstance.Create("PLib.PostLoad." + RunAt.ToString(when));
         foreach (var method in toRun)
         {
             try {
                 method.Run(instance);
             } catch (TargetInvocationException e) {
                 // Use the inner exception
                 PUtil.LogException(e.GetBaseException());
             }
         }
예제 #2
0
 /// <summary>
 /// Runs all patches for the specified time.
 /// </summary>
 /// <param name="when">The time to run the patch.</param>
 private static void RunThisMod(uint when)
 {
     if (patches.TryGetValue(when, out PrivateRunList toRun))
     {
         // Create Harmony instance for the patches
         var instance = HarmonyInstance.Create("PLib.PostLoad." + RunAt.ToString(when));
         foreach (var method in toRun)
         {
             try {
                 method.Run(instance);
             } catch (Exception e) {
                 // Say which mod's postload crashed
                 PUtil.LogException(e);
             }
         }
     }
 }
예제 #3
0
        /// <summary>
        /// Runs all patches for all mods at the given time. Only to be run by the forwarded
        /// instance!
        /// </summary>
        /// <param name="when">The runtime (do not use Immediate) of patches to run.</param>
        internal static void RunAll(uint when)
        {
            SharedRunList toRun;

            lock (PSharedData.GetLock(PRegistry.KEY_POSTLOAD_LOCK)) {
                InitMaster();
                if (!master.TryGetValue(when, out toRun))
                {
                    toRun = null;
                }
            }
            if (toRun != null)
            {
                PRegistry.LogPatchDebug("Executing handlers for stage {1} from {0:D} mod(s)".
                                        F(toRun.Count, RunAt.ToString(when)));
                foreach (var modHandler in toRun)
                {
                    modHandler?.Invoke(when);
                }
            }
        }
예제 #4
0
 public override string ToString()
 {
     return("PLibPatch[RunAt={0},PatchType={1},MethodName={2}]".F(RunAt.ToString(
                                                                      Runtime), PatchType, MethodName));
 }
예제 #5
0
 public override string ToString()
 {
     return("PLibMethod[RunAt={0}]".F(RunAt.ToString(Runtime)));
 }