Patch_GameScript_RefreshRecipeUnlock.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. using HarmonyLib;
  2. using GadgetCore.API;
  3. using UnityEngine;
  4. using System.Collections;
  5. using System.Reflection;
  6. using System.Collections.Generic;
  7. namespace RecipeMenuCore.Patches
  8. {
  9. [HarmonyPatch(typeof(GameScript))]
  10. [HarmonyPatch("RefreshRecipeUnlock")]
  11. [HarmonyGadget("RecipeMenuCore")]
  12. public static class Patch_GameScript_RefreshRecipeUnlock
  13. {
  14. [HarmonyPrefix]
  15. public static bool Prefix(GameScript __instance, int ___craftType, int ___curRecipePage, GameObject ___ultLocksObj, GameObject ___recipeButtons,
  16. GameObject[] ___recipeLock, GameObject[] ___ultLocks, int[,] ___ultLocksUnlocked)
  17. {
  18. if (___craftType == 0 || ___craftType == 1)
  19. {
  20. for (int i = 0; i < 12; i++)
  21. {
  22. ___recipeButtons.transform.GetChild(i).gameObject.SetActive(true);
  23. }
  24. }
  25. var hoverElements = ___ultLocksObj.transform.parent.Find("hoverElements").gameObject;
  26. hoverElements.SetActive(false);
  27. if (___craftType == 2 && ___curRecipePage < 6)
  28. {
  29. hoverElements.SetActive(true);
  30. for (int i = 0; i < 36; i++)
  31. {
  32. if (___ultLocksUnlocked[___curRecipePage, i] == 0)
  33. {
  34. hoverElements.transform.GetChild(i).gameObject.SetActive(false);
  35. }
  36. else
  37. {
  38. hoverElements.transform.GetChild(i).gameObject.SetActive(true);
  39. }
  40. }
  41. }
  42. if (___craftType == 0 && ___curRecipePage >= 6)
  43. {
  44. ___ultLocksObj.SetActive(false);
  45. ___recipeButtons.SetActive(true);
  46. for (int i = 0; i < 12; i++)
  47. {
  48. if (Core.pageGearForgeInfoList[___curRecipePage - 6].GetRecipePageEntries().Length > i)
  49. {
  50. int itemID = Core.pageGearForgeInfoList[___curRecipePage - 6].GetRecipePageEntries()[i].ItemIdBase;
  51. if (__instance.RecipeCraftedAlready(itemID, 0))
  52. ___recipeLock[i].SetActive(false);
  53. else
  54. ___recipeLock[i].SetActive(true);
  55. }
  56. else
  57. {
  58. ___recipeLock[i].SetActive(false);
  59. ___recipeButtons.transform.GetChild(i).gameObject.SetActive(false);
  60. }
  61. }
  62. return false;
  63. }
  64. else if (___craftType == 1 && ___curRecipePage >= 2)
  65. {
  66. ___ultLocksObj.SetActive(false);
  67. ___recipeButtons.SetActive(true);
  68. for (int i = 0; i < 12; i++)
  69. {
  70. if (Core.pageAlchemyStationInfoList[___curRecipePage - 2].GetRecipePageEntries().Length > i)
  71. {
  72. int itemID = Core.pageAlchemyStationInfoList[___curRecipePage - 2].GetRecipePageEntries()[i].ItemIdBase;
  73. if (__instance.RecipeCraftedAlready(itemID, 0))
  74. ___recipeLock[i].SetActive(false);
  75. else
  76. ___recipeLock[i].SetActive(true);
  77. }
  78. else
  79. {
  80. ___recipeLock[i].SetActive(false);
  81. ___recipeButtons.transform.GetChild(i).gameObject.SetActive(false);
  82. }
  83. }
  84. return false;
  85. }
  86. else if (___craftType == 2 && ___curRecipePage >= 6)
  87. {
  88. hoverElements.SetActive(true);
  89. ___ultLocksObj.SetActive(true);
  90. ___recipeButtons.SetActive(false);
  91. for (int i = 0; i < 36; i++)
  92. {
  93. if (i < 12)
  94. {
  95. ___recipeLock[i].SetActive(false);
  96. }
  97. if (Core.pageUltimateForgeInfoList[___curRecipePage - 6].GetRecipePageEntries().Length > i / 3)
  98. {
  99. int itemID = Core.pageUltimateForgeInfoList[___curRecipePage - 6].GetRecipePageEntries()[i / 3].ItemIdExtension[i % 3];
  100. if (__instance.RecipeCraftedAlready(itemID, 0))
  101. {
  102. ___ultLocks[i].SetActive(false);
  103. hoverElements.transform.GetChild(i).gameObject.SetActive(true);
  104. }
  105. else
  106. {
  107. ___ultLocks[i].SetActive(true);
  108. hoverElements.transform.GetChild(i).gameObject.SetActive(false);
  109. }
  110. }
  111. else
  112. {
  113. ___ultLocks[i].SetActive(false);
  114. hoverElements.transform.GetChild(i).gameObject.SetActive(false);
  115. }
  116. }
  117. return false;
  118. }
  119. return true;
  120. }
  121. }
  122. }