Unofficial CardLife revival project, pronounced like "celery"
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

67 lignes
2.5KB

  1. using System.Reflection;
  2. using HarmonyLib;
  3. namespace CLre.Fixes
  4. {
  5. [Bugfix(name = "ClientDurabilityNodeErrorRemover",
  6. description = "Disable OnServerNotifyChange() callback when it will error",
  7. more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
  8. component = BugfixType.API, id = 3)]
  9. public static class DurabilityNodeErrorRemover
  10. {
  11. public static void Disable() => DurabilityGUIEngineClient_OnServerNotifyChange_Patch.IsDisabled = true;
  12. public static void Enable() => DurabilityGUIEngineClient_OnServerNotifyChange_Patch.IsDisabled = false;
  13. }
  14. [Bugfix(name = "ClientDurabilityNodeErrorRemover",
  15. description = "Disable OnServerNotifyChange() callback when it will error",
  16. more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
  17. component = BugfixType.HarmonyPatch, id = 3)]
  18. [HarmonyPatch]
  19. class DurabilityGUIEngineClient_OnServerNotifyChange_Patch
  20. {
  21. internal static bool AnyDurabilityClientNodeExists = false;
  22. internal static bool IsDisabled = false;
  23. [HarmonyPrefix]
  24. public static bool BeforeMethodCall()
  25. {
  26. #if DEBUG
  27. API.Utility.Logging.MetaLog("Intercepting DurabilityGUIEngineClient.OnServerNotifyChange()");
  28. #endif
  29. return AnyDurabilityClientNodeExists || IsDisabled;
  30. }
  31. [HarmonyTargetMethod]
  32. public static MethodBase Target()
  33. {
  34. return AccessTools.Method("Game.Durability.Client.DurabilityGUIEngineClient:OnServerNotifyChange");
  35. }
  36. }
  37. [Bugfix(name = "ClientDurabilityNodeErrorRemover",
  38. description = "Disable OnServerNotifyChange() callback when it will error",
  39. more = "https://trello.com/c/YT3VbXpZ/15-durability-log-error",
  40. component = BugfixType.HarmonyPatch, id = 3)]
  41. [HarmonyPatch]
  42. class DurabilityGUIEngineClientSplit_Add_Patch
  43. {
  44. [HarmonyPrefix]
  45. public static void BeforeMethodCall()
  46. {
  47. #if DEBUG
  48. API.Utility.Logging.MetaLog("Intercepting DurabilityGUIEngineClientSplit.Add()");
  49. #endif
  50. DurabilityGUIEngineClient_OnServerNotifyChange_Patch.AnyDurabilityClientNodeExists = true;
  51. }
  52. [HarmonyTargetMethod]
  53. public static MethodBase Target()
  54. {
  55. return AccessTools.Method("Game.Durability.Client.DurabilityGuiEngineClientSplit:Add", new []{ AccessTools.TypeByName("Game.Durability.Client.DurabilityClientNode")});
  56. }
  57. }
  58. }