Decompiled source of Render Limits v1.14.0

RenderLimits.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Service;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("RenderLimits")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+13ac2c33375513b53f8858c13d207c03d08d0797")]
[assembly: AssemblyProduct("RenderLimits")]
[assembly: AssemblyTitle("RenderLimits")]
[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 Dictionary<string, Action<Terminal, string>> SettingHandlers = new Dictionary<string, Action<Terminal, string>>();

		public ConfigWrapper(string command, ConfigFile configFile)
		{
			//IL_0025: 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_0043: Expected O, but got Unknown
			//IL_0043: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			ConfigFile = configFile;
			new ConsoleCommand(command, "[key] [value] - Toggles or sets a config value.", (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				if (args.Length >= 2 && SettingHandlers.TryGetValue(args[1].ToLower(), out Action<Terminal, string> value))
				{
					if (args.Length == 2)
					{
						value(args.Context, "");
					}
					else
					{
						value(args.Context, string.Join(" ", args.Args.Skip(2)));
					}
				}
			}, false, false, false, false, false, (ConsoleOptionsFetcher)(() => SettingHandlers.Keys.ToList()), false, false, false);
		}

		private void HandleChange(ConfigEntry<string> configEntry, Action onChange)
		{
			Action onChange2 = onChange;
			configEntry.SettingChanged += delegate
			{
				onChange2();
			};
		}

		private void HandleChange(ConfigEntry<string> configEntry, Action<string> onChange)
		{
			Action<string> onChange2 = onChange;
			ConfigEntry<string> configEntry2 = configEntry;
			configEntry2.SettingChanged += delegate
			{
				onChange2(configEntry2.Value);
			};
			onChange2(configEntry2.Value);
		}

		private void HandleChange(ConfigEntry<string> configEntry, Action<int> onChange)
		{
			Action<int> onChange2 = onChange;
			HandleChange(configEntry, onSettingChanged);
			void onSettingChanged(string value)
			{
				if (TryParseInt(value, out var result))
				{
					onChange2(result);
				}
			}
		}

		private void HandleChange(ConfigEntry<string> configEntry, Action<float> onChange)
		{
			Action<float> onChange2 = onChange;
			HandleChange(configEntry, onSettingChanged);
			void onSettingChanged(string value)
			{
				if (TryParseFloat(value, out var result))
				{
					onChange2(result);
				}
			}
		}

		public ConfigEntry<bool> Bind(string group, string name, bool value, string description)
		{
			ConfigEntry<bool> val = ConfigFile.Bind<bool>(group, name, value, description);
			Register<bool>(val);
			return val;
		}

		public ConfigEntry<string> Bind(string group, string name, string value, string description, Action onChange)
		{
			ConfigEntry<string> val = ConfigFile.Bind<string>(group, name, value, description);
			Register(val);
			HandleChange(val, onChange);
			return val;
		}

		public ConfigEntry<string> Bind(string group, string name, string value, string description, Action<string> onChange)
		{
			ConfigEntry<string> val = ConfigFile.Bind<string>(group, name, value, description);
			Register(val);
			HandleChange(val, onChange);
			return val;
		}

		public ConfigEntry<string> Bind(string group, string name, string value, string description, Action<int> onChange)
		{
			ConfigEntry<string> val = ConfigFile.Bind<string>(group, name, value, description);
			Register(val);
			HandleChange(val, onChange);
			return val;
		}

		public ConfigEntry<string> Bind(string group, string name, string value, string description, Action<float> onChange)
		{
			ConfigEntry<string> val = ConfigFile.Bind<string>(group, name, value, description);
			Register(val);
			HandleChange(val, onChange);
			return val;
		}

		private static void AddMessage(Terminal context, string message)
		{
			context.AddString(message);
			Player localPlayer = Player.m_localPlayer;
			if (localPlayer != null)
			{
				((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null);
			}
		}

		private void Register(ConfigEntry<string> setting)
		{
			ConfigEntry<string> setting2 = setting;
			string name = ((ConfigEntryBase)setting2).Definition.Key;
			string key = name.ToLower().Replace(' ', '_');
			SettingHandlers.Add(key, delegate(Terminal terminal, string value)
			{
				SetValue<string>(terminal, setting2, name, value);
			});
		}

		private void Register<T>(ConfigEntry<T> setting)
		{
			ConfigEntry<T> setting2 = setting;
			string name = ((ConfigEntryBase)setting2).Definition.Key;
			string key = name.ToLower().Replace(' ', '_');
			SettingHandlers.Add(key, delegate(Terminal terminal, string value)
			{
				SetValue<T>(terminal, setting2, name, value);
			});
		}

		public static int ParseInt(string value, int defaultValue)
		{
			if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static bool TryParseInt(ConfigEntry<string> setting, out int result)
		{
			return TryParseInt(setting.Value, out result);
		}

		public static bool TryParseInt(string value, out int result)
		{
			return int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result);
		}

		public static int ParseInt(ConfigEntry<string> setting)
		{
			if (int.TryParse(setting.Value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return ParseInt((string)((ConfigEntryBase)setting).DefaultValue, 0);
		}

		private static float ParseFloat(string value, float defaultValue)
		{
			if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return defaultValue;
		}

		public static float ParseFloat(ConfigEntry<string> setting)
		{
			if (float.TryParse(setting.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return ParseFloat((string)((ConfigEntryBase)setting).DefaultValue, 0f);
		}

		public static bool TryParseFloat(string value, out float result)
		{
			return float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result);
		}

		private static void SetValue<T>(Terminal context, ConfigEntry<T> setting, string name, string value)
		{
			if (value == "")
			{
				AddMessage(context, $"{name}: {setting.Value}.");
				return;
			}
			setting.Value = (T)(object)value;
			AddMessage(context, name + " set to " + value + ".");
		}
	}
	public class Helper
	{
		public static void AddMessage(Terminal context, string message, bool priority = true)
		{
			context.AddString(message);
			MessageHud instance = MessageHud.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return;
			}
			if (priority)
			{
				MsgData[] array = instance.m_msgQeue.ToArray();
				instance.m_msgQeue.Clear();
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)1, message, 0, (Sprite)null);
				}
				MsgData[] array2 = array;
				foreach (MsgData item in array2)
				{
					instance.m_msgQeue.Enqueue(item);
				}
				instance.m_msgQueueTimer = 10f;
			}
			else
			{
				Player localPlayer2 = Player.m_localPlayer;
				if (localPlayer2 != null)
				{
					((Character)localPlayer2).Message((MessageType)1, message, 0, (Sprite)null);
				}
			}
		}

		public static void Command(string name, string description, ConsoleEvent action, ConsoleOptionsFetcher? fetcher = null)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			new ConsoleCommand(name, description, Catch(action), false, false, false, false, false, fetcher, false, false, false);
		}

		public static void AddError(Terminal context, string message, bool priority = true)
		{
			AddMessage(context, "Error: " + message, priority);
		}

		public static ConsoleEvent Catch(ConsoleEvent action)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			ConsoleEvent action2 = action;
			return (ConsoleEvent)delegate(ConsoleEventArgs args)
			{
				try
				{
					if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
					{
						throw new InvalidOperationException("Player not found.");
					}
					action2.Invoke(args);
				}
				catch (InvalidOperationException ex)
				{
					AddError(args.Context, ex.Message);
				}
			};
		}
	}
}
namespace RenderLimits
{
	public class Configuration
	{
		public static ConfigEntry<string> configActivateArea;

		public static ConfigEntry<string> configLoadedArea;

		public static ConfigEntry<string> configGeneratedArea;

		public static ConfigEntry<string> configRealTerrainVisibility;

		public static ConfigEntry<string> configClutterVisibility;

		public static ConfigEntry<string> configForceActive;

		public static HashSet<Vector2i> ForceActive = new HashSet<Vector2i>();

		public static ConfigEntry<string> configMaximumGeneratedArea;

		public static ConfigEntry<bool> configAllowForceActive;

		public static ConfigEntry<string> configPixelLightCount;

		public static ConfigEntry<string> configShadowCascades;

		public static ConfigEntry<string> configShadowQuality;

		public static ConfigEntry<string> configShadowDistance;

		public static ConfigEntry<string> configShadowResolution;

		public static ConfigEntry<string> configLodBias;

		public static int ActiveArea => ConfigWrapper.ParseInt(configActivateArea);

		public static int LoadedArea => ConfigWrapper.ParseInt(configLoadedArea);

		public static int GeneratedArea => ConfigWrapper.ParseInt(configGeneratedArea);

		public static int RealTerrainVisibility => ConfigWrapper.ParseInt(configRealTerrainVisibility);

		public static int ClutterVisibility => ConfigWrapper.ParseInt(configClutterVisibility);

		public static int MaximumGeneratedArea => Math.Max(1, ConfigWrapper.ParseInt(configMaximumGeneratedArea));

		public static bool AllowForceActive => configAllowForceActive.Value;

		private static void ParseForceActive(string value)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Vector2i> hashSet = new HashSet<Vector2i>();
			foreach (Vector2i item in (from s in value.Split(new char[1] { '|' })
				select s.Trim() into s
				select s.Split(new char[1] { ',' }) into s
				where s.Length == 2
				select s).Select((Func<string[], Vector2i>)delegate(string[] s)
			{
				//IL_0010: 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_001b: 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_0022: 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)
				try
				{
					return new Vector2i(int.Parse(s[0]), int.Parse(s[1]));
				}
				catch
				{
					return default(Vector2i);
				}
			}))
			{
				hashSet.Add(item);
			}
			ForceActive = hashSet;
		}

		public static void SaveForceActive()
		{
			configForceActive.Value = string.Join("|", ForceActive.Select((Vector2i s) => $"{s.x},{s.y}"));
		}

		public static void Init(ConfigFile configFile)
		{
			ConfigWrapper configWrapper = new ConfigWrapper("render_config", configFile);
			string group = "1. Zones";
			configActivateArea = configWrapper.Bind(group, "Active zones", "1", "Amounts of zones that are active around the player. Creatures are active in this area.", (Action)delegate
			{
				LimitManager.UpdateLocalLimits();
				ZoneSystemPatches.Update();
			});
			configLoadedArea = configWrapper.Bind(group, "Loaded zones", "2", "Amounts of zones loaded around the player. Structures are visible in this area. ", (Action)delegate
			{
				LimitManager.UpdateLocalLimits();
				ZoneSystemPatches.Update();
				TerrainVisibility.Update();
			});
			configGeneratedArea = configWrapper.Bind(group, "Generated zones", "4", "Amounts of zones generated around the player. Large static objects like trees are visible in this area.", (Action)delegate
			{
				LimitManager.UpdateLocalLimits();
				ZoneSystemPatches.Update();
			});
			configRealTerrainVisibility = configWrapper.Bind(group, "Real terrain visibility", "0", "Visibility in meters. If 0, automatically calculated from loaded area.", TerrainVisibility.Update);
			configForceActive = configWrapper.Bind(group, "Force active", "", "Zones that are always active.", (Action)delegate
			{
				ParseForceActive(configForceActive.Value);
				LimitManager.UpdateLocalLimits();
			});
			group = "2. Quality";
			configClutterVisibility = configWrapper.Bind(group, "Clutter visibility", "45", "Visibility in meters.", ClutterDistance.Update);
			configLodBias = configWrapper.Bind(group, "Lod bias", "", "Level of detail limit (increase to show smaller objects, vanilla is from 1 to 5 but even 100 works).", delegate(int value)
			{
				QualitySettings.lodBias = value;
			});
			configPixelLightCount = configWrapper.Bind(group, "Pixel light count", "", "Light detail (bigger the better, vanilla is from 2 to 8).", delegate(int value)
			{
				QualitySettings.pixelLightCount = value;
			});
			configShadowCascades = configWrapper.Bind(group, "Shadow cascades", "", "Improves shadows near the camera (bigger the better, vanilla is from 2 to 4).", delegate(int value)
			{
				QualitySettings.shadowCascades = value;
			});
			configShadowQuality = configWrapper.Bind(group, "Shadow quality", "", "0: off, 1: hard only, 2: all.", delegate(int value)
			{
				QualitySettings.shadows = (ShadowQuality)Math.Max(0, Math.Min(2, value));
			});
			configShadowDistance = configWrapper.Bind(group, "Shadow distance", "", "Max distance for shadows in meters (vanilla is from 80 to 150).", delegate(float value)
			{
				QualitySettings.shadowDistance = value;
			});
			configShadowResolution = configWrapper.Bind(group, "Shadow resolution", "", "Shadow quality. From 0 to 3.", delegate(int value)
			{
				QualitySettings.shadowResolution = (ShadowResolution)Math.Max(0, Math.Min(3, value));
			});
			group = "3. Server limits";
			configMaximumGeneratedArea = configWrapper.Bind(group, "Maximum generated zones", "10", "Maximum generated zones that can be received from clients.", (Action<int>)delegate
			{
			});
			configAllowForceActive = configWrapper.Bind(group, "Allow force active", value: false, "Whether clients can have force active areas.");
			ParseForceActive(configForceActive.Value);
			LimitManager.UpdateLocalLimits();
		}

		public static void InitSettings()
		{
			if (ConfigWrapper.TryParseInt(configLodBias.Value, out var result))
			{
				QualitySettings.lodBias = result;
			}
			if (ConfigWrapper.TryParseInt(configPixelLightCount.Value, out var result2))
			{
				QualitySettings.pixelLightCount = result2;
			}
			if (ConfigWrapper.TryParseInt(configShadowCascades.Value, out var result3))
			{
				QualitySettings.shadowCascades = result3;
			}
			if (ConfigWrapper.TryParseInt(configShadowQuality.Value, out var result4))
			{
				QualitySettings.shadows = (ShadowQuality)Math.Max(0, Math.Min(2, result4));
			}
			if (ConfigWrapper.TryParseFloat(configShadowDistance.Value, out var result5))
			{
				QualitySettings.shadowDistance = result5;
			}
			if (ConfigWrapper.TryParseInt(configShadowResolution.Value, out var result6))
			{
				QualitySettings.shadowResolution = (ShadowResolution)Math.Max(0, Math.Min(3, result6));
			}
		}
	}
	[HarmonyPatch(typeof(ClutterSystem), "Awake")]
	public class ClutterDistance
	{
		private static void Postfix(ClutterSystem __instance)
		{
			Set(__instance);
		}

		private static void Set(ClutterSystem obj)
		{
			obj.m_distance = Configuration.ClutterVisibility;
			obj.ClearAll();
		}

		public static void Update()
		{
			if (Object.op_Implicit((Object)(object)ClutterSystem.instance))
			{
				Set(ClutterSystem.instance);
			}
		}
	}
	public class ForceActiveCommand
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__0_0;

			public static Func<Vector2i, bool> <>9__0_4;

			public static Func<Vector2i, bool> <>9__0_5;

			public static Func<Vector2i, string> <>9__0_2;

			public static Func<Vector2i, string> <>9__0_3;

			public static ConsoleEvent <>9__0_1;

			internal void <.ctor>b__0_0(ConsoleEventArgs args)
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				string text = "toggle";
				if (args.Length > 1)
				{
					text = args[1];
				}
				int num = 0;
				if (args.Length > 2 && int.TryParse(args[2], out var result))
				{
					num = result;
				}
				Vector2i zone = ZoneSystem.GetZone(ZNet.instance.GetReferencePosition());
				Vector2i val = default(Vector2i);
				for (int i = -num; i <= num; i++)
				{
					for (int j = -num; j <= num; j++)
					{
						((Vector2i)(ref val))..ctor(zone.x + i, zone.y + j);
						bool flag = Configuration.ForceActive.Contains(val);
						bool num2 = text == "add" || (text != "remove" && !flag);
						if (num2 && flag)
						{
							Helper.AddMessage(args.Context, $"Zone {val.x},{val.y} is already in active zones.");
						}
						if (!num2 && !flag)
						{
							Helper.AddMessage(args.Context, $"Zone {val.x},{val.y} is not in active zones.");
						}
						if (!num2 && flag)
						{
							Helper.AddMessage(args.Context, $"Zone {val.x},{val.y} removed from active zones.");
							Configuration.ForceActive.Remove(val);
						}
						if (num2 && !flag)
						{
							Helper.AddMessage(args.Context, $"Zone {val.x},{val.y} added to active zones.");
							Configuration.ForceActive.Add(val);
						}
					}
				}
				Configuration.SaveForceActive();
				LimitManager.UpdateLocalLimits();
			}

			internal void <.ctor>b__0_1(ConsoleEventArgs args)
			{
				Dictionary<Vector2i, ZoneData> zones = ZoneSystem.instance.m_zones;
				List<Vector2i> list = new List<Vector2i>();
				list.AddRange(zones.Keys.Where((Vector2i zone) => Configuration.ForceActive.Contains(zone)));
				List<Vector2i> source = list;
				List<Vector2i> list2 = new List<Vector2i>();
				list2.AddRange(zones.Keys.Where((Vector2i zone) => !Configuration.ForceActive.Contains(zone)));
				List<Vector2i> source2 = list2;
				Helper.AddMessage(args.Context, "Forced: " + string.Join(", ", source.Select((Vector2i zone) => $"{zone.x},{zone.y}")));
				Helper.AddMessage(args.Context, "Default: " + string.Join(", ", source2.Select((Vector2i zone) => $"{zone.x},{zone.y}")));
			}

			internal bool <.ctor>b__0_4(Vector2i zone)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return Configuration.ForceActive.Contains(zone);
			}

			internal bool <.ctor>b__0_5(Vector2i zone)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return !Configuration.ForceActive.Contains(zone);
			}

			internal string <.ctor>b__0_2(Vector2i zone)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				return $"{zone.x},{zone.y}";
			}

			internal string <.ctor>b__0_3(Vector2i zone)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				return $"{zone.x},{zone.y}";
			}
		}

		public ForceActiveCommand()
		{
			//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_002f: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate(ConsoleEventArgs args)
				{
					//IL_0039: Unknown result type (might be due to invalid IL or missing references)
					//IL_003e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: Unknown result type (might be due to invalid IL or missing references)
					//IL_0061: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
					//IL_011f: Unknown result type (might be due to invalid IL or missing references)
					//IL_012b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0147: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
					//IL_0160: Unknown result type (might be due to invalid IL or missing references)
					//IL_016c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0188: Unknown result type (might be due to invalid IL or missing references)
					string text = "toggle";
					if (args.Length > 1)
					{
						text = args[1];
					}
					int num = 0;
					if (args.Length > 2 && int.TryParse(args[2], out var result))
					{
						num = result;
					}
					Vector2i zone2 = ZoneSystem.GetZone(ZNet.instance.GetReferencePosition());
					Vector2i val3 = default(Vector2i);
					for (int i = -num; i <= num; i++)
					{
						for (int j = -num; j <= num; j++)
						{
							((Vector2i)(ref val3))..ctor(zone2.x + i, zone2.y + j);
							bool flag = Configuration.ForceActive.Contains(val3);
							bool num2 = text == "add" || (text != "remove" && !flag);
							if (num2 && flag)
							{
								Helper.AddMessage(args.Context, $"Zone {val3.x},{val3.y} is already in active zones.");
							}
							if (!num2 && !flag)
							{
								Helper.AddMessage(args.Context, $"Zone {val3.x},{val3.y} is not in active zones.");
							}
							if (!num2 && flag)
							{
								Helper.AddMessage(args.Context, $"Zone {val3.x},{val3.y} removed from active zones.");
								Configuration.ForceActive.Remove(val3);
							}
							if (num2 && !flag)
							{
								Helper.AddMessage(args.Context, $"Zone {val3.x},{val3.y} added to active zones.");
								Configuration.ForceActive.Add(val3);
							}
						}
					}
					Configuration.SaveForceActive();
					LimitManager.UpdateLocalLimits();
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			Helper.Command("force_active", "[add/remove/toggle] [around=0] - Toggles the force active of the current zone.", (ConsoleEvent)obj);
			object obj2 = <>c.<>9__0_1;
			if (obj2 == null)
			{
				ConsoleEvent val2 = delegate(ConsoleEventArgs args)
				{
					Dictionary<Vector2i, ZoneData> zones = ZoneSystem.instance.m_zones;
					List<Vector2i> list = new List<Vector2i>();
					list.AddRange(zones.Keys.Where((Vector2i zone) => Configuration.ForceActive.Contains(zone)));
					List<Vector2i> source = list;
					List<Vector2i> list2 = new List<Vector2i>();
					list2.AddRange(zones.Keys.Where((Vector2i zone) => !Configuration.ForceActive.Contains(zone)));
					List<Vector2i> source2 = list2;
					Helper.AddMessage(args.Context, "Forced: " + string.Join(", ", source.Select((Vector2i zone) => $"{zone.x},{zone.y}")));
					Helper.AddMessage(args.Context, "Default: " + string.Join(", ", source2.Select((Vector2i zone) => $"{zone.x},{zone.y}")));
				};
				<>c.<>9__0_1 = val2;
				obj2 = (object)val2;
			}
			Helper.Command("check_active", "- Prints currently loaded zones.", (ConsoleEvent)obj2);
		}
	}
	[HarmonyPatch(typeof(SpawnArea), "UpdateSpawn")]
	public class SpawnArea_UpdateSpawn
	{
		private static float GetRange(SpawnArea sa)
		{
			//IL_0019: 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: Unknown result type (might be due to invalid IL or missing references)
			if (Configuration.ForceActive.Count == 0)
			{
				return sa.m_triggerDistance;
			}
			Vector2i zone = ZoneSystem.GetZone(((Component)sa).transform.position);
			if (!Configuration.ForceActive.Contains(zone))
			{
				return sa.m_triggerDistance;
			}
			return 999999f;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_0035: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(SpawnArea), "m_triggerDistance"), (string)null)
			}).Set(OpCodes.Call, (object)AccessTools.Method(typeof(SpawnArea_UpdateSpawn), "GetRange", (Type[])null, (Type[])null)).InstructionEnumeration();
		}
	}
	[HarmonyPatch(typeof(CreatureSpawner), "UpdateSpawner")]
	public class CreatureSpawner_UpdateSpawner
	{
		private static float GetRange(CreatureSpawner cs)
		{
			//IL_0019: 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: Unknown result type (might be due to invalid IL or missing references)
			if (Configuration.ForceActive.Count == 0)
			{
				return cs.m_triggerDistance;
			}
			Vector2i zone = ZoneSystem.GetZone(((Component)cs).transform.position);
			if (!Configuration.ForceActive.Contains(zone))
			{
				return cs.m_triggerDistance;
			}
			return 999999f;
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: 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_0035: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(CreatureSpawner), "m_triggerDistance"), (string)null)
			}).Set(OpCodes.Call, (object)AccessTools.Method(typeof(CreatureSpawner_UpdateSpawner), "GetRange", (Type[])null, (Type[])null)).InstructionEnumeration();
		}
	}
	public class PlayerLimits
	{
		public int ActiveArea = Math.Max(0, activeArea);

		public int LoadedArea = Math.Max(activeArea + 1, loadedArea);

		public int GeneratedArea = Math.Max(0, generatedArea - loadedArea);

		public int TotalArea;

		public HashSet<Vector2i> ForceActive { get; set; }

		public PlayerLimits(int loadedArea, int activeArea, int generatedArea, HashSet<Vector2i> forceActive)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			TotalArea = generatedArea;
			HashSet<Vector2i> hashSet2;
			if (forceActive != null)
			{
				HashSet<Vector2i> hashSet = new HashSet<Vector2i>();
				foreach (Vector2i item in forceActive)
				{
					hashSet.Add(item);
				}
				hashSet2 = hashSet;
			}
			else
			{
				hashSet2 = new HashSet<Vector2i>();
			}
			ForceActive = hashSet2;
			base..ctor();
		}
	}
	public static class LimitManager
	{
		public static string RPC_PLAYERSETTINGS = "RenderLimits_PlayerSettings";

		private static readonly Dictionary<long, PlayerLimits> PlayerLimits = new Dictionary<long, PlayerLimits>();

		private static long CurrentId = 0L;

		private static int MaxTotalArea = 0;

		public static void SetCurrentPlayer(long uid)
		{
			CurrentId = uid;
		}

		public static PlayerLimits GetPlayerLimits(long uid)
		{
			if (!PlayerLimits.ContainsKey(uid))
			{
				PlayerLimits[uid] = new PlayerLimits(1, 2, 4, new HashSet<Vector2i>());
			}
			return PlayerLimits[uid];
		}

		public static void SetPlayerLimits(long uid, int loadedArea, int activeArea, int generatedArea, HashSet<Vector2i> forceActive)
		{
			PlayerLimits[uid] = new PlayerLimits(loadedArea, activeArea, generatedArea, forceActive);
			MaxTotalArea = CalculateMaxTotal();
		}

		public static void RemovePlayer(long uid)
		{
			PlayerLimits.Remove(uid);
			MaxTotalArea = CalculateMaxTotal();
		}

		private static int CalculateMaxTotal()
		{
			return PlayerLimits.Values.Max((PlayerLimits limits) => limits.TotalArea);
		}

		public static int GetMaxTotal()
		{
			return MaxTotalArea;
		}

		public static PlayerLimits GetCurrent()
		{
			return GetPlayerLimits(CurrentId);
		}

		public static PlayerLimits GetLocalLimits()
		{
			return GetPlayerLimits(0L);
		}

		public static void UpdateLocalLimits()
		{
			SetPlayerLimits(0L, Configuration.LoadedArea, Configuration.ActiveArea, Configuration.GeneratedArea, Configuration.ForceActive);
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				SetPlayerLimits(Player.m_localPlayer.GetPlayerID(), Configuration.LoadedArea, Configuration.ActiveArea, Configuration.GeneratedArea, Configuration.ForceActive);
				SendPlayerLimitsToServer();
			}
		}

		private static void SendPlayerLimitsToServer()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.IsServer())
			{
				return;
			}
			ZRpc serverRPC = ZNet.instance.GetServerRPC();
			ZPackage val = new ZPackage();
			val.Write(Configuration.LoadedArea);
			val.Write(Configuration.ActiveArea);
			val.Write(Configuration.GeneratedArea);
			val.Write(Configuration.ForceActive.Count);
			foreach (Vector2i item in Configuration.ForceActive)
			{
				val.Write(item);
			}
			if (serverRPC != null)
			{
				serverRPC.Invoke(RPC_PLAYERSETTINGS, new object[1] { val });
			}
		}

		public static void RPC_PlayerSettings(ZRpc rpc, ZPackage pkg)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (!ZNet.instance.IsServer())
			{
				return;
			}
			ZNetPeer peer = ZNet.instance.GetPeer(rpc);
			int loadedArea = pkg.ReadInt();
			int activeArea = pkg.ReadInt();
			int generatedArea = Math.Min(Configuration.MaximumGeneratedArea, pkg.ReadInt());
			HashSet<Vector2i> hashSet = new HashSet<Vector2i>();
			if (Configuration.AllowForceActive)
			{
				int num = pkg.ReadInt();
				for (int i = 0; i < num; i++)
				{
					hashSet.Add(pkg.ReadVector2i());
				}
			}
			SetPlayerLimits(peer.m_uid, loadedArea, activeArea, generatedArea, hashSet);
		}
	}
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public class ZNet_RPC_PeerInfo_Patch
	{
		private static void Postfix(ZNet __instance, ZRpc rpc)
		{
			if (__instance.GetPeer(rpc).m_uid != 0L)
			{
				if (__instance.IsServer())
				{
					rpc.Register<ZPackage>(LimitManager.RPC_PLAYERSETTINGS, (Action<ZRpc, ZPackage>)LimitManager.RPC_PlayerSettings);
				}
				else
				{
					LimitManager.UpdateLocalLimits();
				}
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public class ZNet_Disconnect
	{
		private static void Postfix(ZNet __instance, ZNetPeer peer)
		{
			if (__instance.IsServer())
			{
				LimitManager.RemovePlayer(peer.m_uid);
			}
		}
	}
	[HarmonyPatch(typeof(SpawnSystem), "GetNrOfInstances", new Type[]
	{
		typeof(GameObject),
		typeof(Vector3),
		typeof(float),
		typeof(bool),
		typeof(bool)
	})]
	public class SpawnLimits
	{
		private static void Prefix(ref Vector3 center, ref float maxRange)
		{
			//IL_001f: 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)
			if (ZoneSystem.instance.m_activeArea != 2 && maxRange == 0f)
			{
				maxRange = 181f;
				if (center == Vector3.zero && Object.op_Implicit((Object)(object)ZNet.instance))
				{
					center.x = ZNet.instance.m_referencePosition.x;
					center.y = ZNet.instance.m_referencePosition.y;
					center.z = ZNet.instance.m_referencePosition.z;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Heightmap), "Initialize")]
	public class TerrainVisibility
	{
		private static void Postfix(Heightmap __instance)
		{
			Set(__instance);
		}

		private static void Set(Heightmap obj)
		{
			Material materialInstance = obj.m_materialInstance;
			int num = Configuration.RealTerrainVisibility;
			if (num == 0)
			{
				num = (int)(((double)Configuration.LoadedArea + 0.8) * 64.0);
			}
			if (Object.op_Implicit((Object)(object)materialInstance))
			{
				materialInstance.SetFloat("_LodHideDistance", (float)num);
			}
		}

		public static void Update()
		{
			Heightmap[] array = Object.FindObjectsByType<Heightmap>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				Set(array[i]);
			}
		}
	}
	[HarmonyPatch(typeof(ZoneSystem))]
	public class ZoneSystemPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void Awake_Postfix(ZoneSystem __instance)
		{
			Set(__instance);
		}

		private static void Set(ZoneSystem obj)
		{
			PlayerLimits localLimits = LimitManager.GetLocalLimits();
			obj.m_activeArea = localLimits.LoadedArea;
			obj.m_activeDistantArea = localLimits.GeneratedArea;
		}

		public static void Update()
		{
			if (Object.op_Implicit((Object)(object)ZoneSystem.instance))
			{
				Set(ZoneSystem.instance);
			}
		}

		[HarmonyPatch("CreateLocalZones")]
		[HarmonyPostfix]
		private static void CreateLocalZones_Postfix(ZoneSystem __instance, ref bool __result)
		{
			//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_002b: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Vector2i> forceActive = LimitManager.GetLocalLimits().ForceActive;
			if (forceActive.Count == 0 || __result)
			{
				return;
			}
			foreach (Vector2i item in forceActive)
			{
				if (__instance.PokeLocalZone(item))
				{
					__result = true;
					break;
				}
			}
		}

		private static int GetTotalArea()
		{
			return LimitManager.GetMaxTotal();
		}

		[HarmonyPatch("CreateGhostZones")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> CreateGhostZones_Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ZoneSystem), "m_activeArea"), (string)null)
			}).SetAndAdvance(OpCodes.Call, (object)AccessTools.Method(typeof(ZoneSystemPatches), "GetTotalArea", (Type[])null, (Type[])null)).SetOpcodeAndAdvance(OpCodes.Nop)
				.SetOpcodeAndAdvance(OpCodes.Nop)
				.SetOpcodeAndAdvance(OpCodes.Nop)
				.SetOpcodeAndAdvance(OpCodes.Nop)
				.InstructionEnumeration();
		}

		[HarmonyPatch("IsActiveAreaLoaded")]
		[HarmonyPostfix]
		private static void IsActiveAreaLoaded_Postfix(ZoneSystem __instance, ref bool __result)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Vector2i> forceActive = LimitManager.GetLocalLimits().ForceActive;
			if (forceActive.Count == 0 || !__result)
			{
				return;
			}
			foreach (Vector2i item in forceActive)
			{
				if (!__instance.m_zones.ContainsKey(item))
				{
					__result = false;
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(ZNetScene))]
	public class ZNetScenePatches
	{
		[HarmonyPatch("InActiveArea", new Type[]
		{
			typeof(Vector2i),
			typeof(Vector2i)
		})]
		[HarmonyPrefix]
		private static bool InActiveArea_Prefix(Vector2i zone, Vector2i refCenterZone, ref bool __result)
		{
			//IL_000c: 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_0027: 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: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			PlayerLimits current = LimitManager.GetCurrent();
			if (current.ForceActive.Contains(zone))
			{
				__result = true;
				return false;
			}
			int activeArea = current.ActiveArea;
			__result = zone.x >= refCenterZone.x - activeArea && zone.x <= refCenterZone.x + activeArea && zone.y <= refCenterZone.y + activeArea && zone.y >= refCenterZone.y - activeArea;
			return false;
		}

		[HarmonyPatch("InActiveArea", new Type[]
		{
			typeof(Vector2i),
			typeof(Vector2i),
			typeof(int)
		})]
		[HarmonyPrefix]
		private static bool InActiveArea2_Prefix(Vector2i zone, Vector2i refCenterZone, ref bool __result)
		{
			//IL_000c: 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_0027: 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: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			PlayerLimits current = LimitManager.GetCurrent();
			if (current.ForceActive.Contains(zone))
			{
				__result = true;
				return false;
			}
			int activeArea = current.ActiveArea;
			__result = zone.x >= refCenterZone.x - activeArea && zone.x <= refCenterZone.x + activeArea && zone.y <= refCenterZone.y + activeArea && zone.y >= refCenterZone.y - activeArea;
			return false;
		}

		[HarmonyPatch("OutsideActiveArea", new Type[]
		{
			typeof(Vector3),
			typeof(Vector3)
		})]
		[HarmonyPrefix]
		private static bool OutsideActiveArea_Prefix(Vector3 point, Vector3 refPoint, ref bool __result)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0018: 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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			PlayerLimits current = LimitManager.GetCurrent();
			int activeArea = current.ActiveArea;
			Vector2i zone = ZoneSystem.GetZone(point);
			if (current.ForceActive.Contains(zone))
			{
				__result = false;
				return false;
			}
			Vector2i zone2 = ZoneSystem.GetZone(refPoint);
			__result = zone.x < zone2.x - activeArea || zone.x > zone2.x + activeArea || zone.y > zone2.y + activeArea || zone.y < zone2.y - activeArea;
			return false;
		}
	}
	[HarmonyPatch(typeof(ZDOMan))]
	public class ZDOManPatches
	{
		[HarmonyPatch("CreateSyncList")]
		[HarmonyPrefix]
		private static void CreateSyncList_Prefix(ZDOPeer peer)
		{
			LimitManager.SetCurrentPlayer(peer.m_peer.m_uid);
		}

		[HarmonyPatch("CreateSyncList")]
		[HarmonyPostfix]
		private static void CreateSyncList_Postfix()
		{
			LimitManager.SetCurrentPlayer(0L);
		}

		[HarmonyPatch("ReleaseNearbyZDOS")]
		[HarmonyPrefix]
		private static void ReleaseNearbyZDOS_Prefix(long uid)
		{
			LimitManager.SetCurrentPlayer(uid);
		}

		[HarmonyPatch("ReleaseNearbyZDOS")]
		[HarmonyPostfix]
		private static void ReleaseNearbyZDOS_Postfix()
		{
			LimitManager.SetCurrentPlayer(0L);
		}

		[HarmonyPatch("FindDistantObjects")]
		[HarmonyPrefix]
		private static bool FindDistantObjects_Prefix(Vector2i sector)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return !LimitManager.GetCurrent().ForceActive.Contains(sector);
		}

		[HarmonyPatch("FindSectorObjects")]
		[HarmonyPrefix]
		private static void FindSectorObjects_Prefix(ref int area, ref int distantArea)
		{
			PlayerLimits current = LimitManager.GetCurrent();
			area = current.LoadedArea;
			if (distantArea != 0)
			{
				distantArea = current.GeneratedArea;
			}
		}

		[HarmonyPatch("FindSectorObjects")]
		[HarmonyPostfix]
		private static void FindSectorObjects_Postfix(ZDOMan __instance, Vector2i sector, int area, List<ZDO> sectorObjects)
		{
			//IL_001f: 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_0025: 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_0066: 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_003b: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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)
			HashSet<Vector2i> forceActive = LimitManager.GetCurrent().ForceActive;
			if (forceActive.Count == 0)
			{
				return;
			}
			foreach (Vector2i item in forceActive)
			{
				if (item.x < sector.x - area || item.x > sector.x + area || item.y > sector.y + area || item.y < sector.y - area)
				{
					__instance.FindObjects(item, sectorObjects);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ZDOPeer))]
	public class ZDOPeerPatches
	{
		[HarmonyPatch("ZDOSectorInvalidated")]
		[HarmonyPrefix]
		private static void CreateSyncList_Prefix(ZDOPeer __instance)
		{
			LimitManager.SetCurrentPlayer(__instance.m_peer.m_uid);
		}

		[HarmonyPatch("ZDOSectorInvalidated")]
		[HarmonyPostfix]
		private static void CreateSyncList_Postfix()
		{
			LimitManager.SetCurrentPlayer(0L);
		}
	}
	[BepInPlugin("render_limits", "Render Limits", "1.14")]
	public class RenderLimits : BaseUnityPlugin
	{
		private const string GUID = "render_limits";

		private const string NAME = "Render Limits";

		private const string VERSION = "1.14";

		public void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Configuration.Init(((BaseUnityPlugin)this).Config);
			new Harmony("render_limits").PatchAll();
		}
	}
	[HarmonyPatch(typeof(GraphicsSettingsManager), "ApplyQualitySettings")]
	public class ApplyQualitySettings
	{
		private static void Postfix()
		{
			Configuration.InitSettings();
		}
	}
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	public class SetCommands
	{
		private static void Postfix()
		{
			new ForceActiveCommand();
		}
	}
}