Patch_PlanetRegistry_get_PlanetSelectorPages.cs 673 B

123456789101112131415161718192021222324252627
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using System.Linq;
  4. using System.Reflection;
  5. namespace Subworlds.Patches
  6. {
  7. [HarmonyPatch]
  8. [HarmonyGadget("SubworldCore_")]
  9. public static class Patch_PlanetRegistry_get_PlanetSelectorPages
  10. {
  11. [HarmonyTargetMethod]
  12. static MethodBase TargetMethod()
  13. {
  14. return AccessTools.Method(typeof(GadgetCoreAPI).Assembly.GetType("GadgetCore.API.PlanetRegistry"), "get_PlanetSelectorPages");
  15. }
  16. [HarmonyPrefix]
  17. public static bool Prefix(ref int __result)
  18. {
  19. __result = ((PlanetRegistry.Singleton.AsEnumerable().Count(x => x.SelectorButtonMat != null) + 13) / 14) + 1;
  20. return false;
  21. }
  22. }
  23. }