Patch_GameScript_UpgradeStorage.cs 1000 B

123456789101112131415161718192021222324252627282930313233
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. namespace IronmanChest.Patches
  4. {
  5. [HarmonyPatch(typeof(GameScript))]
  6. [HarmonyPatch("UpgradeStorage")]
  7. [HarmonyGadget("IronmanChest")]
  8. public static class Patch_GameScript_UpgradeStorage
  9. {
  10. [HarmonyPrefix]
  11. public static void Prefix(GameScript __instance, Item[] ___storage, ref int ___storageLevel, out int __originalStorageLevel)
  12. {
  13. __originalStorageLevel = -1;
  14. if (Menuu.curProfession == 1)
  15. {
  16. __originalStorageLevel = PreviewLabs.PlayerPrefs.GetInt("storageLevel");
  17. }
  18. }
  19. [HarmonyPostfix]
  20. [HarmonyPriority(Priority.Low)]
  21. public static void Postfix(GameScript __instance, Item[] ___storage, ref int ___storageLevel, int __originalStorageLevel)
  22. {
  23. if (Menuu.curProfession == 1)
  24. {
  25. PreviewLabs.PlayerPrefs.SetInt("storageLevel", __originalStorageLevel);
  26. PreviewLabs.PlayerPrefs.SetInt(Menuu.curChar + "ironmanstorageLevel", ___storageLevel);
  27. }
  28. }
  29. }
  30. }