public static void DeApply() { var harmony = new Harmony.Harmony(ID); harmony.UnpatchAll(ID); DebugLog.LogToFileOnly("Harmony patches DeApplied"); }
public static void Apply() { var harmony = new Harmony.Harmony(ID); harmony.PatchAll(); Loader.HarmonyDetourFailed = false; DebugLog.LogToFileOnly("Harmony patches applied"); }
public void CheckDetour() { if (isFirstTime && Loader.DetourInited && Loader.HarmonyDetourInited) { isFirstTime = false; if (Loader.DetourInited) { DebugLog.LogToFileOnly("ThreadingExtension.OnBeforeSimulationFrame: First frame detected. Checking detours."); if (Loader.HarmonyDetourFailed) { string error = "MoreEffectiveTransfer HarmonyDetourInit is failed, Send MoreEffectiveTransfer.txt to Author."; DebugLog.LogToFileOnly(error); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); } else { var harmony = new Harmony.Harmony(HarmonyDetours.ID); var methods = harmony.GetPatchedMethods(); int i = 0; foreach (var method in methods) { var info = Harmony.Harmony.GetPatchInfo(method); if (info.Owners?.Contains(harmony.Id) == true) { DebugLog.LogToFileOnly("Harmony patch method = " + method.Name.ToString()); if (info.Prefixes.Count != 0) { DebugLog.LogToFileOnly("Harmony patch method has PreFix"); } if (info.Postfixes.Count != 0) { DebugLog.LogToFileOnly("Harmony patch method has PostFix"); } i++; } } if (i != HarmonyPatchNum) { string error = $"MoreEffectiveTransfer HarmonyDetour Patch Num is {i}, Right Num is {HarmonyPatchNum} Send MoreEffectiveTransfer.txt to Author."; DebugLog.LogToFileOnly(error); UIView.library.ShowModal <ExceptionPanel>("ExceptionPanel").SetMessage("Incompatibility Issue", error, true); } } } } }