Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Expand World Size v1.30.0
ExpandWorldSize.dll
Decompiled 2 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using Service; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ExpandWorldSize")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+de39355bb436bbe01b3f1db69ec0b53bc3fb488c")] [assembly: AssemblyProduct("ExpandWorldSize")] [assembly: AssemblyTitle("ExpandWorldSize")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Service { public class ConfigWrapper { private readonly ConfigFile ConfigFile; private readonly ConfigSync ConfigSync; public readonly Action Regenerate; public static Dictionary<ConfigEntry<string>, float> Floats = new Dictionary<ConfigEntry<string>, float>(); public static Dictionary<ConfigEntry<string>, float?> NullFloats = new Dictionary<ConfigEntry<string>, float?>(); public static Dictionary<ConfigEntry<string>, int> Ints = new Dictionary<ConfigEntry<string>, int>(); public ConfigWrapper(ConfigFile configFile, ConfigSync configSync, Action regenerate) { ConfigFile = configFile; ConfigSync = configSync; Regenerate = regenerate; } public ConfigEntry<string> BindFloat(string group, string name, float value, bool regenerate, string description = "", bool synchronizedSetting = true) { ConfigEntry<string> entry = Bind(group, name, value.ToString(CultureInfo.InvariantCulture), regenerate, description, synchronizedSetting); entry.SettingChanged += delegate { Floats[entry] = TryParseFloat(entry).GetValueOrDefault(value); }; Floats[entry] = TryParseFloat(entry).GetValueOrDefault(value); return entry; } public ConfigEntry<string> BindFloat(string group, string name, float? value, bool regenerate, string description = "", bool synchronizedSetting = true) { ConfigEntry<string> entry = Bind(group, name, value.HasValue ? value.Value.ToString(CultureInfo.InvariantCulture) : "", regenerate, description, synchronizedSetting); entry.SettingChanged += delegate { NullFloats[entry] = TryParseFloat(entry); }; NullFloats[entry] = TryParseFloat(entry); return entry; } public ConfigEntry<T> Bind<T>(string group, string name, T value, bool regenerate, ConfigDescription description, bool synchronizedSetting = true) { ConfigEntry<T> val = ConfigFile.Bind<T>(group, name, value, description); if (regenerate) { val.SettingChanged += Regen; } ConfigSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting; return val; } public ConfigEntry<T> Bind<T>(string group, string name, T value, bool regenerate, string description = "", bool synchronizedSetting = true) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown return Bind(group, name, value, regenerate, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting); } private void Regen(object e, EventArgs s) { Regenerate(); } private static float? TryParseFloat(string value) { if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return null; } private static float? TryParseFloat(ConfigEntry<string> setting) { if (float.TryParse(setting.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return TryParseFloat((string)((ConfigEntryBase)setting).DefaultValue); } } public class Log { private static ManualLogSource Logger; public static void Init(ManualLogSource logger) { Logger = logger; } public static void Error(string message) { Logger.LogError((object)message); } public static void Warning(string message) { Logger.LogWarning((object)message); } public static void Info(string message) { Logger.LogInfo((object)message); } public static void Debug(string message) { Logger.LogDebug((object)message); } } } namespace ExpandWorldSize { public class BetterContinents { public const string GUID = "BetterContinents"; private static Assembly? Assembly; private static FieldInfo? SettingsField; private static FieldInfo? IsEnabledField; private static MethodInfo? SetSizeMethod; private static FieldInfo? WorldSizeField; private static FieldInfo? EdgeSizeField; public static void Run() { if (!Chainloader.PluginInfos.TryGetValue("BetterContinents", out var value)) { return; } Assembly = ((object)value.Instance).GetType().Assembly; Type type = Assembly.GetType("BetterContinents.BetterContinents"); if (type == null) { return; } SettingsField = AccessTools.Field(type, "Settings"); if (SettingsField == null) { return; } type = Assembly.GetType("BetterContinents.BetterContinents+BetterContinentsSettings"); IsEnabledField = AccessTools.Field(type, "EnabledForThisWorld"); if (IsEnabledField == null) { return; } type = Assembly.GetType("BetterContinents.BetterContinents"); if (type == null) { return; } SetSizeMethod = AccessTools.Method(type, "SetSize", (Type[])null, (Type[])null); if (SetSizeMethod != null) { Log.Info("\"Better Continents\" detected. Applying compatibility."); return; } WorldSizeField = AccessTools.Field(type, "WorldSize"); EdgeSizeField = AccessTools.Field(type, "EdgeSize"); if (EdgeSizeField != null && SetSizeMethod != null) { Log.Info("Older \"Better Continents\" detected. Applying compatibility."); } } public static bool IsEnabled() { if (SettingsField == null) { return false; } if (IsEnabledField == null) { return false; } object value = SettingsField.GetValue(null); if (value == null) { return false; } return (bool)IsEnabledField.GetValue(value); } public static void RefreshSize() { SetSizeMethod?.Invoke(null, new object[2] { Configuration.WorldRadius, Configuration.WorldEdgeSize }); WorldSizeField?.SetValue(null, Configuration.WorldTotalRadius); EdgeSizeField?.SetValue(null, Configuration.WorldEdgeSize); } } public class EWD { public const string GUID = "expand_world_data"; public static bool IsPresent; private static Assembly? Assembly; private static MethodInfo? SetSize; public static void Run() { if (!Chainloader.PluginInfos.TryGetValue("expand_world_data", out var value)) { return; } Assembly = ((object)value.Instance).GetType().Assembly; Type type = Assembly.GetType("ExpandWorldData.WorldInfo"); if (!(type == null)) { SetSize = AccessTools.Method(type, "Set", (Type[])null, (Type[])null); if (!(SetSize == null)) { Log.Info("\"Expand World Data\" detected. Applying compatibility."); IsPresent = true; } } } public static void RefreshSize() { if (!(SetSize == null)) { SetSize.Invoke(null, new object[4] { Configuration.WorldRadius, Configuration.WorldTotalRadius, Configuration.WorldStretch, Configuration.BiomeStretch }); } } } public class Marketplace { public const string GUID = "MarketplaceAndServerNPCs"; private static Assembly? MarketplaceAssembly; private static FieldInfo? IsLoadingField; public static void Run() { if (!Chainloader.PluginInfos.TryGetValue("MarketplaceAndServerNPCs", out var value)) { return; } MarketplaceAssembly = ((object)value.Instance).GetType().Assembly; Type type = MarketplaceAssembly.GetType("API.ClientSide"); if (!(type == null)) { IsLoadingField = AccessTools.Field(type, "FillingTerritoryData"); if (!(IsLoadingField == null)) { Log.Info("\"Marketplace\" detected. Applying compatibility."); } } } public static bool IsLoading() { if (IsLoadingField == null) { return false; } return (bool)IsLoadingField.GetValue(null); } } public class WorldInfo { public static float WaterLevel = 30f; public static float BaseWaterLevel = Helper.HeightToBaseHeight(WaterLevel); public static float WorldStretch = 1f; public static float BiomeStretch = 1f; public static float WaterDepth = 1f; public static float AltitudeMultiplier = 1f; public static float BaseAltitudeDelta = 0f; public static float ForestMultiplier = 1f; public static void SetWaterLevel(float waterLevel) { if (WaterLevel != waterLevel) { WaterLevel = waterLevel; BaseWaterLevel = Helper.HeightToBaseHeight(WaterLevel); } } public static void Generate() { if (!Patcher.IsMenu) { Log.Info("Regenerating the world."); Refresh(); MapGeneration.Cancel(); WorldGenerator.instance.Pregenerate(); Heightmap[] array = Object.FindObjectsByType<Heightmap>((FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (Heightmap obj in array) { obj.m_buildData = null; obj.Regenerate(); } ClutterSystem instance = ClutterSystem.instance; if (instance != null) { instance.ClearAll(); } SetupMaterial.Refresh(); if (Object.op_Implicit((Object)(object)EnvMan.instance)) { ScaleGlobalWaterSurface.Refresh(EnvMan.instance); } if (Configuration.RegenerateMap) { Map(); } } } public static void Map() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType != 4) { Minimap instance = Minimap.instance; if (instance != null) { instance.GenerateWorldMap(); } } } public static void Refresh() { WorldStretch = Configuration.WorldStretch; BiomeStretch = Configuration.BiomeStretch; WaterDepth = Configuration.WaterDepthMultiplier; AltitudeMultiplier = Configuration.AltitudeMultiplier; ForestMultiplier = ((Configuration.ForestMultiplier == 0f) ? 1f : Configuration.ForestMultiplier); BaseAltitudeDelta = Helper.HeightToBaseHeight(Configuration.AltitudeDelta); if (Patcher.WG != null) { Patcher.WG.maxMarshDistance = VersionSetup.MaxMarshDistance * Configuration.WorldRadius / 10000f / Configuration.WorldStretch; } EWD.RefreshSize(); BetterContinents.RefreshSize(); Patcher.Patch(); } } [HarmonyPatch(typeof(WorldGenerator), "VersionSetup")] public class VersionSetup { public static float MaxMarshDistance = 6000f; private static void Prefix(WorldGenerator __instance) { __instance.maxMarshDistance = 6000f; } private static void Postfix(WorldGenerator __instance) { MaxMarshDistance = __instance.maxMarshDistance; } } [HarmonyPatch(typeof(World), "LoadWorld")] public class LoadWorld { private static World Postfix(World result) { if (Configuration.Seed != "" && !result.m_menu) { result.m_seedName = Configuration.Seed; result.m_seed = StringExtensionMethods.GetStableHashCode(Configuration.Seed); } return result; } } public class Configuration { public static ConfigEntry<bool> configRegenerateMap; public static ConfigEntry<string> configWorldRadius; public static ConfigEntry<string> configWorldEdgeSize; public static ConfigEntry<string> configMapSize; public static ConfigEntry<string> configMapPixelSize; public static ConfigEntry<string> configAltitudeMultiplier; public static ConfigEntry<string> configAltitudeDelta; public static ConfigEntry<string> configLocationsMultiplier; public static ConfigEntry<string> configForestMultiplier; public static ConfigEntry<string> configWorldStretch; public static ConfigEntry<string> configBiomeStretch; public static ConfigEntry<string> configSeed; public static ConfigEntry<string> configOffsetX; public static ConfigEntry<string> configOffsetY; public static ConfigEntry<string> configHeightSeed; public static ConfigEntry<string> configWaterDepthMultiplier; public static ConfigEntry<string> configAshlandsWidthRestriction; public static ConfigEntry<string> configAshlandsLengthRestriction; public static ConfigEntry<bool> configRestrictAshlands; public static ConfigEntry<bool> configAshlandsGap; public static ConfigEntry<bool> configDeepNorthGap; public static ConfigEntry<bool> configFixWaterColor; public static ConfigEntry<bool> configRemoveAshlandsWater; public static bool RegenerateMap => configRegenerateMap.Value; public static float WorldRadius => ConfigWrapper.Floats[configWorldRadius]; public static float StrechedWorldRadius => WorldRadius / WorldStretch; public static float WorldEdgeSize => ConfigWrapper.Floats[configWorldEdgeSize]; public static float WorldTotalRadius => WorldRadius + WorldEdgeSize; public static float StrechedWorldTotalRadius => WorldTotalRadius / WorldStretch; public static float MapSize => ConfigWrapper.Floats[configMapSize]; public static float MapPixelSize => ConfigWrapper.Floats[configMapPixelSize]; public static float AltitudeMultiplier => ConfigWrapper.Floats[configAltitudeMultiplier]; public static float AltitudeDelta => ConfigWrapper.Floats[configAltitudeDelta]; public static float LocationsMultiplier => ConfigWrapper.Floats[configLocationsMultiplier]; public static float ForestMultiplier => ConfigWrapper.Floats[configForestMultiplier]; public static float WorldStretch => ConfigWrapper.Floats[configWorldStretch]; public static float BiomeStretch => ConfigWrapper.Floats[configBiomeStretch]; public static string Seed => configSeed.Value; public static float? OffsetX => ConfigWrapper.NullFloats[configOffsetX]; public static float? OffsetY => ConfigWrapper.NullFloats[configOffsetY]; public static float? HeightSeed => ConfigWrapper.NullFloats[configHeightSeed]; public static float WaterDepthMultiplier => ConfigWrapper.Floats[configWaterDepthMultiplier]; public static double AshlandsWidthRestriction { get { if (!RestrictAshlands) { return double.PositiveInfinity; } return ConfigWrapper.Floats[configAshlandsWidthRestriction]; } } public static double AshlandsLengthRestriction { get { if (!RestrictAshlands) { return double.PositiveInfinity; } return ConfigWrapper.Floats[configAshlandsLengthRestriction]; } } public static bool RestrictAshlands => configRestrictAshlands.Value; public static bool AshlandsGap => configAshlandsGap.Value; public static bool DeepNorthGap => configDeepNorthGap.Value; public static bool FixWaterColor => configFixWaterColor.Value; public static bool RemoveAshlandsWater => configRemoveAshlandsWater.Value; public static void Init(ConfigWrapper wrapper) { ConfigWrapper wrapper2 = wrapper; string group = "1. General"; configRegenerateMap = wrapper2.Bind(group, "Regenerate map", value: true, regenerate: false, "If true, the world map is regenerated automatically on data changes."); configWorldRadius = wrapper2.BindFloat(group, "World radius", 10000f, regenerate: true, "Radius of the world in meters (excluding the edge)."); configWorldEdgeSize = wrapper2.BindFloat(group, "World edge size", 500f, regenerate: true, "Size of the edge area in meters (added to the radius for the total size)."); configMapSize = wrapper2.BindFloat(group, "Minimap size", 1f, regenerate: false, "Increases the minimap size, but also significantly increases the generation time."); configMapSize.SettingChanged += delegate { if (Object.op_Implicit((Object)(object)Minimap.instance) && MinimapAwake.Refresh(Minimap.instance)) { wrapper2.Regenerate(); } }; configMapPixelSize = wrapper2.BindFloat(group, "Minimap pixel size", 0f, regenerate: false, "Decreases the minimap detail, but doesn't affect the generation time. Automatically calculated when zero."); configMapPixelSize.SettingChanged += delegate { if (Object.op_Implicit((Object)(object)Minimap.instance) && MinimapAwake.Refresh(Minimap.instance)) { wrapper2.Regenerate(); } }; configWorldStretch = wrapper2.BindFloat(group, "Stretch world", 1f, regenerate: true, "Stretches the world to a bigger area."); configBiomeStretch = wrapper2.BindFloat(group, "Stretch biomes", 1f, regenerate: true, "Stretches the biomes to a bigger area."); configForestMultiplier = wrapper2.BindFloat(group, "Forest multiplier", 1f, regenerate: true, "Multiplies the amount of forest."); configAltitudeMultiplier = wrapper2.BindFloat(group, "Altitude multiplier", 1f, regenerate: true, "Multiplies the altitude."); configAltitudeDelta = wrapper2.BindFloat(group, "Altitude delta", 0f, regenerate: true, "Adds to the altitude."); configWaterDepthMultiplier = wrapper2.BindFloat(group, "Water depth multiplier", 1f, regenerate: true, "Multplies the water depth."); configLocationsMultiplier = wrapper2.BindFloat(group, "Locations", 1f, regenerate: true, "Multiplies the max amount of locations."); configOffsetX = wrapper2.BindFloat(group, "Offset X", null, regenerate: true); configOffsetY = wrapper2.BindFloat(group, "Offset Y", null, regenerate: true); configSeed = wrapper2.Bind(group, "Seed", "", regenerate: false); configSeed.SettingChanged += delegate { if (!(Seed == "") && WorldGenerator.instance != null) { World world = WorldGenerator.instance.m_world; if (!world.m_menu) { world.m_seedName = Seed; world.m_seed = StringExtensionMethods.GetStableHashCode(Seed); world.m_menu = true; WorldGenerator.Initialize(world); world.m_menu = false; WorldInfo.Generate(); } } }; configHeightSeed = wrapper2.BindFloat(group, "Height variation seed", null, regenerate: true); group = "2. Poles"; configRestrictAshlands = wrapper2.Bind(group, "Restrict Ashlands position", value: true, regenerate: true, "If true, restricts Ashlands biome position."); configAshlandsWidthRestriction = wrapper2.BindFloat(group, "Ashlands width restriction", 7500f, regenerate: true, "How wide is the Ashlands biome (meters)."); configAshlandsLengthRestriction = wrapper2.BindFloat(group, "Ashlands length restriction", 1000f, regenerate: true, "How long/deep is the Ashlands biome (meters)."); configAshlandsGap = wrapper2.Bind(group, "Ashlands gap", value: true, regenerate: true, "If true, Ashlands biome has an Ocean gap above it."); configDeepNorthGap = wrapper2.Bind(group, "Deep North gap", value: true, regenerate: true, "If true, Deep North biome has an Ocean gap below it."); configRemoveAshlandsWater = wrapper2.Bind(group, "Remove Ashlands water", value: false, regenerate: false, "If true, the red water color is completely removed."); configRemoveAshlandsWater.SettingChanged += delegate { WaterColor.Regenerate(); }; configFixWaterColor = wrapper2.Bind(group, "Fix water color", value: true, regenerate: false, "If true, fixes the water color to match the current biome."); configFixWaterColor.SettingChanged += delegate { WaterColor.Regenerate(); }; WaterColor.Regenerate(); } } [HarmonyPatch] public static class Patcher { public static WorldGenerator? WG; private static Harmony Harmony; private static Harmony DynamicHarmony; private static float PatchedWorldStretch = 1f; private static float PatchedWaterDepthMultiplier = 1f; private static float PatchedWaterLevel = 30f; private static float PatchedForestMultiplier = 1f; private static float PatchedAltitudeDelta = 0f; private static float PatchedAltitudeMultiplier = 1f; public static bool IsMenu { get { if (WG != null) { return WG.m_world.m_menu; } return true; } } public static void Init(Harmony harmony, Harmony dynamicHarmony) { Harmony = harmony; DynamicHarmony = dynamicHarmony; Patch(); } public static void Patch() { Harmony.UnpatchSelf(); Harmony.PatchAll(); CheckWorldStretch(DynamicHarmony); CheckWaterDepth(DynamicHarmony); CheckForest(DynamicHarmony); CheckAltitude(DynamicHarmony); CreateAshlandsGap.Patch(DynamicHarmony, !Configuration.AshlandsGap); CreateDeepNorthGap.Patch(DynamicHarmony, !Configuration.DeepNorthGap); GetAshlandsHeight.Patch(DynamicHarmony, Configuration.AshlandsWidthRestriction, Configuration.AshlandsLengthRestriction); } [HarmonyPatch(typeof(WorldGenerator), "VersionSetup")] [HarmonyPostfix] [HarmonyPriority(0)] private static void PatchOnLoad(WorldGenerator __instance) { WG = __instance; WorldInfo.Refresh(); } private static void CheckWorldStretch(Harmony harmony) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown float num = (IsMenu ? 1f : WorldInfo.WorldStretch); if (PatchedWorldStretch != num) { PatchedWorldStretch = num; MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetBiomeHeight", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Stretch), "GetBiomeHeight", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetAshlandsOceanGradient", new Type[1] { typeof(Vector3) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(Stretch), "StretchVector3", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } methodInfo = AccessTools.Method(typeof(Minimap), "GetMaskColor", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(Stretch), "GetMaskColor", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetBiome", new Type[4] { typeof(float), typeof(float), typeof(float), typeof(bool) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(Stretch), "GetBiome", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } methodInfo = AccessTools.Method(typeof(WorldGenerator), "AddRivers", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(AddRivers), "Prefix", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } PatchAshlandsDeepNorthChecks(harmony, num); } } private static void PatchAshlandsDeepNorthChecks(Harmony harmony, float worldStretch) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(Character), "UpdateLava", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Stretch), "StretchIsAshlandsTranspiler", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (worldStretch != 1f) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } methodInfo = AccessTools.Method(typeof(EnvMan), "GetBiome", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(Stretch), "StretchIsAshlandsDeepNorthTranspiler", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (worldStretch != 1f) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } methodInfo = AccessTools.Method(typeof(EnvMan), "UpdateEnvironment", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(Stretch), "StretchIsAshlandsDeepNorthTranspiler", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (worldStretch != 1f) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } } private static void CheckWaterDepth(Harmony harmony) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown float num = (IsMenu ? 1f : WorldInfo.WaterDepth); if (PatchedWaterDepthMultiplier != num || WorldInfo.WaterLevel != PatchedWaterLevel) { PatchedWaterDepthMultiplier = num; PatchedWaterLevel = WorldInfo.WaterLevel; MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetBiomeHeight", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(BiomeHeight), "Postfix", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void CheckForest(Harmony harmony) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown float num = (IsMenu ? 1f : WorldInfo.ForestMultiplier); if (PatchedForestMultiplier != num) { PatchedForestMultiplier = num; MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetForestFactor", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(Forest), "Postfix", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 1f) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void CheckAltitude(Harmony harmony) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown float num = (IsMenu ? 0f : WorldInfo.BaseAltitudeDelta); float num2 = (IsMenu ? 1f : WorldInfo.AltitudeMultiplier); if (PatchedAltitudeDelta != num || PatchedAltitudeMultiplier != num2) { PatchedAltitudeDelta = num; PatchedAltitudeMultiplier = num2; MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetBaseHeight", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(BaseHeight), "Postfix", (Type[])null, (Type[])null); harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (num != 0f || num2 != 1f) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] public class DebugCommands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleEvent <>9__0_1; internal void <Postfix>b__0_0(ConsoleEventArgs args) { WorldInfo.Map(); } internal void <Postfix>b__0_1(ConsoleEventArgs args) { WorldGenerator instance = WorldGenerator.m_instance; if (instance != null) { List<string> values = new List<string> { "Main: " + instance.m_world.m_seedName, "Generator: " + instance.m_world.m_worldGenVersion, "World: " + instance.m_world.m_seed, "Offset X: " + instance.m_offset0, "Offset Y: " + instance.m_offset1, "Height: " + instance.m_offset3, "Meadows: " + instance.m_offset3, "Black forest: " + instance.m_offset2, "Swamp: " + instance.m_offset0, "Plains: " + instance.m_offset1, "Mistlands: " + instance.m_offset4 }; ZLog.Log((object)string.Join("\n", values)); args.Context.AddString(string.Join("\n", values)); } } } private static void Postfix() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate { WorldInfo.Map(); }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("ew_map", "Refreshes the world map.", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { WorldGenerator instance = WorldGenerator.m_instance; if (instance != null) { List<string> values = new List<string> { "Main: " + instance.m_world.m_seedName, "Generator: " + instance.m_world.m_worldGenVersion, "World: " + instance.m_world.m_seed, "Offset X: " + instance.m_offset0, "Offset Y: " + instance.m_offset1, "Height: " + instance.m_offset3, "Meadows: " + instance.m_offset3, "Black forest: " + instance.m_offset2, "Swamp: " + instance.m_offset0, "Plains: " + instance.m_offset1, "Mistlands: " + instance.m_offset4 }; ZLog.Log((object)string.Join("\n", values)); args.Context.AddString(string.Join("\n", values)); } }; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("ew_seeds", "- Prints different seeds.", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } [BepInPlugin("expand_world_size", "Expand World Size", "1.30")] [BepInIncompatibility("expand_world")] public class EWS : BaseUnityPlugin { public const string GUID = "expand_world_size"; public const string NAME = "Expand World Size"; public const string VERSION = "1.30"; public static EWS Instance; public static ConfigSync ConfigSync = new ConfigSync("expand_world_size") { DisplayName = "Expand World Size", CurrentVersion = "1.30", ModRequired = true, IsLocked = true }; public static string ConfigName = "expand_world_size.cfg"; public static bool NeedsMigration = File.Exists(Path.Combine(Paths.ConfigPath, "expand_world.cfg")) && !File.Exists(Path.Combine(Paths.ConfigPath, ConfigName)); public void Awake() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_004d: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); Instance = this; Configuration.Init(new ConfigWrapper(((BaseUnityPlugin)this).Config, ConfigSync, InvokeRegenerate)); Harmony val = new Harmony("expand_world_size"); Harmony dynamicHarmony = new Harmony("expand_world_size.dynamic"); Patcher.Init(val, dynamicHarmony); try { SetupWatcher(); } catch (Exception ex) { Log.Error(ex.Message); } } public void Start() { Marketplace.Run(); BetterContinents.Run(); EWD.Run(); } public void InvokeRegenerate() { if (!Patcher.IsMenu) { ((MonoBehaviour)this).CancelInvoke("Regenerate"); ((MonoBehaviour)this).Invoke("Regenerate", 1f); } } public void LateUpdate() { if (!Patcher.IsMenu) { WaterColor.Transition(Time.deltaTime); } } public void Regenerate() { WorldInfo.Generate(); } private void OnDestroy() { ((BaseUnityPlugin)this).Config.Save(); } private void SetupWatcher() { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigName); fileSystemWatcher.Changed += ReadConfigValues; fileSystemWatcher.Created += ReadConfigValues; fileSystemWatcher.Renamed += ReadConfigValues; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private void ReadConfigValues(object sender, FileSystemEventArgs e) { if (!File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath)) { return; } try { Log.Debug("ReadConfigValues called"); ((BaseUnityPlugin)this).Config.Reload(); } catch { Log.Error("There was an issue loading your " + ((BaseUnityPlugin)this).Config.ConfigFilePath); Log.Error("Please check your config entries for spelling and format!"); } } } [HarmonyPatch(typeof(ZRpc), "SetLongTimeout")] public class IncreaseTimeout { private static bool Prefix() { ZRpc.m_timeout = 300f; ZLog.Log((object)$"ZRpc timeout set to {ZRpc.m_timeout}s "); return false; } } [HarmonyPatch(typeof(WorldGenerator), "GetForestFactor")] public class Forest { public static float Postfix(float result) { return result /= WorldInfo.ForestMultiplier; } } [HarmonyPatch(typeof(WorldGenerator), "GetBaseHeight")] public class BaseHeight { public static float Postfix(float result) { return WorldInfo.BaseWaterLevel + (result - WorldInfo.BaseWaterLevel) * WorldInfo.AltitudeMultiplier + WorldInfo.BaseAltitudeDelta; } } [HarmonyPatch(typeof(WorldGenerator), "GetBiomeHeight")] public class BiomeHeight { public static float Postfix(float result) { if (!(result > WorldInfo.WaterLevel)) { return (result - WorldInfo.WaterLevel) * WorldInfo.WaterDepth + WorldInfo.WaterLevel; } return result; } } [HarmonyPatch] public class HeightSeed { private static IEnumerable<CodeInstruction> Transpile(IEnumerable<CodeInstruction> instructions) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } if (!Configuration.HeightSeed.HasValue) { return instructions; } return Helper.ReplaceSeed(new CodeMatcher(instructions, (ILGenerator)null), "m_offset3", Configuration.HeightSeed.Value).InstructionEnumeration(); } [HarmonyPatch(typeof(WorldGenerator), "GetAshlandsHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Ashlands(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } [HarmonyPatch(typeof(WorldGenerator), "GetForestHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Forest(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } [HarmonyPatch(typeof(WorldGenerator), "GetMeadowsHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Meadows(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } [HarmonyPatch(typeof(WorldGenerator), "GetDeepNorthHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> DeepNorth(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } [HarmonyPatch(typeof(WorldGenerator), "GetPlainsHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Plains(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } [HarmonyPatch(typeof(WorldGenerator), "GetSnowMountainHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Mountain(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } [HarmonyPatch(typeof(WorldGenerator), "GetMistlandsHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> Mistlands(IEnumerable<CodeInstruction> instructions) { return Transpile(instructions); } } [HarmonyPatch(typeof(LoadingIndicator), "SetShowProgress")] public class ModifyLocations { private static readonly Dictionary<ZoneLocation, int> OriginalQuantities = new Dictionary<ZoneLocation, int>(); private static readonly Dictionary<ZoneLocation, float> OriginalMin = new Dictionary<ZoneLocation, float>(); private static readonly Dictionary<ZoneLocation, float> OriginalMax = new Dictionary<ZoneLocation, float>(); private static void Prefix(bool show) { if (!show) { return; } if (Configuration.LocationsMultiplier != 1f) { foreach (ZoneLocation location in ZoneSystem.instance.m_locations) { if (location.m_quantity != 0 && location.m_enable && !(location.m_prefabName == Game.instance.m_StartLocation)) { OriginalQuantities[location] = location.m_quantity; if (Configuration.LocationsMultiplier == 0f) { location.m_quantity = 0; } else { location.m_quantity = Math.Max(1, Mathf.RoundToInt((float)location.m_quantity * Configuration.LocationsMultiplier)); } } } } if (EWD.IsPresent || Configuration.WorldRadius == 10000f) { return; } foreach (ZoneLocation location2 in ZoneSystem.instance.m_locations) { OriginalMin[location2] = location2.m_minDistance; OriginalMax[location2] = location2.m_maxDistance; location2.m_minDistance *= Configuration.WorldRadius / 10000f; location2.m_maxDistance *= Configuration.WorldRadius / 10000f; } } private static void Postfix(bool show) { if (show) { return; } foreach (ZoneLocation location in ZoneSystem.instance.m_locations) { if (OriginalQuantities.TryGetValue(location, out var value)) { location.m_quantity = value; } if (OriginalMin.TryGetValue(location, out var value2)) { location.m_minDistance = value2; } if (OriginalMax.TryGetValue(location, out var value3)) { location.m_maxDistance = value3; } } OriginalQuantities.Clear(); OriginalMin.Clear(); OriginalMax.Clear(); } } [HarmonyPatch(typeof(ZoneSystem), "GetRandomZone")] public class GetRandomZone { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10000f, Configuration.WorldRadius).InstructionEnumeration(); } } [HarmonyPatch(typeof(ZoneSystem), "GenerateLocationsTimeSliced", new Type[] { typeof(ZoneLocation), typeof(Stopwatch), typeof(ZPackage) })] [HarmonyPatch(/*Could not decode attribute arguments.*/)] public class GenerateLocations { [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileMoveNext(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10000f, Configuration.WorldRadius).InstructionEnumeration(); } } public class GetAshlandsHeight { private static readonly double DefaultWidthRestriction = 7500.0; private static double PatchedWidthRestriction = DefaultWidthRestriction; private static readonly double DefaultLengthRestriction = 1000.0; private static double PatchedLengthRestriction = DefaultLengthRestriction; public static void Patch(Harmony harmony, double widthRestriction, double lengthRestriction) { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown if (PatchedWidthRestriction != widthRestriction || PatchedLengthRestriction != lengthRestriction) { MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "GetAshlandsHeight", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(GetAshlandsHeight), "Transpiler", (Type[])null, (Type[])null); PatchedWidthRestriction = widthRestriction; PatchedLengthRestriction = lengthRestriction; harmony.Unpatch((MethodBase)methodInfo, methodInfo2); if (PatchedWidthRestriction != DefaultWidthRestriction || PatchedLengthRestriction != DefaultLengthRestriction) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R8, (object)1000.0, (string)null) }).SetOperandAndAdvance((object)PatchedLengthRestriction).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R8, (object)7500.0, (string)null) }) .SetOperandAndAdvance((object)PatchedWidthRestriction) .InstructionEnumeration(); } } public class CreateAshlandsGap { private static bool IsPatched; public static void Patch(Harmony harmony, bool doPatch) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (IsPatched != doPatch) { MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "CreateAshlandsGap", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CreateAshlandsGap), "DisableGap", (Type[])null, (Type[])null); IsPatched = doPatch; if (doPatch) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Unpatch((MethodBase)methodInfo, methodInfo2); } } } private static bool DisableGap(ref double __result) { __result = 1.0; return false; } } public class CreateDeepNorthGap { private static bool IsPatched; public static void Patch(Harmony harmony, bool doPatch) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (IsPatched != doPatch) { MethodInfo methodInfo = AccessTools.Method(typeof(WorldGenerator), "CreateDeepNorthGap", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(CreateAshlandsGap), "DisableGap", (Type[])null, (Type[])null); IsPatched = doPatch; if (doPatch) { harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } else { harmony.Unpatch((MethodBase)methodInfo, methodInfo2); } } } private static bool DisableGap(ref double __result) { __result = 1.0; return false; } } [HarmonyPatch(typeof(WorldGenerator), "FindLakes")] public class FindLakes { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(Helper.Replace(Stretch.Replace(Stretch.Replace(Helper.Replace(Helper.Replace(Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), -10000f, 0f - Configuration.WorldRadius), -10000f, 0f - Configuration.WorldRadius), 10000f, Configuration.WorldRadius), OpCodes.Ldloc_3), OpCodes.Ldloc_2), 10000f, Configuration.WorldRadius), 10000f, Configuration.WorldRadius).InstructionEnumeration(); } } [HarmonyPatch(typeof(WorldGenerator), "IsRiverAllowed")] public class IsRiverAllowed { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Stretch.Replace(Stretch.Replace(new CodeMatcher(instructions, (ILGenerator)null), OpCodes.Ldfld), OpCodes.Ldfld).InstructionEnumeration(); } } [HarmonyPatch(typeof(WorldGenerator), "FindStreamStartPoint")] public class FindStreamStartPoint { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(Helper.Replace(Helper.Replace(Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), -10000f, 0f - Configuration.WorldRadius), 10000f, Configuration.WorldRadius), -10000f, 0f - Configuration.WorldRadius), 10000f, Configuration.WorldRadius).InstructionEnumeration(); } } public class AddRivers { public static void Prefix(ref float wx, ref float wy) { wx *= Configuration.WorldStretch; wy *= Configuration.WorldStretch; } } [HarmonyPatch] public class Stretch { public static IEnumerable<CodeInstruction> StretchIsAshlandsTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(WorldGenerator), "IsAshlands", (Type[])null, (Type[])null), (string)null) }).MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Vector3), "z"), (string)null) }).Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Vector3), "x"), (string)null) }) .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .InstructionEnumeration(); } public static IEnumerable<CodeInstruction> StretchIsAshlandsDeepNorthTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(WorldGenerator), "IsAshlands", (Type[])null, (Type[])null), (string)null) }).MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Vector3), "z"), (string)null) }).Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Vector3), "x"), (string)null) }) .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(WorldGenerator), "IsDeepnorth", (Type[])null, (Type[])null), (string)null) }) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Vector3), "z"), (string)null) }) .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .MatchBack(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(Vector3), "x"), (string)null) }) .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .InstructionEnumeration(); } [HarmonyPriority(500)] public static void StretchVector3(ref Vector3 pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos; val.x = pos.x / Configuration.WorldStretch; val.z = pos.z / Configuration.WorldStretch; pos = val; } [HarmonyPriority(500)] public static void GetMaskColor(ref float wx, ref float wy) { wx /= Configuration.WorldStretch; wy /= Configuration.WorldStretch; } [HarmonyPriority(500)] public static void GetBiomeHeight(ref float wx, ref float wy) { wx /= Configuration.WorldStretch; wy /= Configuration.WorldStretch; } [HarmonyPriority(500)] public static void GetBiome(ref float wx, ref float wy) { wx /= Configuration.WorldStretch; wy /= Configuration.WorldStretch; } public static CodeMatcher Replace(CodeMatcher matcher, OpCode code) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown if (Configuration.WorldStretch == 1f) { return matcher; } return matcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)code, (object)null, (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.WorldStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }); } public static CodeMatcher ReplaceBiome(CodeMatcher matcher) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown if (Configuration.BiomeStretch == 1f) { return matcher; } return matcher.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_1, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R8, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.BiomeStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_2, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Conv_R8, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Add, (object)null, (string)null) }) .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_R4, (object)Configuration.BiomeStretch) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Div, (object)null) }); } [HarmonyPatch(typeof(WorldGenerator), "GetBiome", new Type[] { typeof(float), typeof(float), typeof(float), typeof(bool) })] private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } CodeMatcher val = new CodeMatcher(ReplaceBiome(ReplaceBiome(ReplaceBiome(ReplaceBiome(new CodeMatcher(instructions, (ILGenerator)null))))).InstructionEnumeration(), (ILGenerator)null); AccessTools.Field(typeof(WorldGenerator), "ashlandsMinDistance").SetValue(null, 1.2f * Configuration.StrechedWorldRadius); AccessTools.Field(typeof(WorldGenerator), "ashlandsYOffset").SetValue(null, -0.4f * Configuration.StrechedWorldRadius); return Helper.Replace(Helper.Replace(Helper.Replace(Helper.Replace(Helper.Replace(Helper.Replace(Helper.Replace(Helper.Replace(val, 2000f, 0.2f * Configuration.StrechedWorldRadius), 6000.0, 0.6 * (double)Configuration.StrechedWorldRadius), 10000f, Configuration.StrechedWorldRadius), 3000.0, 0.3 * (double)Configuration.StrechedWorldRadius), 8000f, 0.8f * Configuration.StrechedWorldRadius), 600.0, 0.06 * (double)Configuration.StrechedWorldRadius), 6000f, 0.6f * Configuration.StrechedWorldRadius), 5000.0, 0.5 * (double)Configuration.StrechedWorldRadius).InstructionEnumeration(); } [HarmonyPatch(typeof(WorldGenerator), "IsDeepnorth")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspilerIsDeepnorth(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 4000.0, 0.4 * (double)Configuration.StrechedWorldRadius), 12000.0, 1.2 * (double)Configuration.StrechedWorldRadius).InstructionEnumeration(); } [HarmonyPatch(typeof(WorldGenerator), "CreateAshlandsGap")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspilerCreateAshlandsGap(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 400.0, 0.04 * (double)Configuration.StrechedWorldRadius).InstructionEnumeration(); } [HarmonyPatch(typeof(WorldGenerator), "CreateDeepNorthGap")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspilerCreateDeepNorthGap(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(Helper.Replace(Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 4000f, 0.4f * Configuration.StrechedWorldRadius), 12000.0, 1.2f * Configuration.StrechedWorldRadius), 400.0, 0.04 * (double)Configuration.StrechedWorldRadius).InstructionEnumeration(); } [HarmonyPatch(typeof(WorldGenerator), "GetBiomeHeight")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspilerGetBiomeHeight(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10500f, Configuration.StrechedWorldTotalRadius).InstructionEnumeration(); } } [HarmonyPatch(typeof(Player), "AddKnownBiome")] public class StartColorTransition { public static void Postfix(Biome biome) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 WaterColor.StartTransition((int)biome == 32); } } [HarmonyPatch(typeof(Player), "OnSpawned")] public class ResetColorTransition { public static void Postfix() { WaterColor.StopTransition(); } } public class WaterColor { private static float TransitionProgress; private static bool Transitioning; public static bool? TargetAshlands; private static bool InitDone; private static Color WaterSurface; private static Color AshlandsSurface; private static Color WaterTop; private static Color AshlandsTop; private static Color WaterBottom; private static Color AshlandsBottom; private static Color WaterShallow; private static Color AshlandsShallow; public static void Transition(float time) { if (!Transitioning) { return; } if (TargetAshlands.GetValueOrDefault()) { TransitionProgress += 0.1f * time; if (TransitionProgress >= 1f) { StopTransition(); } } else if (TargetAshlands == false) { TransitionProgress -= 0.1f * time; if (TransitionProgress <= 0f) { StopTransition(); } } UpdateTransitions(); } public static void StartTransition(bool toAshlands) { if (Configuration.FixWaterColor && TargetAshlands != toAshlands) { TargetAshlands = toAshlands; Transitioning = true; } } public static void StopTransition() { if (Transitioning) { Transitioning = false; TransitionProgress = (TargetAshlands.GetValueOrDefault() ? 1f : 0f); } } private static void UpdateTransitions() { foreach (WaterVolume instance2 in WaterVolume.Instances) { UpdateTransition(((Renderer)instance2.m_waterSurface).sharedMaterial); } EnvMan instance = EnvMan.instance; Transform val = ((instance != null) ? ((Component)instance).transform.Find("WaterPlane").Find("watersurface") : null); if ((Object)(object)val != (Object)null) { UpdateTransition(((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial); } } private static void UpdateTransition(Material mat) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) InitColors(mat); Color surface = Color.Lerp(WaterSurface, AshlandsSurface, TransitionProgress); Color top = Color.Lerp(WaterTop, AshlandsTop, TransitionProgress); Color bottom = Color.Lerp(WaterBottom, AshlandsBottom, TransitionProgress); Color shallow = Color.Lerp(WaterShallow, AshlandsShallow, TransitionProgress); UpdateColors(mat, surface, top, bottom, shallow); } public static void Regenerate() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { StartTransition((int)Player.m_localPlayer.GetCurrentBiome() == 32); } foreach (WaterVolume instance2 in WaterVolume.Instances) { FixColors(((Renderer)instance2.m_waterSurface).sharedMaterial); } EnvMan instance = EnvMan.instance; Transform val = ((instance != null) ? ((Component)instance).transform.Find("WaterPlane").Find("watersurface") : null); if ((Object)(object)val != (Object)null) { FixColors(((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial); } } public static void FixColors(Material mat) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) InitColors(mat); if (Configuration.FixWaterColor) { UpdateTransition(mat); return; } if (Configuration.RemoveAshlandsWater) { StopTransition(); UpdateColors(mat, WaterSurface, WaterTop, WaterBottom, WaterShallow); return; } StopTransition(); mat.SetColor("_SurfaceColor", WaterSurface); mat.SetColor("_AshlandsSurfaceColor", AshlandsSurface); mat.SetColor("_ColorTop", WaterTop); mat.SetColor("_AshlandsColorTop", AshlandsTop); mat.SetColor("_ColorBottom", WaterBottom); mat.SetColor("_AshlandsColorBottom", AshlandsBottom); mat.SetColor("_ColorBottomShallow", WaterShallow); mat.SetColor("_AshlandsColorBottomShallow", AshlandsShallow); } private static void UpdateColors(Material mat, Color surface, Color top, Color bottom, Color shallow) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) mat.SetColor("_SurfaceColor", surface); mat.SetColor("_AshlandsSurfaceColor", surface); mat.SetColor("_ColorTop", top); mat.SetColor("_AshlandsColorTop", top); mat.SetColor("_ColorBottom", bottom); mat.SetColor("_AshlandsColorBottom", bottom); mat.SetColor("_ColorBottomShallow", shallow); mat.SetColor("_AshlandsColorBottomShallow", shallow); } private static void InitColors(Material mat) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) if (!InitDone) { InitDone = true; WaterSurface = mat.GetColor("_SurfaceColor"); AshlandsSurface = mat.GetColor("_AshlandsSurfaceColor"); WaterTop = mat.GetColor("_ColorTop"); AshlandsTop = mat.GetColor("_AshlandsColorTop"); WaterBottom = mat.GetColor("_ColorBottom"); AshlandsBottom = mat.GetColor("_AshlandsColorBottom"); WaterShallow = mat.GetColor("_ColorBottomShallow"); AshlandsShallow = mat.GetColor("_AshlandsColorBottomShallow"); } } } public class WorldSizeHelper { public static IEnumerable<CodeInstruction> EdgeCheck(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown return Helper.Replace(Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10420f, Configuration.WorldTotalRadius - 80f), 10500f, Configuration.WorldTotalRadius).InstructionEnumeration(); } } [HarmonyPatch(typeof(Ship), "ApplyEdgeForce")] public class ApplyEdgeForce { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return WorldSizeHelper.EdgeCheck(instructions); } } [HarmonyPatch(typeof(Player), "EdgeOfWorldKill")] public class EdgeOfWorldKill { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { return WorldSizeHelper.EdgeCheck(instructions); } private static bool Prefix(Player __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return ((Component)__instance).transform.position.y < 4000f; } } [HarmonyPatch(typeof(WorldGenerator), "GetAshlandsHeight")] public class GetAshlandsHeightSize { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } return Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10150.0, (Configuration.WorldTotalRadius + 150f) / Configuration.WorldStretch).InstructionEnumeration(); } } [HarmonyPatch(typeof(WorldGenerator), "GetBaseHeight")] public class GetBaseHeight { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown if (Patcher.IsMenu) { return instructions; } CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null); val = val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(WorldGenerator), "m_offset1"), (string)null) }); if (Configuration.OffsetX.HasValue) { val = Helper.ReplaceSeed(val, "m_offset0", Configuration.OffsetX.Value); } if (Configuration.OffsetY.HasValue) { val = Helper.ReplaceSeed(val, "m_offset1", Configuration.OffsetY.Value); } val = Helper.Replace(val, 10000f, Configuration.StrechedWorldRadius); val = Helper.Replace(val, 10000f, Configuration.StrechedWorldRadius); val = Helper.Replace(val, 10500f, Configuration.StrechedWorldTotalRadius); val = Helper.Replace(val, 10490f, (Configuration.WorldTotalRadius - 10f) / Configuration.WorldStretch); val = Helper.Replace(val, 10500f, Configuration.StrechedWorldTotalRadius); return val.InstructionEnumeration(); } } [HarmonyPatch(typeof(WaterVolume), "SetupMaterial")] public class SetupMaterial { public static void Refresh() { foreach (WaterVolume instance in WaterVolume.Instances) { ((Renderer)instance.m_waterSurface).sharedMaterial.SetFloat("_WaterEdge", Configuration.WorldTotalRadius); } } public static void Prefix(WaterVolume __instance) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) ((Renderer)__instance.m_waterSurface).sharedMaterial.SetFloat("_WaterEdge", Configuration.WorldTotalRadius); if (((Component)__instance).transform.position.y < 30.001f && ((Component)__instance).transform.position.y > 29.999f) { Collider collider = __instance.m_collider; BoxCollider val = (BoxCollider)(object)((collider is BoxCollider) ? collider : null); if (val != null) { val.center = new Vector3(0f, -100f, 0f); val.size = new Vector3(64f, 220f, 64f); } } WaterColor.FixColors(((Renderer)__instance.m_waterSurface).sharedMaterial); } } [HarmonyPatch(typeof(EnvMan), "Awake")] public class ScaleGlobalWaterSurface { public static void Refresh(EnvMan obj) { Transform val = ((Component)obj).transform.Find("WaterPlane").Find("watersurface"); if (Object.op_Implicit((Object)(object)val)) { ((Renderer)((Component)val).GetComponent<MeshRenderer>()).sharedMaterial.SetFloat("_WaterEdge", Configuration.WorldTotalRadius); } } public static void Postfix(EnvMan __instance) { Refresh(__instance); } } [HarmonyPatch(typeof(EnvMan), "UpdateWind")] public class UpdateWind { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Helper.Replace(Helper.Replace(Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10500f, Configuration.WorldRadius).SetOpcodeAndAdvance(OpCodes.Nop).SetOpcodeAndAdvance(OpCodes.Nop) .SetOpcodeAndAdvance(OpCodes.Nop), 10500f, Configuration.WorldRadius).SetOpcodeAndAdvance(OpCodes.Nop).SetOpcodeAndAdvance(OpCodes.Nop) .SetOpcodeAndAdvance(OpCodes.Nop), 10500f, Configuration.WorldTotalRadius).InstructionEnumeration(); } } [HarmonyPatch(typeof(WaterVolume), "GetWaterSurface")] public class GetWaterSurface { private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown return Helper.Replace(new CodeMatcher(instructions, (ILGenerator)null), 10500f, Configuration.WorldTotalRadius).InstructionEnumeration(); } } [HarmonyPatch(typeof(WorldGenerator), "Pregenerate")] [HarmonyPriority(500)] public class Pregenerate { private static void Prefix(WorldGenerator __instance) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) __instance.m_riverCacheLock.EnterWriteLock(); __instance.m_riverPoints = new Dictionary<Vector2i, RiverPoint[]>(); __instance.m_rivers = new List<River>(); __instance.m_streams = new List<River>(); __instance.m_lakes = new List<Vector2>(); __instance.m_cachedRiverGrid = new Vector2i(-999999, -999999); __instance.m_cachedRiverPoints = Array.Empty<RiverPoint>(); __instance.m_riverCacheLock.ExitWriteLock(); } } [HarmonyPatch(typeof(Minimap), "TryLoadMinimapTextureData")] public class PatchTryLoadMinimapTextureData { private static bool Prefix(Minimap __instance, ref bool __result) { __result = TryLoadMinimapTextureData(__instance); return false; } private static bool TryLoadMinimapTextureData(Minimap obj) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if (string.IsNullOrEmpty(obj.m_forestMaskTexturePath) || !File.Exists(obj.m_forestMaskTexturePath) || !File.Exists(obj.m_mapTexturePath) || !File.Exists(obj.m_heightTexturePath) || 33 != ZNet.World.m_worldVersion) { return false; } Stopwatch stopwatch = Stopwatch.StartNew(); Texture2D val = new Texture2D(((Texture)obj.m_forestMaskTexture).width, ((Texture)obj.m_forestMaskTexture).height, (TextureFormat)5, false); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(obj.m_forestMaskTexturePath))) { return false; } if (((Texture)obj.m_forestMaskTexture).width != ((Texture)val).width || ((Texture)obj.m_forestMaskTexture).height != ((Texture)val).height) { return false; } obj.m_forestMaskTexture.SetPixels(val.GetPixels()); obj.m_forestMaskTexture.Apply(); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(obj.m_mapTexturePath))) { return false; } if (((Texture)obj.m_mapTexture).width != ((Texture)val).width || ((Texture)obj.m_mapTexture).height != ((Texture)val).height) { return false; } obj.m_mapTexture.SetPixels(val.GetPixels()); obj.m_mapTexture.Apply(); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(obj.m_heightTexturePath))) { return false; } if (((Texture)obj.m_heightTexture).width != ((Texture)val).width || ((Texture)obj.m_heightTexture).height != ((Texture)val).height) { return false; } Color[] pixels = val.GetPixels(); for (int i = 0; i < obj.m_textureSize; i++) { for (int j = 0; j < obj.m_textureSize; j++) { int num = i * obj.m_textureSize + j; int num2 = (int)(pixels[num].r * 255f); int num3 = (int)(pixels[num].g * 255f); int num4 = (num2 << 8) + num3; float num5 = 127.5f; pixels[num].r = (float)num4 / num5; } } obj.m_heightTexture.SetPixels(pixels); obj.m_heightTexture.Apply(); ZLog.Log((object)("Loading minimap textures done [" + stopwatch.ElapsedMilliseconds + "ms]")); return true; } } [HarmonyPatch(typeof(Minimap), "GenerateWorldMap")] public class MapGeneration { private static bool DoFakeGenerate; private static CancellationTokenSource? CTS; public static bool Generating => CTS != null; private static bool Prefix(Minimap __instance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType == 4) { return true; } if (DoFakeGenerate) { DoFakeGenerate = false; return false; } if (BetterContinents.IsEnabled()) { Log.Info("Better Continents enabled, skipping map generation."); return true; } ((MonoBehaviour)Game.instance).StartCoroutine(Coroutine(__instance)); return false; } public static void Cancel() { if (CTS != null) { Log.Info("Cancelling previous map generation."); CTS.Cancel(); CTS = null; } } public static void UpdateTextureSize(Minimap map, int textureSize) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown if (map.m_textureSize != textureSize) { map.m_textureSize = textureSize; map.m_mapTexture = new Texture2D(map.m_textureSize, map.m_textureSize, (TextureFormat)3, false) { wrapMode = (TextureWrapMode)1 }; map.m_forestMaskTexture = new Texture2D(map.m_textureSize, map.m_textureSize, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; map.m_heightTexture = new Texture2D(map.m_textureSize, map.m_textureSize, (TextureFormat)18, false) { wrapMode = (TextureWrapMode)1 }; map.m_fogTexture = new Texture2D(map.m_textureSize, map.m_textureSize, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; map.m_explored = new bool[map.m_textureSize * map.m_textureSize]; map.m_exploredOthers = new bool[map.m_textureSize * map.m_textureSize]; ((Graphic)map.m_mapImageLarge).material.SetTexture("_MainTex", (Texture)(object)map.m_mapTexture); ((Graphic)map.m_mapImageLarge).material.SetTexture("_MaskTex", (Texture)(object)map.m_forestMaskTexture); ((Graphic)map.m_mapImageLarge).material.SetTexture("_HeightTex", (Texture)(object)map.m_heightTexture); ((Graphic)map.m_mapImageLarge).material.SetTexture("_FogTex", (Texture)(object)map.m_fogTexture); ((Graphic)map.m_mapImageSmall).material.SetTexture("_MainTex", (Texture)(object)map.m_mapTexture); ((Graphic)map.m_mapImageSmall).material.SetTexture("_MaskTex", (Texture)(object)map.m_forestMaskTexture); ((Graphic)map.m_mapImageSmall).material.SetTexture("_HeightTex", (Texture)(object)map.m_heightTexture); ((Graphic)map.m_mapImageSmall).material.SetTexture("_FogTex", (Texture)(object)map.m_fogTexture); map.Reset(); } } private static IEnumerator Coroutine(Minimap map) { Cancel(); Log.Info("Starting map generation."); Stopwatch stopwatch = Stopwatch.StartNew(); Minimap.DeleteMapTextureData(ZNet.World.m_name); int num = map.m_textureSize * map.m_textureSize; Color32[] mapTexture = (Color32[])(object)new Color32[num]; Color32[] forestMaskTexture = (Color32[])(object)new Color32[num]; Color[] heightTexture = (Color[])(object)new Color[num]; Color32[] cachedTexture = (Color32[])(object)new Color32[num]; CancellationTokenSource cts = new CancellationTokenSource(); CancellationToken ct = cts.Token; while (Marketplace.IsLoading()) { yield return null; } Task task = Generate(map, mapTexture, forestMaskTexture, heightTexture, cachedTexture, ct); CTS = cts; while (!task.IsCompleted) { yield return null; } if (task.IsFaulted) { Log.Error($"Map generation failed!\n{task.Exception}"); } else if (!ct.IsCancellationRequested) { map.m_mapTexture.SetPixels32(mapTexture); yield return null; map.m_mapTexture.Apply(); yield return null; map.m_forestMaskTexture.SetPixels32(forestMaskTexture); yield return null; map.m_forestMaskTexture.Apply(); yield return null; map.m_heightTexture.SetPixels(heightTexture); yield return null; map.m_heightTexture.Apply(); yield return null; DoFakeGenerate = true; map.GenerateWorldMap(); Texture2D val = new Texture2D(map.m_textureSize, map.m_textureSize); val.SetPixels32(cachedTexture); val.Apply(); Log.Info($"Map generation finished ({stopwatch.Elapsed.TotalSeconds:F0} seconds)."); map.SaveMapTextureDataToDisk(map.m_forestMaskTexture, map.m_mapTexture, val); } stopwatch.Stop(); cts.Dispose(); if (CTS == cts) { CTS = null; } } private static async Task Generate(Minimap map, Color32[] mapTexture, Color32[] forestMaskTexture, Color[] heightTexture, Color32[] cachedtexture, CancellationToken ct) { Minimap map2 = map; Color32[] mapTexture2 = mapTexture; Color32[] forestMaskTexture2 = forestMaskTexture; Color[] heightTexture2 = heightTexture; Color32[] cachedtexture2 = cachedtexture; await Task.Run(delegate { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); } WorldGenerator instance = WorldGenerator.m_instance; int textureSize = map2.m_textureSize; int num = textureSize / 2; float pixelSize = map2.m_pixelSize; float num2 = pixelSize / 2f; float num3 = 127.5f; Color val = default(Color); for (int i = 0; i < textureSize; i++) { for (int j = 0; j < textureSize; j++) { float num4 = (float)(j - num) * pixelSize + num2; float num5 = (float)(i - num) * pixelSize + num2; while (Marketplace.IsLoading()) { Log.Info("Waiting 100 ms for Marketplace to load..."); Thread.Sleep(100); } Biome biome = instance.GetBiome(num4, num5, 0.02f, false); float biomeHeight = instance.GetBiomeHeight(biome, num4, num5, ref val, false); mapTexture2[i * textureSize + j] = Color32.op_Implicit(map2.GetPixelColor(biome)); forestMaskTexture2[i * textureSize + j] = Color32.op_Implicit(map2.GetMaskColor(num4, num5, biomeHeight, biome)); heightTexture2[i * textureSize + j] = new Color(biomeHeight, 0f, 0f); int num6 = Mathf.Clamp((int)(biomeHeight * num3), 0, 65025); byte b = (byte)(num6 >> 8); byte b2 = (byte)((uint)num6 & 0xFFu); cachedtexture2[i * textureSize + j] = new Color32(b, b2, (byte)0, byte.MaxValue); if (ct.IsCancellationRequested) { ct.ThrowIfCancellationRequested(); } } } }).ConfigureAwait(continueOnCapturedContext: false); } } [HarmonyPatch(typeof(Game), "Logout")] public class CancelOnLogout { private static void Prefix() { MapGeneration.Cancel(); } } public static class Helper { public static CodeMatcher Replace(CodeMatcher instructions, double value, double newValue) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown return instructions.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R8, (object)value, (string)null) }).SetOperandAndAdvance((object)newValue); } public static CodeMatcher Replace(CodeMatcher instructions, float value, float newValue) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown return instructions.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)value, (string)null) }).SetOperandAndAdvance((object)newValue); } public static CodeMatcher ReplaceSeed(CodeMatcher instructions, string name, float value) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown return instructions.MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(WorldGenerator), name), (string)null) }).Advance(-1).SetAndAdvance(OpCodes.Ldc_R4, (object)value) .RemoveInstruction(); } public static float HeightToBaseHeight(float altitude) { return altitude / 200f; } public static bool IsServer() { if (Object.op_Implicit((Object)(object)ZNet.instance)) { return ZNet.instance.IsServer(); } return false; } public static bool IsClient() { return !IsServer(); } } [HarmonyPatch(typeof(Minimap), "Awake")] public class MinimapAwake { public static float OriginalPixelSize; public static int OriginalTextureSize; public static float OriginalMaxZoom; public static void Postfix(Minimap __instance) { OriginalTextureSize = __instance.m_textureSize; OriginalMaxZoom = __instance.m_maxZoom; OriginalPixelSize = __instance.m_pixelSize; Refresh(__instance); } public static bool Refresh(Minimap instance) { int num = (int)((float)OriginalTextureSize * Configuration.MapSize); float num2 = OriginalMaxZoom * Mathf.Max(1f, Configuration.MapSize); float num3 = CalculatePixelSize(); if (instance.m_textureSize == num && instance.m_maxZoom == num2 && instance.m_pixelSize == num3) { return false; } MapGeneration.UpdateTextureSize(Minimap.instance, num); instance.m_maxZoom = num2; instance.m_pixelSize = num3; return true; } private static float CalculatePixelSize() { if (Configuration.MapPixelSize != 0f) { return OriginalPixelSize * Configuration.MapPixelSize; } float num = Configuration.WorldTotalRadius / 10500f; return OriginalPixelSize * num / Configuration.MapSize; } } [HarmonyPatch(typeof(Minimap), "SetMapData")] public class InitializeWhenDimensionsChange { public static bool Prefix(Minimap __instance, byte[] data) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown ZPackage val = new ZPackage(data); if (val.ReadInt() >= 7) { val = val.ReadCompressedPackage(); } int num = val.ReadInt(); if (__instance.m_textureSize == num) { return true; } __instance.Reset(); __instance.m_fogTexture.Apply(); return false; } } [HarmonyPatch(typeof(Minimap), "Awake")] public class Minimap_Alignment { private static void Postfix(Minimap __instance) { __instance.m_biomeNameSmall.alignment = (TextAlignmentOptions)260; __instance.m_biomeNameLarge.alignment = (TextAlignmentOptions)260; } } [HarmonyPatch(typeof(Minimap), "UpdateBiome")] public class Minimap_ShowLoading { private static string PreviousSmallText = ""; private static string PreviousLargeText = ""; private static void AddText(TMP_Text input, string text) { if (!input.text.Contains(text)) { input.text += text; } } private static void CleanUp(TMP_Text input, string text) { if (!(text == "") && input.text.Contains(text)) { input.text = input.text.Replace(text, ""); } } private static string GetText() { return "\nLoading.."; } private static void Postfix(Minimap __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_0080: Invalid comparison between Unknown and I4 MapMode mode = __instance.m_mode; if (PreviousSmallText != "") { CleanUp(__instance.m_biomeNameSmall, PreviousSmallText); PreviousSmallText = ""; } if (PreviousLargeText != "") { CleanUp(__instance.m_biomeNameLarge, PreviousLargeText); PreviousLargeText = ""; } if ((int)mode == 1 && MapGeneration.Generating) { string text = GetText(); AddText(__instance.m_biomeNameSmall, text); PreviousSmallText = text; } if ((int)mode == 2 && MapGeneration.Generating) { string text2 = GetText(); AddText(__instance.m_biomeNameLarge, text2); PreviousLargeText = text2; } } } } namespace ServerSync { [PublicAPI] public abstract class OwnConfigEntryBase { public object? LocalBaseValue; public bool SynchronizedConfig = true; public abstract ConfigEntryBase BaseConfig { get; } } [PublicAPI] public class SyncedConfigEntry<T> : OwnConfigEntryBase { public readonly ConfigEntry<T> SourceConfig; public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig; public T Value { get { return SourceConfig.Value; } set { SourceConfig.Value = value; } } public SyncedConfigEntry(ConfigEntry<T> sourceConfig) { SourceConfig = sourceConfig; base..ctor(); } public void AssignLocalValue(T value) { if (LocalBaseValue == null) { Value = value; } else { LocalBaseValue = value; } } } internal abstract class CustomSyncedValueBase { public object? LocalBaseValue; public readonly string Identifier; public readonly Type Type; private object? boxedValue; protected bool localIsOwner; public readonly int Priority; public object? BoxedValue { get { return boxedValue; } set { boxedValue = value; this.ValueChanged?.Invoke(); } } public event Action? ValueChanged; protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority) { Priority = priority; Identifier = identifier; Type = type; configSync.AddCustomValue(this); localIsOwner = configSync.IsSourceOfTruth; configSync.SourceOfTruthChanged += delegate(bool truth) { localIsOwner = truth; }; } } [PublicAPI] internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase { public T Value { get { return (T)base.BoxedValue; } set { base.BoxedValue = value; } } public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0) : base(configSync, identifier, typeof(T), priority) { Value = value; } public void AssignLocalValue(T value) { if (localIsOwner) { Value = value; } else { LocalBaseValue = value; } } } internal class ConfigurationManagerAttributes { [UsedImplicitly] public bool? ReadOnly = false; } [PublicAPI] public class ConfigSync { [HarmonyPatch(typeof(ZRpc), "HandlePackage")] private static class SnatchCurrentlyHandlingRPC { public static ZRpc? currentRpc; [HarmonyPrefix] private static void Prefix(ZRpc __instance) { currentRpc = __instance; } } [HarmonyPatch(typeof(ZNet), "Awake")] internal static class RegisterRPCPatch { [HarmonyPostfix] private static void Postfix(ZNet __instance) { isServer = __instance.IsServer(); foreach (ConfigSync configSync2 in configSyncs) { ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync); if (isServer) { configSync2.InitialSyncDone = true; Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections")); } } if (isServer) { ((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges()); } static void SendAdmin(List<ZNetPeer> peers, bool isAdmin) {