Patch_GameScript_RecipeDown.cs 760 B

12345678910111213141516171819202122232425262728293031323334
  1. using HarmonyLib;
  2. using GadgetCore.API;
  3. using UnityEngine;
  4. using System.Collections;
  5. namespace VendingMachine.Patches
  6. {
  7. [HarmonyPatch(typeof(GameScript))]
  8. [HarmonyPatch("RecipeDown")]
  9. [HarmonyGadget("VendingMachine")]
  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. switch (___craftType)
  17. {
  18. case 0:
  19. pages = 6;
  20. break;
  21. case 1:
  22. pages = 2;
  23. break;
  24. case 2:
  25. pages = 7;
  26. break;
  27. }
  28. ___curRecipePage = (___curRecipePage + pages - 1) % pages;
  29. __instance.RefreshRecipe();
  30. return false;
  31. }
  32. }
  33. }