using GadgetCore; using GadgetCore.API; using HarmonyLib; using System; using System.Reflection; namespace IronmanChest { internal static class Core { public static GadgetLogger logger; public static int settingAmountPages { get { var fieldInfo = GetFieldInfo("settingAmountPages"); if (fieldInfo != null) return (int)fieldInfo.GetValue(null); return 12; } } public static int settingAmountSlots { get { var fieldInfo = GetFieldInfo("settingAmountSlots"); if (fieldInfo != null) return (int)fieldInfo.GetValue(null); return 5 * 6; } } private static FieldInfo GetFieldInfo(string f) { bool active = false; foreach (var gadget in Gadgets.ListAllEnabledGadgets()) if (gadget.Info?.ModName == "Storage Expansion") { active = true; break; } if (!active) return null; foreach (var a in AppDomain.CurrentDomain.GetAssemblies()) { if (a.FullName.StartsWith("StorageExpansion,")) { return AccessTools.Field(a.GetType("StorageExpansion.Core"), f); } } return null; } public static bool IsSoftcore() { foreach (var gadget in Gadgets.ListAllEnabledGadgets()) if (gadget.Info?.ModName == "Softcore") return true; return false; } } }