Patch_GameScript_RefreshRecipe.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using HarmonyLib;
  2. using GadgetCore.API;
  3. using UnityEngine;
  4. using System.Collections;
  5. namespace RecipeMenuCore.Patches
  6. {
  7. [HarmonyPatch(typeof(GameScript))]
  8. [HarmonyPatch("RefreshRecipe")]
  9. [HarmonyGadget("RecipeMenuCore")]
  10. public static class Patch_GameScript_RefreshRecipe
  11. {
  12. [HarmonyPrefix]
  13. public static bool Prefix(GameScript __instance, int ___craftType, int ___curRecipePage)
  14. {
  15. if (___craftType == 0)
  16. {
  17. __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName0(___curRecipePage);
  18. __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (6 + Core.pageGearForgeInfoList.Count);
  19. }
  20. else if (___craftType == 1)
  21. {
  22. __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName1(___curRecipePage);
  23. __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (2 + Core.pageAlchemyStationInfoList.Count);
  24. }
  25. else if (___craftType == 2)
  26. {
  27. __instance.txtRecipeName[0].text = string.Empty + __instance.GetRecipeName2(___curRecipePage);
  28. __instance.txtRecipeUnlocked[0].text = "Page " + (___curRecipePage + 1) + "/" + (6 + Core.pageUltimateForgeInfoList.Count);
  29. }
  30. __instance.txtRecipeUnlocked[0].gameObject.GetComponent<Animation>().Play();
  31. __instance.txtRecipeName[0].gameObject.GetComponent<Animation>().Play();
  32. __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
  33. __instance.txtRecipeUnlocked[1].text = __instance.txtRecipeUnlocked[0].text;
  34. if ((___craftType != 0 || ___curRecipePage <= 5)
  35. && (___craftType != 1 || ___curRecipePage <= 1)
  36. && (___craftType != 2 || ___curRecipePage <= 5))
  37. {
  38. __instance.menuRecipe.GetComponent<Renderer>().material = (Material)Resources.Load(string.Concat(new object[] { "mat/r", ___curRecipePage, "t", ___craftType }));
  39. }
  40. else
  41. {
  42. if (___craftType == 0)
  43. {
  44. __instance.txtRecipeName[0].text = Core.pageGearForgeInfoList[___curRecipePage - 6].Title;
  45. __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
  46. __instance.menuRecipe.GetComponent<Renderer>().material = Core.pageGearForgeInfoList[___curRecipePage - 6].Mat;
  47. }
  48. else if (___craftType == 1)
  49. {
  50. __instance.txtRecipeName[0].text = Core.pageAlchemyStationInfoList[___curRecipePage - 2].Title;
  51. __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
  52. __instance.menuRecipe.GetComponent<Renderer>().material = Core.pageAlchemyStationInfoList[___curRecipePage - 2].Mat;
  53. }
  54. else if (___craftType == 2)
  55. {
  56. __instance.txtRecipeName[0].text = Core.pageUltimateForgeInfoList[___curRecipePage - 6].Title;
  57. __instance.txtRecipeName[1].text = __instance.txtRecipeName[0].text;
  58. __instance.menuRecipe.GetComponent<Renderer>().material = Core.pageUltimateForgeInfoList[___curRecipePage - 6].Mat;
  59. }
  60. }
  61. __instance.RefreshRecipeUnlock();
  62. return false;
  63. }
  64. }
  65. }