using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("Farm")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Farm")] [assembly: AssemblyTitle("Farm")] [assembly: AssemblyVersion("1.0.0.0")] namespace SukeExpandMod; [BepInPlugin("com.suke.MoreExpand.mod", "MoreExpand Mod", "1.0.0")] public class WorldSizeScaleMod : BaseUnityPlugin { public const string PluginGuid = "com.suke.MoreExpand.mod"; public const string PluginName = "MoreExpand Mod"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; try { new Harmony("com.suke.MoreExpand.mod").PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"MoreExpand Mod loaded"); } catch (Exception arg) { Log.LogError((object)$"Failed to patch: {arg}"); } } internal static void TweakUnlock(UnlockSO u) { if ((Object)(object)u == (Object)null) { return; } try { if (string.Equals(u.unlockName, "expand", StringComparison.OrdinalIgnoreCase) || string.Equals(((Object)u).name, "expand", StringComparison.OrdinalIgnoreCase)) { u.maxUnlockLevel = 10000; ManualLogSource log = Log; if (log != null) { log.LogInfo((object)$"Patched UnlockSO ({((Object)u).name}/{u.unlockName}) -> maxUnlockLevel={u.maxUnlockLevel}"); } } } catch (Exception arg) { ManualLogSource log2 = Log; if (log2 != null) { log2.LogError((object)$"TweakUnlock error: {arg}"); } } } } [HarmonyPatch(typeof(Helper), "WorldSizeScale")] public static class Patch_Helper_WorldSizeScale { public static bool Prefix(int numExpandUpgrades, ref int __result) { if (numExpandUpgrades >= 10) { switch (numExpandUpgrades) { case 10: __result = 64; return false; case 11: __result = 96; return false; case 12: __result = 128; return false; case 13: __result = 192; return false; case 14: __result = 256; return false; case 15: __result = 384; return false; case 16: __result = 512; return false; default: { int num = numExpandUpgrades - 16; __result = 512 * (int)Math.Pow(2.0, num); return false; } } } return true; } } [HarmonyPatch(typeof(Resources), "Load", new Type[] { typeof(string), typeof(Type) })] public static class Patch_Resources_Load { private static void Postfix(object __result, string path, Type systemTypeInstance) { UnlockSO val = (UnlockSO)((__result is UnlockSO) ? __result : null); if (val != null) { ManualLogSource log = WorldSizeScaleMod.Log; if (log != null) { log.LogDebug((object)("Resources.Load -> " + path + " (" + ((Object)val).name + ")")); } WorldSizeScaleMod.TweakUnlock(val); } } } [HarmonyPatch(typeof(Resources), "LoadAll", new Type[] { typeof(string), typeof(Type) })] public static class Patch_Resources_LoadAll { private static void Postfix(Object[] __result, string path, Type systemTypeInstance) { if (__result == null) { return; } foreach (Object obj in __result) { UnlockSO val = (UnlockSO)(object)((obj is UnlockSO) ? obj : null); if (val != null) { ManualLogSource log = WorldSizeScaleMod.Log; if (log != null) { log.LogDebug((object)("Resources.LoadAll -> " + path + " (" + ((Object)val).name + ")")); } WorldSizeScaleMod.TweakUnlock(val); } } } } [HarmonyPatch(typeof(Object), "Instantiate", new Type[] { typeof(Object) })] public static class Patch_Object_Instantiate { private static void Postfix(Object __result) { UnlockSO val = (UnlockSO)(object)((__result is UnlockSO) ? __result : null); if (val != null) { WorldSizeScaleMod.TweakUnlock(val); } } }