Patch_GameScript_LoadGame.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. namespace IronmanChest.Patches
  4. {
  5. [HarmonyPatch(typeof(GameScript))]
  6. [HarmonyPatch(nameof(GameScript.LoadGame))]
  7. [HarmonyGadget("IronmanChest")]
  8. public static class Patch_GameScript_LoadGame
  9. {
  10. [HarmonyPostfix]
  11. public static void Postfix(GameScript __instance, Item[] ___storage, ref int ___storageLevel)
  12. {
  13. if (Menuu.curProfession == 1)
  14. {
  15. ___storageLevel = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorageLevel");
  16. if (___storageLevel == 0)
  17. ___storageLevel = 1;
  18. for (int i = 0; i < Core.settingAmountPages * Core.settingAmountSlots; i++)
  19. {
  20. ___storage[i].id = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "id");
  21. ___storage[i].q = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "q");
  22. ___storage[i].exp = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "exp");
  23. ___storage[i].tier = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "tier");
  24. ___storage[i].corrupted = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "corrupted");
  25. ___storage[i].aspect[0] = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "a0");
  26. ___storage[i].aspect[1] = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "a1");
  27. ___storage[i].aspect[2] = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "a2");
  28. ___storage[i].aspectLvl[0] = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "aL0");
  29. ___storage[i].aspectLvl[1] = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "aL1");
  30. ___storage[i].aspectLvl[2] = PreviewLabs.PlayerPrefs.GetInt(Menuu.curChar + "ironmanstorage" + i + "aL2");
  31. }
  32. __instance.StartCoroutine(__instance.RefreshStoragePage(0));
  33. }
  34. }
  35. }
  36. }