| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using HarmonyLib;
- using GadgetCore.API;
- using UnityEngine;
- using System.Collections;
- namespace RecipeMenuCore.Patches
- {
- [HarmonyPatch(typeof(GameScript))]
- [HarmonyPatch("RefreshRecipe")]
- [HarmonyGadget("RecipeMenuCore")]
- public static class Patch_GameScript_RefreshRecipe
- {
- [HarmonyPrefix]
- public static bool Prefix(GameScript __instance, int ___craftType, int ___curRecipePage)
- {
- if (___craftType == 0)
- {
- __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName0(___curRecipePage);
- __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (6 + Core.pageGearForgeInfoList.Count);
- }
- else if (___craftType == 1)
- {
- __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName1(___curRecipePage);
- __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (2 + Core.pageAlchemyStationInfoList.Count);
- }
- else if (___craftType == 2)
- {
- __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName2(___curRecipePage);
- __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (6 + Core.pageUltimateForgeInfoList.Count);
- }
- else if (___craftType == MenuRegistry.Singleton["Gadget Core:Crafter Menu"].GetID())
- {
- __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName2(___curRecipePage);
- __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (Core.pageUniversalCrafterInfoList.Count);
- }
- else if (CraftTypeHelper.IsCraftTypeRegisteredAsCustom(___craftType))
- {
- string s = CraftTypeHelper.GetNameFromCraftTypeRegisteredAsCustom(___craftType);
- __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName2(___curRecipePage);
- __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (Core.pageCustomCrafterInfoLists[s].Count);
- }
- __instance.txtRecipeUnlocked[0].gameObject.GetComponent<Animation>().Play();
- __instance.txtRecipeName[0].gameObject.GetComponent<Animation>().Play();
- __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
- __instance.txtRecipeUnlocked[1].text = __instance.txtRecipeUnlocked[0].text;
- if ((___craftType != 0 || (___curRecipePage <= 5 && Core.pageGearForgeInfoListVanilla[___curRecipePage] == null))
- && (___craftType != 1 || (___curRecipePage <= 1 && Core.pageAlchemyStationInfoListVanilla[___curRecipePage] == null))
- && (___craftType != 2 || (___curRecipePage <= 5 && Core.pageUltimateForgeInfoListVanilla[___curRecipePage] == null))
- && (___craftType != MenuRegistry.Singleton["Gadget Core:Crafter Menu"].GetID())
- && (!CraftTypeHelper.IsCraftTypeRegisteredAsCustom(___craftType)))
- {
- __instance.menuRecipe.GetComponent<Renderer>().material = (Material)Resources.Load(string.Concat(new object[] { "mat/r", ___curRecipePage, "t", ___craftType }));
- }
- else
- {
- if (___craftType == 0)
- {
- var page = ___curRecipePage >= 6 ? Core.pageGearForgeInfoList[___curRecipePage - 6] : Core.pageGearForgeInfoListVanilla[___curRecipePage];
- __instance.txtRecipeName[0].text = page.Title;
- __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
- __instance.menuRecipe.GetComponent<Renderer>().material = page.Mat;
- }
- else if (___craftType == 1)
- {
- var page = ___curRecipePage >= 2 ? Core.pageAlchemyStationInfoList[___curRecipePage - 2] : Core.pageAlchemyStationInfoListVanilla[___curRecipePage];
- __instance.txtRecipeName[0].text = page.Title;
- __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
- __instance.menuRecipe.GetComponent<Renderer>().material = page.Mat;
- }
- else if (___craftType == 2)
- {
- var page = ___curRecipePage >= 6 ? Core.pageUltimateForgeInfoList[___curRecipePage - 6] : Core.pageUltimateForgeInfoListVanilla[___curRecipePage];
- __instance.txtRecipeName[0].text = page.Title;
- __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
- __instance.menuRecipe.GetComponent<Renderer>().material = page.Mat;
- }
- else if (___craftType == MenuRegistry.Singleton["Gadget Core:Crafter Menu"].GetID())
- {
- var page = Core.pageUniversalCrafterInfoList[___curRecipePage];
- __instance.txtRecipeName[0].text = page.Title;
- __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
- __instance.menuRecipe.GetComponent<Renderer>().material = page.Mat;
- }
- else if (CraftTypeHelper.IsCraftTypeRegisteredAsCustom(___craftType))
- {
- string s = CraftTypeHelper.GetNameFromCraftTypeRegisteredAsCustom(___craftType);
- var page = Core.pageCustomCrafterInfoLists[s][___curRecipePage];
- __instance.txtRecipeName[0].text = page.Title;
- __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
- __instance.menuRecipe.GetComponent<Renderer>().material = page.Mat;
- }
- }
- __instance.RefreshRecipeUnlock();
- return false;
- }
- [HarmonyPostfix]
- [HarmonyAfter("URP.URP.gadget")]
- public static void Postfix(GameScript __instance, int ___curRecipePage, int ___craftType)
- {
- if (___curRecipePage == 1 && ___craftType == 1 && Core.pageAlchemyStationInfoListVanilla[1] != null)
- {
- var page = Core.pageAlchemyStationInfoListVanilla[1];
- __instance.menuRecipe.GetComponent<Renderer>().material = page.Mat;
- }
- }
- }
- }
|