| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- using HarmonyLib;
- using GadgetCore.API;
- using UnityEngine;
- using System.Collections;
- using System.Reflection;
- using System.Collections.Generic;
- namespace RecipeMenuCore.Patches
- {
- [HarmonyPatch(typeof(GameScript))]
- [HarmonyPatch("RefreshRecipeUnlock")]
- [HarmonyGadget("RecipeMenuCore")]
- public static class Patch_GameScript_RefreshRecipeUnlock
- {
- [HarmonyPrefix]
- public static bool Prefix(GameScript __instance, int ___craftType, int ___curRecipePage, GameObject ___ultLocksObj, GameObject ___recipeButtons,
- GameObject[] ___recipeLock, GameObject[] ___ultLocks)
- {
- if (___craftType == 0 || ___craftType == 1)
- {
- for (int i = 0; i < 12; i++)
- {
- ___recipeButtons.transform.GetChild(i).gameObject.SetActive(true);
- }
- }
- if (___craftType == 0 && ___curRecipePage >= 6)
- {
- ___ultLocksObj.SetActive(false);
- ___recipeButtons.SetActive(true);
- for (int i = 0; i < 12; i++)
- {
- if (Core.pageGearForgeInfoList[___curRecipePage - 6].GetRecipePageEntries().Length > i)
- {
- int itemID = Core.pageGearForgeInfoList[___curRecipePage - 6].GetRecipePageEntries()[i].ItemIdBase;
- if (__instance.RecipeCraftedAlready(itemID, 0))
- ___recipeLock[i].SetActive(false);
- else
- ___recipeLock[i].SetActive(true);
- }
- else
- {
- ___recipeLock[i].SetActive(false);
- ___recipeButtons.transform.GetChild(i).gameObject.SetActive(false);
- }
- }
- return false;
- }
- else if (___craftType == 1 && ___curRecipePage >= 2)
- {
- ___ultLocksObj.SetActive(false);
- ___recipeButtons.SetActive(true);
- for (int i = 0; i < 12; i++)
- {
- if (Core.pageAlchemyStationInfoList[___curRecipePage - 2].GetRecipePageEntries().Length > i)
- {
- int itemID = Core.pageAlchemyStationInfoList[___curRecipePage - 2].GetRecipePageEntries()[i].ItemIdBase;
- if (__instance.RecipeCraftedAlready(itemID, 0))
- ___recipeLock[i].SetActive(false);
- else
- ___recipeLock[i].SetActive(true);
- }
- else
- {
- ___recipeLock[i].SetActive(false);
- ___recipeButtons.transform.GetChild(i).gameObject.SetActive(false);
- }
- }
- return false;
- }
- else if (___craftType == 2 && ___curRecipePage >= 6)
- {
- ___ultLocksObj.SetActive(true);
- ___recipeButtons.SetActive(false);
- for (int i = 0; i < 36; i++)
- {
- if (i < 12)
- {
- ___recipeLock[i].SetActive(false);
- }
- if (Core.pageUltimateForgeInfoList[___curRecipePage - 6].GetRecipePageEntries().Length > i / 3)
- {
- int itemID = Core.pageUltimateForgeInfoList[___curRecipePage - 6].GetRecipePageEntries()[i / 3].ItemIdExtension[i % 3];
- if (__instance.RecipeCraftedAlready(itemID, 0))
- ___ultLocks[i].SetActive(false);
- else
- ___ultLocks[i].SetActive(true);
- }
- else
- ___ultLocks[i].SetActive(false);
- }
- return false;
- }
- return true;
- }
- }
- }
|