Patch_GameScript_Storage.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using UnityEngine;
  4. namespace StorageExpansion.Patches
  5. {
  6. [HarmonyPatch(typeof(GameScript))]
  7. [HarmonyPatch("Storage")]
  8. [HarmonyGadget("StorageExpansion")]
  9. public static class Patch_GameScript_Storage
  10. {
  11. [HarmonyPostfix]
  12. public static void Postfix(GameScript __instance, int ___storageLevel, bool ___enteringCombatMode)
  13. {
  14. if (!___enteringCombatMode)
  15. {
  16. for (int i = 0; i < __instance.storageButton.Length; i++)
  17. {
  18. if (i <= ___storageLevel)
  19. {
  20. __instance.storageButton[i].GetComponent<Renderer>().enabled = false;
  21. }
  22. else
  23. {
  24. __instance.storageButton[i].GetComponent<Renderer>().enabled = true;
  25. }
  26. }
  27. int storageUpgradeCost = __instance.GetStorageUpgradeCost(___storageLevel);
  28. if (___storageLevel == __instance.storageButton.Length - 1)
  29. {
  30. __instance.txtStorageCost[0].text = "Max Lvl";
  31. __instance.txtStorageCost[1].text = "Max Lvl";
  32. }
  33. else
  34. {
  35. __instance.txtStorageCost[0].text = string.Empty + storageUpgradeCost;
  36. __instance.txtStorageCost[1].text = string.Empty + storageUpgradeCost;
  37. }
  38. }
  39. }
  40. }
  41. }