Пример #1
0
        /// <summary>Applies the patch</summary>
        /// <param name="type">The type of patch, see <see cref="HarmonyReversePatchType"/></param>
        /// <returns>The generated replacement method</returns>
        ///
        public MethodInfo Patch(HarmonyReversePatchType type = HarmonyReversePatchType.Original)
        {
            if (original == null)
            {
                throw new NullReferenceException($"Null method for {instance.Id}");
            }

            var transpiler = GetTranspiler(standin.method);

            return(PatchFunctions.ReversePatch(standin, original, transpiler));
        }
Пример #2
0
        /// <summary>Applies the patch</summary>
        ///
        public void Patch(HarmonyReversePatchType type = HarmonyReversePatchType.Original)
        {
            if (original == null)
            {
                throw new NullReferenceException("Null method for " + instance.Id);
            }

            var transpiler = GetTranspiler(standin);

            PatchFunctions.ReversePatch(standin, original, instance.Id, transpiler);
        }
Пример #3
0
 /// <summary>Patches a foreign method onto a stub method of yours and optionally applies transpilers during the process</summary>
 /// <param name="original">The original method/constructor you want to duplicate</param>
 /// <param name="standin">Your stub method as <see cref="HarmonyMethod"/> that will become the original. Needs to have the correct signature (either original or whatever your transpilers generates)</param>
 /// <param name="transpiler">An optional transpiler as method that will be applied during the process</param>
 /// <returns>The replacement method that was created to patch the stub method</returns>
 ///
 public static MethodInfo ReversePatch(MethodBase original, HarmonyMethod standin, MethodInfo transpiler = null)
 {
     return(PatchFunctions.ReversePatch(standin, original, transpiler));
 }