Patch_CraftMenuInfo_AllowQuickCrafting.cs 916 B

12345678910111213141516171819202122232425262728293031323334
  1. using HarmonyLib;
  2. using GadgetCore.API;
  3. using UnityEngine;
  4. using System.Collections;
  5. using System.Reflection;
  6. using System.Collections.Generic;
  7. namespace RecipeMenuCore.Patches
  8. {
  9. [HarmonyPatch(typeof(CraftMenuInfo))]
  10. [HarmonyPatch("AllowQuickCrafting")]
  11. [HarmonyGadget("RecipeMenuCore")]
  12. public static class Patch_CraftMenuInfo_AllowQuickCrafting
  13. {
  14. [HarmonyPrefix]
  15. public static bool Prefix(CraftMenuInfo __instance, ref bool __result)
  16. {
  17. if(__instance.GetRegistryName() == "Gadget Core:Crafter Menu")
  18. {
  19. __result = Core.pageUniversalCrafterInfoList.Count > 0;
  20. return false;
  21. }
  22. foreach(var crafter in Core.pageCustomCrafterInfoLists.Keys)
  23. {
  24. if (__instance.GetRegistryName() == crafter)
  25. {
  26. __result = Core.pageCustomCrafterInfoLists[crafter].Count > 0;
  27. return false;
  28. }
  29. }
  30. return true;
  31. }
  32. }
  33. }