-
Notifications
You must be signed in to change notification settings - Fork 0
/
workshop.json
1 lines (1 loc) · 2.28 KB
/
workshop.json
1
{"workshopId":1625698528,"Title":"Harmony Injector","Description":"[b]Note[/b]: At the first time install before Enable this mod, you should restart game for make sure mod compiled success.\r\n\r\n[b]Note[/b]: Upgrade guide from HarmonyShim to Harmony Injector here: https://steamcommunity.com/workshop/filedetails/discussion/1625698528/1771511442696801069/\r\n\r\nHarmony Injector is another injector for Harmony lib. This allow other mods patch any method of the game that not available for modding at current time.\r\n\r\nCompare with HarmonyShim this mod allow to use mostly all features of Harmonylike PatchAll with Annotation, Manual Patching, AccessTools, Traverse, ... and just like you using Harmony package directly\r\n\r\nFor using just: \r\n[code]\r\nusing Harmony;\r\n\r\n... create patch class: in where we patch Mutate function of MultipleArms class\r\n\r\n[HarmonyPatch(typeof(MultipleArms))]\r\n[HarmonyPatch(\"Mutate\", new[] { typeof(GameObject), typeof(int) })]\r\nclass Patch\r\n{\r\n static void Postfix()\r\n {\r\n Debug.Log(\"[Namkazt.HarmonyTest] Yay!. We just override mutate function if you have mutation [MultipleArms]\");\r\n }\r\n}\r\n[/code]\r\nand call Harmony functions like normal.\r\n\r\n[b]Note:[/b] you do NOT have to call: \r\n[code]\r\nvar harmony = HarmonyInstance.Create(\"your.mod.id\");\r\nharmony.PatchAll(XRL.ModManager.modAssembly);\r\n// or harmony.PatchAll(Assembly.GetExecutingAssembly());\r\n[/code]\r\n\r\nNew update: allow to patch in unity MonoBehaviour easier ([b]internal class[/b]) by follow this example:\r\n[code]\r\nusing HarmonyInjector;\r\n\r\n.... your name space\r\n\r\npublic static class Init\r\n{\r\n static Init()\r\n {\r\n try\r\n {\r\n var original = Injector.GetUnityType(\"Unity MonoBehaviour Class\").GetMethod(\"Method to patch\");\r\n var postfix = typeof(Patch_NewGame_SelectSubtype).GetMethod(\"Transpiler\");\r\n Injector.Shared.Patch(original, null, null, new HarmonyMethod(postfix));\r\n }\r\n catch (Exception ex)\r\n {\r\n Debug.Log(ex);\r\n }\r\n }\r\n}\r\n[/code]\r\n\r\nLearn about Harmony: https://github.com/pardeike/Harmony/wiki/Patching","Tags":"Scripting, C#, Harmony, Modder's Resource","Visibility":"2","ImagePath":"preview.png"}