Ejemplo n.º 1
0
        static void ApplyPatch(string owner, MethodBase target, HarmonyMethod prefix = null, HarmonyMethod postfix = null, HarmonyMethod transpiler = null)
        {
            var instance  = HarmonyInstance.Create(owner);
            var processor = new Harmony.PatchProcessor(instance, new List <MethodBase> {
                target
            }, prefix: prefix, postfix: postfix, transpiler: transpiler);

            processor.Patch();
        }
Ejemplo n.º 2
0
        public void TestMultiple()
        {
            var targetMethods = new List <MethodBase>()
            {
                AccessTools.Method(typeof(PatchProcessorClass1), nameof(PatchProcessorClass1.TestA)),
                AccessTools.Method(typeof(PatchProcessorClass1), nameof(PatchProcessorClass1.TestB))
            };
            var postfix   = new HarmonyMethod(typeof(PatchProcessorPatchClass1), nameof(PatchProcessorPatchClass1.Postfix));
            var harmony   = HarmonyInstance.Create("test");
            var processor = new Harmony.PatchProcessor(harmony, targetMethods, postfix: postfix);

            processor.Patch();
            Assert.AreEqual("Patched", PatchProcessorClass1.TestA(), "Test A");
            Assert.AreEqual("Patched", PatchProcessorClass1.TestB(), "Test B");
        }
Ejemplo n.º 3
0
        public void Patch(MethodBase original, HarmonyMethod prefix, HarmonyMethod postfix, HarmonyMethod transpiler = null)
        {
            var processor = new PatchProcessor(this, original, prefix, postfix, transpiler);

            processor.Patch();
        }
Ejemplo n.º 4
0
        //

        public Patches IsPatched(MethodBase method)
        {
            return(PatchProcessor.IsPatched(method));
        }
Ejemplo n.º 5
0
 public Patches GetPatchInfo(MethodBase method)
 {
     return(PatchProcessor.GetPatchInfo(method));
 }