|
- using System.Reflection;
- using HarmonyLib;
-
- namespace CLre.Fixes
- {
- [Bugfix(name = "ClientDurabilityNodeErrorRemover",
- description = "Disable OnServerNotifyChange() callback when it will error",
- more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
- component = BugfixType.API, id = 3)]
- public static class DurabilityNodeErrorRemover
- {
- public static void Disable() => DurabilityGUIEngineClient_OnServerNotifyChange_Patch.IsDisabled = true;
-
- public static void Enable() => DurabilityGUIEngineClient_OnServerNotifyChange_Patch.IsDisabled = false;
- }
-
- [Bugfix(name = "ClientDurabilityNodeErrorRemover",
- description = "Disable OnServerNotifyChange() callback when it will error",
- more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
- component = BugfixType.HarmonyPatch, id = 3)]
- [HarmonyPatch]
- class DurabilityGUIEngineClient_OnServerNotifyChange_Patch
- {
- internal static bool AnyDurabilityClientNodeExists = false;
-
- internal static bool IsDisabled = false;
-
- [HarmonyPrefix]
- public static bool BeforeMethodCall()
- {
- #if DEBUG
- API.Utility.Logging.MetaLog("Intercepting DurabilityGUIEngineClient.OnServerNotifyChange()");
- #endif
- return AnyDurabilityClientNodeExists || IsDisabled;
- }
-
- [HarmonyTargetMethod]
- public static MethodBase Target()
- {
- return AccessTools.Method("Game.Durability.Client.DurabilityGUIEngineClient:OnServerNotifyChange");
- }
- }
-
- [Bugfix(name = "ClientDurabilityNodeErrorRemover",
- description = "Disable OnServerNotifyChange() callback when it will error",
- more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
- component = BugfixType.HarmonyPatch, id = 3)]
- [HarmonyPatch]
- class DurabilityGUIEngineClientSplit_Add_Patch
- {
-
- [HarmonyPrefix]
- public static void BeforeMethodCall()
- {
- #if DEBUG
- API.Utility.Logging.MetaLog("Intercepting DurabilityGUIEngineClientSplit.Add()");
- #endif
- DurabilityGUIEngineClient_OnServerNotifyChange_Patch.AnyDurabilityClientNodeExists = true;
- }
-
- [HarmonyTargetMethod]
- public static MethodBase Target()
- {
- return AccessTools.Method("Game.Durability.Client.DurabilityGuiEngineClientSplit:Add", new []{ AccessTools.TypeByName("Game.Durability.Client.DurabilityClientNode")});
- }
- }
- }
|