Caves of Qud

Caves of Qud

Harmony Injector
 This topic has been pinned, so it's probably important
namkazt  [developer] 18 Jan, 2019 @ 2:08am
Example Manual Patch Mod
Some class that mark internal that you can't patch by using Annotation method. So here i will demo how to manual patch that kind of class ( e.g: MonoBehaviour type class , Unity, ... )

Note: this a part of my Mutated Kin mod.
... other imports using Harmony; // harmony lib using HarmonyInjector; // custom injector and shared instance namespace Namkazt.HybirdGenotype { // create a static class is require for auto run public static class Init { // static construction method. static Init() { try { Debug.Log("[Namkazt.HybridGenotype - Manual Patch] Starting initialization"); // get original method we using Injector.GetUnityType("Internal class name") var originalEnter = Injector.GetUnityType("NewGame_SelectSubtype").GetMethod("Enter"); // lead to our patching method var transEnter = typeof(Patch_NewGame).GetMethod("EnterTranspiler"); // inject the patch. // prefix postfix transpiler Injector.Shared.Patch(originalEnter, null, null, new HarmonyMethod(transEnter)); } catch (Exception ex) { Debug.Log("[Namkazt.HybirdGenotype - Manual Patch] Error when init manual patching method"); Debug.Log(ex); } } } }