Patch_GameScript_RefreshSlotStorage.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using System.Collections;
  4. using System.Reflection;
  5. using UnityEngine;
  6. namespace StorageExpansion.Patches
  7. {
  8. [HarmonyPatch(typeof(GameScript))]
  9. [HarmonyPatch("RefreshSlotStorage")]
  10. [HarmonyGadget("StorageExpansion")]
  11. public static class Patch_GameScript_RefreshSlotStorage
  12. {
  13. [HarmonyPrefix]
  14. public static bool Prefix(GameScript __instance, int i, Item[] ___storage, GameObject[] ___storageIconBack, GameObject[] ___storageIcon,
  15. int ___curStoragePage, TextMesh[] ___txtQStorage)
  16. {
  17. int num = i + ___curStoragePage * Core.settingAmountSlots;
  18. ___storageIcon[i].GetComponent<Renderer>().material = (Material)Resources.Load("i/i" + ___storage[num].id);
  19. AnimIcon animIcon = (AnimIcon)___storageIconBack[i].GetComponent("AnimIcon");
  20. if (___storage[num].id < 300 || ___storage[num].id >= 2000)
  21. {
  22. ___storageIconBack[i].SetActive(false);
  23. animIcon.anim = 0;
  24. }
  25. else
  26. {
  27. ___storageIconBack[i].GetComponent<Renderer>().material = (Material)Resources.Load("iBack" + ___storage[num].tier);
  28. if (___storage[num].tier == 3)
  29. {
  30. animIcon.anim = 1;
  31. }
  32. else
  33. {
  34. animIcon.anim = 0;
  35. }
  36. ___storageIconBack[i].SetActive(true);
  37. }
  38. if (___storage[num].q > 1)
  39. {
  40. ___txtQStorage[i].text = string.Empty + ___storage[num].q;
  41. }
  42. else
  43. {
  44. ___txtQStorage[i].text = string.Empty;
  45. }
  46. return false;
  47. }
  48. }
  49. }