Patch_GameScript_RecipeDown.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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("RecipeDown")]
  9. [HarmonyGadget("RecipeMenuCore")]
  10. public static class Patch_GameScript_RecipeDown
  11. {
  12. [HarmonyPrefix]
  13. public static bool Prefix(GameScript __instance, int ___craftType, ref int ___curRecipePage)
  14. {
  15. int pages = 1;
  16. if (___craftType == 0)
  17. pages = 6 + Core.pageGearForgeInfoList.Count;
  18. else if (___craftType == 1)
  19. pages = 2 + Core.pageAlchemyStationInfoList.Count;
  20. else if (___craftType == 2)
  21. pages = 6 + Core.pageUltimateForgeInfoList.Count;
  22. else if (___craftType == MenuRegistry.Singleton["Gadget Core:Crafter Menu"].GetID())
  23. pages = Core.pageUniversalCrafterInfoList.Count;
  24. else if (CraftTypeHelper.IsCraftTypeRegisteredAsCustom(___craftType))
  25. {
  26. string s = CraftTypeHelper.GetNameFromCraftTypeRegisteredAsCustom(___craftType);
  27. pages = Core.pageCustomCrafterInfoLists[s].Count;
  28. }
  29. ___curRecipePage = (___curRecipePage + pages - 1) % pages;
  30. __instance.RefreshRecipe();
  31. return false;
  32. }
  33. }
  34. }