Decompiled source of Upgrade World v1.74.0

UpgradeWorld.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Service;
using SoftReferenceableAssets;
using Splatform;
using UnityEngine;
using UpgradeWorld;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UpgradeWorld")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+41e9701d225c90f27001218027c5d241d2831bfc")]
[assembly: AssemblyProduct("UpgradeWorld")]
[assembly: AssemblyTitle("UpgradeWorld")]
[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 ComponentInfo
	{
		private static Type[]? types;

		private static readonly Dictionary<string, HashSet<int>> PrefabComponents = new Dictionary<string, HashSet<int>>();

		public static Type[] Types => types ?? (types = LoadTypes());

		private static Type[] LoadTypes()
		{
			List<Assembly> list = new List<Assembly>();
			list.Add(Assembly.GetAssembly(typeof(ZNetView)));
			list.AddRange(from p in Chainloader.PluginInfos.Values
				where (Object)(object)p.Instance != (Object)null
				select ((object)p.Instance).GetType().Assembly);
			List<Assembly> source = list;
			Assembly assembly = Assembly.GetAssembly(typeof(ZNetView));
			Type baseType = typeof(MonoBehaviour);
			List<Type> list2 = new List<Type>();
			list2.AddRange(source.SelectMany(delegate(Assembly s)
			{
				try
				{
					return s.GetTypes();
				}
				catch (ReflectionTypeLoadException ex)
				{
					return ex.Types.Where((Type t) => t != null);
				}
			}).Where(delegate(Type t)
			{
				try
				{
					return baseType.IsAssignableFrom(t);
				}
				catch
				{
					return false;
				}
			}));
			return list2.ToArray();
		}

		public static IEnumerable<KeyValuePair<int, GameObject>> HaveComponent(IEnumerable<KeyValuePair<int, GameObject>> objs, List<string[]> typeSets)
		{
			List<string[]> typeSets2 = typeSets;
			if (PrefabComponents.Count == 0)
			{
				foreach (KeyValuePair<int, GameObject> namedPrefab in ZNetScene.instance.m_namedPrefabs)
				{
					namedPrefab.Value.GetComponentsInChildren<MonoBehaviour>(ZNetView.m_tempComponents);
					foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents)
					{
						string key = ((object)tempComponent).GetType().Name.ToLowerInvariant();
						if (!PrefabComponents.ContainsKey(key))
						{
							PrefabComponents[key] = new HashSet<int>();
						}
						PrefabComponents[key].Add(namedPrefab.Key);
					}
				}
			}
			HashSet<int> value;
			return objs.Where<KeyValuePair<int, GameObject>>((KeyValuePair<int, GameObject> obj) => typeSets2.Any((string[] types) => types.All((string type) => PrefabComponents.TryGetValue(type.ToLowerInvariant(), out value) && value.Contains(obj.Key))));
		}
	}
	public class DataHelper
	{
		public static string GetData(ZDO zdo, string key, string type)
		{
			//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_0036: 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_0059: 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_007c: 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)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			int stableHashCode = StringExtensionMethods.GetStableHashCode(key);
			int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u");
			int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i");
			bool flag = ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode);
			bool flag2 = ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode);
			bool flag3 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode);
			bool flag4 = ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode);
			bool flag5 = ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode);
			bool flag6 = ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode);
			bool flag7 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode3);
			if (flag && (type == "" || type == "vector"))
			{
				return Helper.PrintVectorXZY(ZDOExtraData.s_vec3[uid][stableHashCode]) + " (vector)";
			}
			if (flag2 && (type == "" || type == "quat"))
			{
				return Helper.PrintAngleYXZ(ZDOExtraData.s_quats[uid][stableHashCode]) + " (quat)";
			}
			if (flag3 && (type == "" || type == "long"))
			{
				if (stableHashCode == ZDOVars.s_timeOfDeath)
				{
					return Helper.PrintDay(ZDOExtraData.s_longs[uid][stableHashCode]) + " (long)";
				}
				return ZDOExtraData.s_longs[uid][stableHashCode] + " (long)";
			}
			if (flag4 && (type == "" || type == "string"))
			{
				return ZDOExtraData.s_strings[uid][stableHashCode] + " (string)";
			}
			if (flag5 && (type == "" || type == "int"))
			{
				return ZDOExtraData.s_ints[uid][stableHashCode] + " (int)";
			}
			if (flag6 && (type == "" || type == "float"))
			{
				return ZDOExtraData.s_floats[uid][stableHashCode].ToString("F1") + " (float)";
			}
			if (flag7 && (type == "" || type == "id"))
			{
				return ZDOExtraData.s_longs[uid][stableHashCode2] + "/" + ZDOExtraData.s_longs[uid][stableHashCode3] + " (id)";
			}
			return "No data";
		}

		public static bool SetData(ZDO zdo, string key, string data, string type)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0180: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			int stableHashCode = StringExtensionMethods.GetStableHashCode(key);
			int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u");
			bool flag = ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode);
			bool flag2 = ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode);
			bool flag3 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode);
			bool flag4 = ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode);
			bool flag5 = ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode);
			bool flag6 = ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode);
			bool flag7 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2);
			if (type == "vector" || (type == "" && flag))
			{
				zdo.Set(stableHashCode, Parse.VectorXZY(Parse.Split(data), Vector3.zero));
			}
			else if (type == "quat" || (type == "" && flag2))
			{
				zdo.Set(stableHashCode, Parse.AngleYXZ(data));
			}
			else if (type == "long" || (type == "" && flag3))
			{
				if (stableHashCode == ZDOVars.s_timeOfDeath)
				{
					zdo.Set(stableHashCode, Helper.ToTick(Parse.Long(data, 0L)));
				}
				else
				{
					zdo.Set(stableHashCode, Parse.Long(data, 0L));
				}
			}
			else if (type == "string" || (type == "" && flag4))
			{
				zdo.Set(stableHashCode, data);
			}
			else if (type == "int" || (type == "" && flag5))
			{
				zdo.Set(stableHashCode, Parse.Int(data), false);
			}
			else if (type == "float" || (type == "" && flag6))
			{
				zdo.Set(stableHashCode, Parse.Float(data));
			}
			else
			{
				if (!(type == "id") && !(type == "" && flag7))
				{
					return false;
				}
				string[] array = Parse.Split(data, '/');
				int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i");
				zdo.Set(stableHashCode2, Parse.Long(array[0], 0L));
				zdo.Set(stableHashCode3, Parse.Long(array, 1, 0L));
			}
			return true;
		}

		public static bool HasData(ZDO zdo, string key, string data, bool includeEmpty)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_004a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			int stableHashCode = StringExtensionMethods.GetStableHashCode(key);
			int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u");
			if (ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode))
			{
				return Parse.VectorXZYRange(data, Vector3.zero).Includes(ZDOExtraData.s_vec3[uid][stableHashCode]);
			}
			if (ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode))
			{
				return Parse.AngleYXZ(data) == ZDOExtraData.s_quats[uid][stableHashCode];
			}
			if (ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode))
			{
				if (stableHashCode == ZDOVars.s_timeOfDeath)
				{
					return Parse.LongRange(data, 0L).Includes(Helper.ToDay(ZDOExtraData.s_longs[uid][stableHashCode]));
				}
				return Parse.LongRange(data, 0L).Includes(ZDOExtraData.s_longs[uid][stableHashCode]);
			}
			if (ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode))
			{
				return data == ZDOExtraData.s_strings[uid][stableHashCode];
			}
			if (ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode))
			{
				return Parse.IntRange(data).Includes(ZDOExtraData.s_ints[uid][stableHashCode]);
			}
			if (ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode))
			{
				return Parse.FloatRange(data).Includes(ZDOExtraData.s_floats[uid][stableHashCode]);
			}
			int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i");
			if (ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode3))
			{
				return data == ZDOExtraData.s_longs[uid][stableHashCode2] + "/" + ZDOExtraData.s_longs[uid][stableHashCode3];
			}
			return includeEmpty;
		}
	}
	public static class Hash
	{
		public static int Changed = StringExtensionMethods.GetStableHashCode("override_changed");

		public static int OverrideItems = StringExtensionMethods.GetStableHashCode("override_items");
	}
	public class Range<T> where T : IComparable
	{
		public T Min;

		public T Max;

		public Range(T value)
		{
			Min = value;
			Max = value;
		}

		public Range(T min, T max)
		{
			Min = min;
			Max = max;
		}

		public bool Includes(T value)
		{
			return Min.CompareTo(value) <= 0 && Max.CompareTo(value) >= 0;
		}
	}
	public class Vector3Range
	{
		public Vector3 Min;

		public Vector3 Max;

		public Vector3Range(Vector3 value)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Min = value;
			Max = value;
		}

		public Vector3Range(Vector3 min, Vector3 max)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			Min = min;
			Max = max;
		}

		public bool Includes(Vector3 value)
		{
			return ((Vector3)(ref Min)).sqrMagnitude <= ((Vector3)(ref value)).sqrMagnitude && ((Vector3)(ref value)).sqrMagnitude <= ((Vector3)(ref Max)).sqrMagnitude;
		}
	}
	public static class Parse
	{
		private static readonly HashSet<string> Truthies = new HashSet<string> { "1", "true", "yes", "on" };

		private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "false", "no", "off" };

		private static Range<string> Range(string arg)
		{
			List<string> list = arg.Split(new char[1] { '-' }).ToList();
			if (list.Count > 1 && list[0] == "")
			{
				list[0] = "-" + list[1];
				list.RemoveAt(1);
			}
			if (list.Count > 2 && list[1] == "")
			{
				list[1] = "-" + list[2];
				list.RemoveAt(2);
			}
			if (list.Count == 1)
			{
				return new Range<string>(list[0]);
			}
			return new Range<string>(list[0], list[1]);
		}

		public static int Int(string arg, int defaultValue = 0)
		{
			if (!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		public static int Int(string[] args, int index, int defaultValue = 0)
		{
			if (args.Length <= index)
			{
				return defaultValue;
			}
			return Int(args[index], defaultValue);
		}

		public static Range<int> IntRange(string arg, int defaultValue = 0)
		{
			Range<string> range = Range(arg);
			return new Range<int>(Int(range.Min, defaultValue), Int(range.Max, defaultValue));
		}

		public static Range<int> IntRange(string[] args, int index, int defaultValue = 0)
		{
			if (args.Length <= index)
			{
				return new Range<int>(defaultValue);
			}
			return IntRange(args[index], defaultValue);
		}

		public static uint UInt(string arg, uint defaultValue = 0u)
		{
			if (!uint.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		public static uint UInt(string[] args, int index, uint defaultValue = 0u)
		{
			if (args.Length <= index)
			{
				return defaultValue;
			}
			return UInt(args[index], defaultValue);
		}

		public static Range<uint> UIntRange(string arg, uint defaultValue = 0u)
		{
			Range<string> range = Range(arg);
			return new Range<uint>(UInt(range.Min, defaultValue), UInt(range.Max, defaultValue));
		}

		public static Range<uint> UIntRange(string[] args, int index, uint defaultValue = 0u)
		{
			if (args.Length <= index)
			{
				return new Range<uint>(defaultValue);
			}
			return UIntRange(args[index], defaultValue);
		}

		public static long Long(string arg, long defaultValue = 0L)
		{
			if (!long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		public static long Long(string[] args, int index, long defaultValue = 0L)
		{
			if (args.Length <= index)
			{
				return defaultValue;
			}
			return Long(args[index], defaultValue);
		}

		public static Range<long> LongRange(string arg, long defaultValue = 0L)
		{
			Range<string> range = Range(arg);
			return new Range<long>(Long(range.Min, defaultValue), Long(range.Max, defaultValue));
		}

		public static Range<long> LongRange(string[] args, int index, long defaultValue = 0L)
		{
			if (args.Length <= index)
			{
				return new Range<long>(defaultValue);
			}
			return LongRange(args[index], defaultValue);
		}

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

		public static float Float(string arg, float defaultValue = 0f)
		{
			if (!TryFloat(arg, out var value))
			{
				return defaultValue;
			}
			return value;
		}

		public static float Float(string[] args, int index, float defaultValue = 0f)
		{
			if (args.Length <= index)
			{
				return defaultValue;
			}
			return Float(args[index], defaultValue);
		}

		public static Range<float> FloatRange(string arg, float defaultValue = 0f)
		{
			Range<string> range = Range(arg);
			return new Range<float>(Float(range.Min, defaultValue), Float(range.Max, defaultValue));
		}

		public static Range<float> FloatRange(string[] args, int index, float defaultValue = 0f)
		{
			if (args.Length <= index)
			{
				return new Range<float>(defaultValue);
			}
			return FloatRange(args[index], defaultValue);
		}

		public static string String(string[] args, int index, string defaultValue = "")
		{
			if (args.Length <= index)
			{
				return defaultValue;
			}
			return args[index];
		}

		public static Quaternion AngleYXZ(string arg)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return AngleYXZ(arg, Quaternion.identity);
		}

		public static Quaternion AngleYXZ(string arg, Quaternion defaultValue)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_004a: 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)
			//IL_005f: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			string[] args = Split(arg);
			Vector3 zero = Vector3.zero;
			zero.y = Float(args, 0, ((Quaternion)(ref defaultValue)).eulerAngles.y);
			zero.x = Float(args, 1, ((Quaternion)(ref defaultValue)).eulerAngles.x);
			zero.z = Float(args, 2, ((Quaternion)(ref defaultValue)).eulerAngles.z);
			return Quaternion.Euler(zero);
		}

		public static Vector3 VectorXZY(string[] args)
		{
			//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)
			return VectorXZY(args, 0, Vector3.zero);
		}

		public static Vector3 VectorXZY(string[] args, Vector3 defaultValue)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return VectorXZY(args, 0, defaultValue);
		}

		public static Vector3 VectorXZY(string[] args, int index)
		{
			//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)
			return VectorXZY(args, index, Vector3.zero);
		}

		public static Vector3 VectorXZY(string[] args, int index, Vector3 defaultValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0021: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			Vector3 zero = Vector3.zero;
			zero.x = Float(args, index, defaultValue.x);
			zero.y = Float(args, index + 2, defaultValue.y);
			zero.z = Float(args, index + 1, defaultValue.z);
			return zero;
		}

		public static Vector3Range VectorXZYRange(string arg, Vector3 defaultValue)
		{
			//IL_000c: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			string[] args = Split(arg);
			Range<float> x = FloatRange(args, 0, defaultValue.x);
			Range<float> y = FloatRange(args, 2, defaultValue.y);
			Range<float> z = FloatRange(args, 1, defaultValue.z);
			return ToVectorRange(x, y, z);
		}

		public static Vector3 VectorZXY(string[] args)
		{
			//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)
			return VectorZXY(args, 0, Vector3.zero);
		}

		public static Vector3 VectorZXY(string[] args, Vector3 defaultValue)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return VectorZXY(args, 0, defaultValue);
		}

		public static Vector3 VectorZXY(string[] args, int index)
		{
			//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)
			return VectorZXY(args, index, Vector3.zero);
		}

		public static Vector3 VectorZXY(string[] args, int index, Vector3 defaultValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0023: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			Vector3 zero = Vector3.zero;
			zero.x = Float(args, index + 1, defaultValue.x);
			zero.y = Float(args, index + 2, defaultValue.y);
			zero.z = Float(args, index, defaultValue.z);
			return zero;
		}

		public static Vector3Range VectorZXYRange(string arg, Vector3 defaultValue)
		{
			//IL_000c: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			string[] args = Split(arg);
			Range<float> x = FloatRange(args, 1, defaultValue.x);
			Range<float> y = FloatRange(args, 2, defaultValue.y);
			Range<float> z = FloatRange(args, 0, defaultValue.z);
			return ToVectorRange(x, y, z);
		}

		private static Vector3Range ToVectorRange(Range<float> x, Range<float> y, Range<float> z)
		{
			//IL_0033: 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)
			Vector3 min = default(Vector3);
			((Vector3)(ref min))..ctor(x.Min, y.Min, z.Min);
			Vector3 max = default(Vector3);
			((Vector3)(ref max))..ctor(x.Max, y.Max, z.Max);
			return new Vector3Range(min, max);
		}

		public static Vector3 VectorYXZ(string[] args)
		{
			//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)
			return VectorYXZ(args, 0, Vector3.zero);
		}

		public static Vector3 VectorYXZ(string[] args, Vector3 defaultValue)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return VectorYXZ(args, 0, defaultValue);
		}

		public static Vector3 VectorYXZ(string[] args, int index)
		{
			//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)
			return VectorYXZ(args, index, Vector3.zero);
		}

		public static Vector3 VectorYXZ(string[] args, int index, Vector3 defaultValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0021: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			Vector3 zero = Vector3.zero;
			zero.y = Float(args, index, defaultValue.y);
			zero.x = Float(args, index + 1, defaultValue.x);
			zero.z = Float(args, index + 2, defaultValue.z);
			return zero;
		}

		public static Vector3Range VectorYXZRange(string arg, Vector3 defaultValue)
		{
			//IL_000c: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			string[] args = Split(arg);
			Range<float> x = FloatRange(args, 1, defaultValue.x);
			Range<float> y = FloatRange(args, 0, defaultValue.y);
			Range<float> z = FloatRange(args, 2, defaultValue.z);
			return ToVectorRange(x, y, z);
		}

		public static Vector3 Scale(string[] args)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return Scale(args, 0);
		}

		public static Vector3 Scale(string[] args, int index)
		{
			//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)
			return SanityCheck(VectorXZY(args, index));
		}

		private static Vector3 SanityCheck(Vector3 scale)
		{
			//IL_0001: 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_003c: 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_005a: 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_004f: 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)
			if (scale.x == 0f)
			{
				scale.x = 1f;
			}
			if (scale.y == 0f)
			{
				scale.y = scale.x;
			}
			if (scale.z == 0f)
			{
				scale.z = scale.x;
			}
			return scale;
		}

		public static Vector3Range ScaleRange(string arg)
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			string[] args = Split(arg);
			Range<float> x = FloatRange(args, 0);
			Range<float> y = FloatRange(args, 1);
			Range<float> z = FloatRange(args, 2);
			Vector3Range vector3Range = ToVectorRange(x, y, z);
			vector3Range.Min = SanityCheck(vector3Range.Min);
			vector3Range.Max = SanityCheck(vector3Range.Max);
			return vector3Range;
		}

		public static string[] Split(string arg, char separator = ',')
		{
			List<string> list = new List<string>();
			list.AddRange(from s in arg.Split(new char[1] { separator })
				select s.Trim() into s
				where s != ""
				select s);
			return list.ToArray();
		}

		public static string[] Split(string[] args, int index, char separator)
		{
			return (args.Length <= index) ? Array.Empty<string>() : Split(args[index], separator);
		}

		private static bool IsTruthy(string value)
		{
			return Truthies.Contains(value);
		}

		private static bool IsFalsy(string value)
		{
			return Falsies.Contains(value);
		}

		public static bool? Boolean(string arg)
		{
			if (IsTruthy(arg))
			{
				return true;
			}
			if (IsFalsy(arg))
			{
				return false;
			}
			return null;
		}

		public static IEnumerable<string> Flag(IEnumerable<string> parameters, string flag, out bool value)
		{
			string flag2 = flag;
			value = parameters.FirstOrDefault((string arg) => arg.ToLower() == flag2) != null;
			return parameters.Where((string arg) => arg.ToLower() != flag2);
		}

		public static bool Flag(List<string> parameters, string flag)
		{
			string flag2 = flag;
			string text = parameters.FirstOrDefault((string value) => value.ToLower() == flag2.ToLower());
			if (text == null)
			{
				return false;
			}
			return parameters.Remove(text);
		}

		public static Vector2i Zone(string arg)
		{
			//IL_0011: 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_004b: 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)
			string[] array = Split(arg).ToArray();
			Vector2i result = default(Vector2i);
			if (array.Length != 0)
			{
				result.x = Int(array[0]);
			}
			if (array.Length > 1)
			{
				result.y = Int(array[1]);
			}
			return result;
		}

		public static Vector2 Pos(string arg)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			string[] array = Split(arg).ToArray();
			Vector2 result = default(Vector2);
			if (array.Length != 0)
			{
				result.x = Float(array[0]);
			}
			if (array.Length > 1)
			{
				result.y = Float(array[1]);
			}
			return result;
		}

		public static HashSet<Biome> Biomes(string arg)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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)
			HashSet<Biome> hashSet = new HashSet<Biome>();
			foreach (Biome item in Split(arg).Select(Helper.GetBiome))
			{
				hashSet.Add(item);
			}
			return hashSet;
		}
	}
	public class ZDOData
	{
		public ZDO Zdo;

		public int Prefab = 0;

		public Dictionary<int, string> Strings = new Dictionary<int, string>();

		public Dictionary<int, float> Floats = new Dictionary<int, float>();

		public Dictionary<int, int> Ints = new Dictionary<int, int>();

		public Dictionary<int, long> Longs = new Dictionary<int, long>();

		public Dictionary<int, Vector3> Vecs = new Dictionary<int, Vector3>();

		public Dictionary<int, Quaternion> Quats = new Dictionary<int, Quaternion>();

		public Dictionary<int, byte[]> ByteArrays = new Dictionary<int, byte[]>();

		public ConnectionType ConnectionType = (ConnectionType)0;

		public int ConnectionHash = 0;

		public ZDOID OriginalId = ZDOID.None;

		public ZDOID TargetConnectionId = ZDOID.None;

		public ZDOData(ZDO zdo)
		{
			//IL_0056: 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)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Zdo = zdo;
			Load(zdo);
		}

		public ZDO Clone()
		{
			//IL_000c: 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_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)
			ZDO val = ZDOMan.instance.CreateNewZDO(Zdo.m_position, 0);
			val.Persistent = Zdo.Persistent;
			val.Type = Zdo.Type;
			val.Distant = Zdo.Distant;
			val.m_prefab = Prefab;
			val.m_rotation = Zdo.m_rotation;
			val.SetOwnerInternal(Zdo.GetOwner());
			Write(val);
			return val;
		}

		public ZDO Move(Vector3 pos, Quaternion rot)
		{
			//IL_0006: 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_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)
			ZDO val = ZDOMan.instance.CreateNewZDO(pos, 0);
			val.Persistent = Zdo.Persistent;
			val.Type = Zdo.Type;
			val.Distant = Zdo.Distant;
			val.m_prefab = Prefab;
			val.m_rotation = ((Quaternion)(ref rot)).eulerAngles;
			val.SetOwnerInternal(Zdo.GetOwner());
			Write(val);
			return val;
		}

		private void Write(ZDO zdo)
		{
			//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_001f: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			if (Floats.Count > 0)
			{
				ZDOHelper.Init<float>(ZDOExtraData.s_floats, uid);
			}
			if (Vecs.Count > 0)
			{
				ZDOHelper.Init<Vector3>(ZDOExtraData.s_vec3, uid);
			}
			if (Quats.Count > 0)
			{
				ZDOHelper.Init<Quaternion>(ZDOExtraData.s_quats, uid);
			}
			if (Ints.Count > 0)
			{
				ZDOHelper.Init<int>(ZDOExtraData.s_ints, uid);
			}
			if (Longs.Count > 0)
			{
				ZDOHelper.Init<long>(ZDOExtraData.s_longs, uid);
			}
			if (Strings.Count > 0)
			{
				ZDOHelper.Init<string>(ZDOExtraData.s_strings, uid);
			}
			if (ByteArrays.Count > 0)
			{
				ZDOHelper.Init<byte[]>(ZDOExtraData.s_byteArrays, uid);
			}
			foreach (KeyValuePair<int, float> @float in Floats)
			{
				ZDOExtraData.s_floats[uid].SetValue(@float.Key, @float.Value);
			}
			foreach (KeyValuePair<int, Vector3> vec in Vecs)
			{
				ZDOExtraData.s_vec3[uid].SetValue(vec.Key, vec.Value);
			}
			foreach (KeyValuePair<int, Quaternion> quat in Quats)
			{
				ZDOExtraData.s_quats[uid].SetValue(quat.Key, quat.Value);
			}
			foreach (KeyValuePair<int, int> @int in Ints)
			{
				ZDOExtraData.s_ints[uid].SetValue(@int.Key, @int.Value);
			}
			foreach (KeyValuePair<int, long> @long in Longs)
			{
				ZDOExtraData.s_longs[uid].SetValue(@long.Key, @long.Value);
			}
			foreach (KeyValuePair<int, string> @string in Strings)
			{
				ZDOExtraData.s_strings[uid].SetValue(@string.Key, @string.Value);
			}
			foreach (KeyValuePair<int, byte[]> byteArray in ByteArrays)
			{
				ZDOExtraData.s_byteArrays[uid].SetValue(byteArray.Key, byteArray.Value);
			}
			HandleConnection(zdo);
			HandleHashConnection(zdo);
		}

		private void HandleConnection(ZDO ownZdo)
		{
			//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_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_0022: 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_003c: 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_0058: 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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (OriginalId == ZDOID.None)
			{
				return;
			}
			ZDOID uid = ownZdo.m_uid;
			if (TargetConnectionId != ZDOID.None)
			{
				ZDO zDO = ZDOMan.instance.GetZDO(TargetConnectionId);
				if (zDO != null)
				{
					ownZdo.SetConnection(ConnectionType, TargetConnectionId);
					if ((int)ConnectionType == 1)
					{
						zDO.SetConnection((ConnectionType)1, uid);
					}
				}
				return;
			}
			KeyValuePair<ZDOID, ZDOConnection> keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair<ZDOID, ZDOConnection> kvp) => kvp.Value.m_target == OriginalId);
			if (keyValuePair.Value != null)
			{
				ZDO zDO2 = ZDOMan.instance.GetZDO(keyValuePair.Key);
				if (zDO2 != null)
				{
					zDO2.SetConnection(keyValuePair.Value.m_type, uid);
				}
			}
		}

		private void HandleHashConnection(ZDO ownZdo)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Invalid comparison between Unknown and I4
			//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_0032: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Invalid comparison between Unknown and I4
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Invalid comparison between Unknown and I4
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (ConnectionHash == 0 || (int)ConnectionType == 0)
			{
				return;
			}
			ZDOID uid = ownZdo.m_uid;
			ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash);
			ConnectionType val = (ConnectionType)(ConnectionType ^ 0x10);
			bool flag = (ConnectionType & 0x10) == 0;
			List<ZDOID> allConnectionZDOIDs = ZDOExtraData.GetAllConnectionZDOIDs(val);
			ZDOID val2 = ((IEnumerable<ZDOID>)allConnectionZDOIDs).FirstOrDefault((Func<ZDOID, bool>)((ZDOID z) => ZDOExtraData.GetConnectionHashData(z, ConnectionType)?.m_hash == ConnectionHash));
			if (val2 == ZDOID.None)
			{
				return;
			}
			ZDO zDO = ZDOMan.instance.GetZDO(val2);
			if (zDO != null)
			{
				if ((ConnectionType & 3) > 0)
				{
					ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO));
					ZDOID val4 = (flag ? val2 : uid);
					val3.SetConnection((ConnectionType)3, val4);
				}
				if ((ConnectionType & 2) > 0)
				{
					ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO));
					ZDOID val6 = (flag ? val2 : uid);
					val5.SetConnection((ConnectionType)2, val6);
				}
				if ((ConnectionType & 1) > 0)
				{
					zDO.SetConnection((ConnectionType)1, uid);
					ownZdo.SetConnection((ConnectionType)1, val2);
				}
			}
		}

		private void Load(ZDO zdo)
		{
			//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_001a: 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_0082: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			Prefab = zdo.m_prefab;
			Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, float>>)ZDOExtraData.s_floats[uid]).ToDictionary((KeyValuePair<int, float> kvp) => kvp.Key, (KeyValuePair<int, float> kvp) => kvp.Value) : new Dictionary<int, float>());
			Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, int>>)ZDOExtraData.s_ints[uid]).ToDictionary((KeyValuePair<int, int> kvp) => kvp.Key, (KeyValuePair<int, int> kvp) => kvp.Value) : new Dictionary<int, int>());
			Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, long>>)ZDOExtraData.s_longs[uid]).ToDictionary((KeyValuePair<int, long> kvp) => kvp.Key, (KeyValuePair<int, long> kvp) => kvp.Value) : new Dictionary<int, long>());
			Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, string>>)ZDOExtraData.s_strings[uid]).ToDictionary((KeyValuePair<int, string> kvp) => kvp.Key, (KeyValuePair<int, string> kvp) => kvp.Value) : new Dictionary<int, string>());
			Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Vector3>>)ZDOExtraData.s_vec3[uid]).ToDictionary((KeyValuePair<int, Vector3> kvp) => kvp.Key, (KeyValuePair<int, Vector3> kvp) => kvp.Value) : new Dictionary<int, Vector3>());
			Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Quaternion>>)ZDOExtraData.s_quats[uid]).ToDictionary((KeyValuePair<int, Quaternion> kvp) => kvp.Key, (KeyValuePair<int, Quaternion> kvp) => kvp.Value) : new Dictionary<int, Quaternion>());
			ByteArrays = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, byte[]>>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair<int, byte[]> kvp) => kvp.Key, (KeyValuePair<int, byte[]> kvp) => kvp.Value) : new Dictionary<int, byte[]>());
			if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value))
			{
				ConnectionType = value.m_type;
				ConnectionHash = value.m_hash;
			}
			OriginalId = uid;
			if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None)
			{
				TargetConnectionId = value2.m_target;
				ConnectionType = value2.m_type;
			}
		}
	}
}
namespace UpgradeWorld
{
	public abstract class BaseOperation
	{
		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private bool <pin>P;

		protected int LocationProxyHash;

		protected int LocationHash;

		protected Terminal Context;

		public ZRpc? User;

		private readonly List<Vector3> Pins;

		protected BaseOperation(Terminal context, bool pin = false)
		{
			<pin>P = pin;
			LocationProxyHash = StringExtensionMethods.GetStableHashCode("LocationProxy");
			LocationHash = StringExtensionMethods.GetStableHashCode("location");
			Context = (Terminal)(((object)context) ?? ((object)Console.instance));
			User = ServerExecution.User;
			Pins = new List<Vector3>();
			base..ctor();
		}

		public void Print(string value, bool addDot = true)
		{
			if (addDot && !value.EndsWith("."))
			{
				value += ".";
			}
			Helper.Print(Context, User, value);
		}

		protected void Log(IEnumerable<string> values)
		{
			ZLog.Log((object)("\n" + string.Join("\n", values)));
		}

		protected void Print(IEnumerable<string> values, bool addDot = true)
		{
			foreach (string value in values)
			{
				Print(value, addDot);
			}
		}

		protected void PrintOnce(string value, bool addDot = true)
		{
			if (addDot && !value.EndsWith("."))
			{
				value += ".";
			}
			Helper.PrintOnce(Context, User, value, 10f);
		}

		protected void AddPin(Vector3 pos)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (<pin>P)
			{
				Pins.Add(pos);
			}
		}

		protected void PrintPins()
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			if (!<pin>P)
			{
				return;
			}
			if (User != null)
			{
				User.Invoke(ServerExecution.RPC_Pins, new object[1] { string.Join("|", Pins.Select(Helper.PrintPin)) });
				return;
			}
			List<PinData> findPins = ((Terminal)Console.instance).m_findPins;
			foreach (PinData item in findPins)
			{
				Minimap instance = Minimap.instance;
				if (instance != null)
				{
					instance.RemovePin(item);
				}
			}
			findPins.Clear();
			foreach (Vector3 pin in Pins)
			{
				Minimap instance2 = Minimap.instance;
				PinData val = ((instance2 != null) ? instance2.AddPin(pin, (PinType)3, "", false, false, Player.m_localPlayer.GetPlayerID(), default(PlatformUserID)) : null);
				if (val != null)
				{
					findPins.Add(val);
				}
			}
		}
	}
	public abstract class EntityOperation : BaseOperation
	{
		private static readonly int PlayerHash = StringExtensionMethods.GetStableHashCode("Player");

		private static Dictionary<int, string> HashToName = new Dictionary<int, string>();

		protected EntityOperation(Terminal context, bool pin)
			: base(context, pin)
		{
		}

		protected static string S(int i)
		{
			return (i > 1) ? "s" : "";
		}

		private static bool IsIncluded(string id, string name)
		{
			if (id == "*")
			{
				return true;
			}
			if (id[0] == '*' && id[id.Length - 1] == '*')
			{
				return name.Contains(id.Substring(1, id.Length - 2));
			}
			if (id[0] == '*')
			{
				return name.EndsWith(id.Substring(1), StringComparison.OrdinalIgnoreCase);
			}
			if (id[id.Length - 1] == '*')
			{
				return name.StartsWith(id.Substring(0, id.Length - 1), StringComparison.OrdinalIgnoreCase);
			}
			return id == name;
		}

		public static string GetName(int prefab)
		{
			string value;
			return HashToName.TryGetValue(prefab, out value) ? value : "";
		}

		public static HashSet<int> GetPrefabs(IEnumerable<string> id, List<string[]> types)
		{
			List<string[]> types2 = types;
			if (id.Count() == 0)
			{
				return GetPrefabs("*", types2);
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (int item in id.SelectMany((string id) => GetPrefabs(id, types2)))
			{
				hashSet.Add(item);
			}
			return hashSet;
		}

		public static HashSet<int> GetPrefabs(string id, List<string[]> types)
		{
			string id2 = id;
			if (HashToName.Count == 0)
			{
				HashToName = ZNetScene.instance.m_namedPrefabs.ToDictionary((KeyValuePair<int, GameObject> kvp) => StringExtensionMethods.GetStableHashCode(((Object)kvp.Value).name), (KeyValuePair<int, GameObject> kvp) => ((Object)kvp.Value).name);
			}
			IEnumerable<KeyValuePair<int, GameObject>> source = ZNetScene.instance.m_namedPrefabs.Where((KeyValuePair<int, GameObject> kvp) => kvp.Key != PlayerHash);
			if (!(id2 == "*"))
			{
				source = ((!id2.Contains("*")) ? source.Where((KeyValuePair<int, GameObject> kvp) => string.Equals(((Object)kvp.Value).name, id2, StringComparison.OrdinalIgnoreCase)) : source.Where((KeyValuePair<int, GameObject> kvp) => IsIncluded(id2, ((Object)kvp.Value).name)));
			}
			if (types.Count > 0)
			{
				source = ComponentInfo.HaveComponent(source.ToArray(), types);
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (int item in source.Select((KeyValuePair<int, GameObject> kvp) => kvp.Key))
			{
				hashSet.Add(item);
			}
			return hashSet;
		}

		public static ZDO[] GetZDOs(ZDO[] zdos, int hash)
		{
			List<ZDO> list = new List<ZDO>();
			list.AddRange(zdos.Where((ZDO zdo) => hash == zdo.m_prefab));
			return list.ToArray();
		}

		public static ZDO[] GetZDOs(FiltererParameters args, HashSet<int> prefabs)
		{
			HashSet<int> prefabs2 = prefabs;
			IEnumerable<ZDO> zdos = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => prefabs2.Contains(zdo.m_prefab));
			List<ZDO> list = new List<ZDO>();
			list.AddRange(FilterZdos(zdos, args));
			return list.ToArray();
		}

		public static ZDO[] GetZDOs(DataParameters args, HashSet<int> prefabs)
		{
			HashSet<int> prefabs2 = prefabs;
			IEnumerable<ZDO> zdos = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => prefabs2.Contains(zdo.m_prefab));
			List<ZDO> list = new List<ZDO>();
			list.AddRange(FilterZdos(zdos, args));
			return list.ToArray();
		}

		public static ZDO[] GetZDOs(FiltererParameters args)
		{
			List<ZDO> list = new List<ZDO>();
			list.AddRange(FilterZdos(ZDOMan.instance.m_objectsByID.Values, args));
			return list.ToArray();
		}

		public static ZDO[] GetZDOs(DataParameters args)
		{
			List<ZDO> list = new List<ZDO>();
			list.AddRange(FilterZdos(ZDOMan.instance.m_objectsByID.Values, args));
			return list.ToArray();
		}

		public static ZDO[] GetZDOs(string id)
		{
			return GetZDOs(StringExtensionMethods.GetStableHashCode(id));
		}

		public static ZDO[] GetZDOs(int hash)
		{
			List<ZDO> list = new List<ZDO>();
			list.AddRange(ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => hash == zdo.m_prefab));
			return list.ToArray();
		}

		public static IEnumerable<ZDO> FilterZdos(IEnumerable<ZDO> zdos, DataParameters args)
		{
			return args.LimitZdos(args.FilterZdos(zdos, checkExcludedZones: false));
		}

		public static IEnumerable<ZDO> FilterZdos(IEnumerable<ZDO> zdos, FiltererParameters args)
		{
			return args.LimitZdos(args.FilterZdos(zdos, checkExcludedZones: false));
		}
	}
	public abstract class ExecutedOperation : BaseOperation
	{
		protected int Attempts = 0;

		protected int Failed = 0;

		public bool AutoStart;

		public bool First;

		protected ExecutedOperation(Terminal context, bool autoStart, bool pin = false)
		{
			AutoStart = autoStart;
			First = true;
			base..ctor(context, pin);
		}

		public bool Execute()
		{
			try
			{
				if (First)
				{
					OnStart();
					First = false;
				}
				bool flag = OnExecute();
				Attempts++;
				if (flag)
				{
					PrintPins();
					OnEnd();
				}
				return flag;
			}
			catch (InvalidOperationException ex)
			{
				Helper.Print(Context, User, ex.Message);
				OnEnd();
				return true;
			}
		}

		protected abstract bool OnExecute();

		public void Init()
		{
			string text = OnInit();
			if (text != "")
			{
				Print(text);
			}
		}

		protected abstract string OnInit();

		protected virtual void OnStart()
		{
		}

		protected virtual void OnEnd()
		{
		}
	}
	public abstract class TimeOperation : BaseOperation
	{
		protected TimeOperation(Terminal context)
			: base(context)
		{
		}

		protected void Change(double time)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (time < 0.0)
			{
				Print("Error: New time would be negative.");
				return;
			}
			ZNet instance = ZNet.instance;
			long ticks = instance.GetTime().Ticks;
			instance.SetNetTime(time);
			long num = instance.GetTime().Ticks - ticks;
			int num2 = 0;
			int num3 = 0;
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			IEnumerable<string> timeBasedDataNames = Settings.TimeBasedDataNames;
			HashSet<int> hashSet = timeBasedDataNames.Select((string par) => StringExtensionMethods.GetStableHashCode(par)).ToHashSet();
			foreach (int item in hashSet)
			{
				dictionary.Add(item, 0);
			}
			foreach (ZDO value2 in ZDOMan.instance.m_objectsByID.Values)
			{
				if (!ZDOExtraData.s_longs.TryGetValue(value2.m_uid, out var value))
				{
					continue;
				}
				bool flag = false;
				if (value2.m_prefab == Settings.ZoneControlHash)
				{
					num3++;
					foreach (int item2 in value.Keys.ToList())
					{
						if (value[item2] != 0)
						{
							flag = true;
							num2++;
							value[item2] = (long)time;
						}
					}
				}
				foreach (int item3 in hashSet)
				{
					if (value.ContainsKey(item3) && value[item3] != 0)
					{
						value[item3] = (long)time;
						dictionary[item3]++;
						flag = true;
					}
				}
				if (flag)
				{
					value2.IncreaseDataRevision();
				}
			}
			if (Settings.Verbose)
			{
				Print("Updated " + num2 + " spawn zones in " + num3 + " of zones");
				foreach (string item4 in timeBasedDataNames)
				{
					int stableHashCode = StringExtensionMethods.GetStableHashCode(item4);
					Print("Updated " + dictionary[stableHashCode] + " of " + item4);
				}
			}
			Print("Setting time to " + time.ToString("0") + "s , Day: " + EnvMan.instance.GetDay(time));
		}
	}
	public abstract class ZoneOperation : ExecutedOperation
	{
		public string Operation = "BaseOperation";

		protected Vector2i[] ZonesToUpgrade = Zones.GetZones(args);

		protected int ZonesPerUpdate = 1;

		protected int ZoneIndex = 0;

		protected int PreOperated = 0;

		protected FiltererParameters Args;

		protected List<IZoneFilterer> Filterers;

		protected string InitString;

		protected ZoneOperation(Terminal context, FiltererParameters args)
		{
			Args = args;
			Filterers = new List<IZoneFilterer>();
			InitString = "";
			base..ctor(context, args.Start, args.Pin);
		}

		protected override string OnInit()
		{
			List<string> messages = new List<string>();
			ZonesToUpgrade = Filterers.Aggregate(ZonesToUpgrade, (Vector2i[] zones, IZoneFilterer filterer) => filterer.FilterZones(zones, ref messages));
			InitString += $" {ZonesToUpgrade.Length} zones";
			if (messages.Count > 0)
			{
				InitString = InitString + ": " + Helper.JoinRows(messages);
			}
			InitString += ".";
			return InitString;
		}

		protected abstract bool ExecuteZone(Vector2i zone);

		protected override bool OnExecute()
		{
			//IL_0032: 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_0039: 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)
			if (ZonesToUpgrade == null || ZonesToUpgrade.Length == 0)
			{
				return true;
			}
			for (int i = 0; i < ZonesPerUpdate; i++)
			{
				if (ZoneIndex >= ZonesToUpgrade.Length)
				{
					break;
				}
				Vector2i val = ZonesToUpgrade[ZoneIndex];
				bool flag = ExecuteZone(val);
				if (flag && ZoneSystem.instance.m_zones.TryGetValue(val, out var value))
				{
					value.m_ttl = ZoneSystem.instance.m_zoneTTL;
				}
				MoveToNextZone(flag);
				if (!flag)
				{
					break;
				}
			}
			UpdateConsole();
			return ZoneIndex >= ZonesToUpgrade.Length;
		}

		private void MoveToNextZone(bool success = true)
		{
			if (success)
			{
				Attempts = 0;
				ZoneIndex++;
				return;
			}
			Attempts++;
			if (Attempts > 1000)
			{
				Failed++;
				Attempts = 0;
				ZoneIndex++;
			}
		}

		private void UpdateConsole()
		{
			if (Settings.Verbose)
			{
				string text = (ZonesToUpgrade.Length + PreOperated).ToString();
				string text2 = (ZoneIndex + PreOperated).ToString().PadLeft(text.Length, '0');
				PrintOnce(Operation + ": " + text2 + "/" + text, addDot: false);
			}
			else
			{
				int num = Math.Min(100, (ZonesToUpgrade.Length == 0) ? 100 : ((int)Math.Floor(100.0 * (double)(ZoneIndex + PreOperated) / (double)(ZonesToUpgrade.Length + PreOperated))));
				PrintOnce(Operation + ": " + num + "%", addDot: false);
			}
		}
	}
	public class ChangeTime : TimeOperation
	{
		public ChangeTime(Terminal context, double time)
			: base(context)
		{
			Change(ZNet.instance.GetTimeSeconds() + time);
		}
	}
	public class CountBiomes : BaseOperation
	{
		public CountBiomes(Terminal context, float frequency, FiltererParameters args)
			: base(context)
		{
			Count(frequency, args);
		}

		private void Count(float frequency, FiltererParameters args)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (!args.Pos.HasValue)
			{
				return;
			}
			if (args.MaxDistance == 0f)
			{
				args.MaxDistance = Settings.WorldRadius;
			}
			Dictionary<Biome, int> dictionary = new Dictionary<Biome, int>();
			float num = (0f - (float)Math.Ceiling(args.MaxDistance / frequency)) * frequency;
			for (float num2 = num; num2 <= args.MaxDistance; num2 += frequency)
			{
				for (float num3 = num; num3 <= args.MaxDistance; num3 += frequency)
				{
					Vector2 val = new Vector2(num2, num3);
					float magnitude = ((Vector2)(ref val)).magnitude;
					if (magnitude < args.MinDistance || magnitude > args.MaxDistance)
					{
						continue;
					}
					Biome biome = WorldGenerator.instance.GetBiome(args.Pos.Value.x + num2, args.Pos.Value.y + num3, 0.02f, false);
					if (args.IsBiomeValid(biome))
					{
						if (!dictionary.ContainsKey(biome))
						{
							dictionary[biome] = 0;
						}
						dictionary[biome]++;
					}
				}
			}
			float total = dictionary.Values.Sum();
			IEnumerable<string> values = from kvp in dictionary
				orderby Enum.GetName(typeof(Biome), kvp.Key)
				select Enum.GetName(typeof(Biome), kvp.Key) + ": " + kvp.Value + "/" + total + " (" + ((float)kvp.Value / total).ToString("P2", CultureInfo.InvariantCulture) + ")";
			Print(string.Join("\n", values));
		}
	}
	public class Generate : ZoneOperation
	{
		private bool Empty = false;

		public Generate(Terminal context, FiltererParameters args, bool empty)
			: base(context, args)
		{
			Operation = "Generate";
			InitString = args.Print("Generate");
			Filterers = FiltererFactory.Create(args);
			if (empty)
			{
				ZonesPerUpdate = 100000;
			}
			Empty = empty;
		}

		protected override bool ExecuteZone(Vector2i zone)
		{
			//IL_0024: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			if (Empty)
			{
				instance.m_generatedZones.Add(zone);
				return true;
			}
			if (instance.IsZoneGenerated(zone))
			{
				return true;
			}
			GameObject val = default(GameObject);
			return instance.SpawnZone(zone, (SpawnMode)2, ref val);
		}

		protected override void OnEnd()
		{
			int num = ZonesToUpgrade.Length - Failed;
			string text = Operation + " completed. " + num + " zones generated.";
			if (Failed > 0)
			{
				text = text + " " + Failed + " errors.";
			}
			Print(text);
		}
	}
	public class DistributeLocations : ExecutedOperation
	{
		private readonly string[] Ids = Array.Empty<string>();

		public float Chance = 1f;

		public int Added = 0;

		private int Total = 0;

		public static bool SpawnToAlreadyGenerated = false;

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

		private readonly Dictionary<string, int> Counts = new Dictionary<string, int>();

		public DistributeLocations(Terminal context, HashSet<string> ids, FiltererParameters args)
		{
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			HashSet<string> ids2 = ids;
			FiltererParameters args2 = args;
			base..ctor(context, args2.Start);
			List<string> list = new List<string>();
			list.AddRange(from loc in ZoneSystem.instance.m_locations.Where(Helper.IsValid)
				where ids2.Contains(loc.m_prefab.Name)
				where loc.m_enable && loc.m_quantity != 0
				where (loc.m_biome & args2.BiomeMask) > 0
				orderby loc.m_prioritized descending
				select loc.m_prefab.Name);
			Ids = list.ToArray();
			if (Ids.Length == 0)
			{
				Print("Error: No valid location ids.");
				return;
			}
			Chance = args2.Chance;
			args2 = new FiltererParameters(args2)
			{
				TargetZones = TargetZones.All
			};
			List<IZoneFilterer> source = FiltererFactory.Create(args2);
			List<string> messages = new List<string>();
			HashSet<Vector2i> hashSet = new HashSet<Vector2i>();
			foreach (Vector2i item in source.Aggregate(Zones.GetZones(args2), (Vector2i[] zones, IZoneFilterer filterer) => filterer.FilterZones(zones, ref messages)).Distinct())
			{
				hashSet.Add(item);
			}
			AllowedZones = hashSet;
		}

		protected override bool OnExecute()
		{
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			if (Attempts == 0)
			{
				LoadingIndicator.SetProgressVisibility(true);
				if (Ids.Length == 0)
				{
					Print("No locations to generate.");
					return true;
				}
				Print("Generating locations " + Ids[Attempts] + ". This may take a while...");
				ClearNotSpawned(Ids);
				return false;
			}
			if (Attempts <= Ids.Length)
			{
				SpawnToAlreadyGenerated = true;
				ZoneSystem instance = ZoneSystem.instance;
				string id = Ids[Attempts - 1];
				ZoneLocation[] array = instance.m_locations.Where((ZoneLocation location) => Helper.IsValid(location) && location.m_prefab.Name == id).ToArray();
				if (array.Length == 0)
				{
					return false;
				}
				if (Attempts < Ids.Length)
				{
					Print("Generating locations " + Ids[Attempts] + ". This may take a while...");
				}
				int value;
				int num = (Counts.TryGetValue(id, out value) ? value : 0);
				ZoneLocation[] array2 = array;
				foreach (ZoneLocation location2 in array2)
				{
					GenerateLocations(location2);
				}
				if (Chance < 1f)
				{
					instance.m_locationInstances = instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_placed || kvp.Value.m_location.m_prefab.Name != id || FiltererParameters.random.NextDouble() < (double)Chance).ToDictionary((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Key, (KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value);
				}
				List<KeyValuePair<Vector2i, LocationInstance>> list = instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_location.m_prefab.Name == id && !kvp.Value.m_placed).ToList();
				foreach (KeyValuePair<Vector2i, LocationInstance> item in list)
				{
					AddPin(item.Value.m_position);
				}
				Total += Count(id);
				Added += Total - num;
				SpawnToAlreadyGenerated = false;
				LoadingIndicator.SetProgress((float)Attempts / (float)Ids.Length);
				return false;
			}
			LoadingIndicator.SetProgressVisibility(false);
			return true;
		}

		private void ClearNotSpawned(string[] ids)
		{
			Counts.Clear();
			foreach (string text in ids)
			{
				Counts[text] = Count(text);
			}
			ZoneSystem instance = ZoneSystem.instance;
			instance.m_locationInstances = instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_placed || !Counts.ContainsKey(kvp.Value.m_location.m_prefab.Name)).ToDictionary((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Key, (KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value);
			DummyClearNonPlacedLocations.Skip = true;
			instance.ClearNonPlacedLocations();
			DummyClearNonPlacedLocations.Skip = false;
		}

		private int Count(string id)
		{
			string id2 = id;
			ZoneSystem instance = ZoneSystem.instance;
			return instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_location.m_prefab.Name == id2).Count();
		}

		protected override void OnEnd()
		{
			if (Added >= 0)
			{
				Print($"{Added} locations{LocationOperation.IdString(Ids)} added to the world (total amount in the world: {Total}).");
			}
			else
			{
				Print($"{Math.Abs(Added)} locations{LocationOperation.IdString(Ids)} removed from the world (total amount in the world: {Total}).");
			}
		}

		protected override string OnInit()
		{
			return "Generate locations" + LocationOperation.IdString(Ids) + ".";
		}

		private void GenerateLocations(ZoneLocation location)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Invalid comparison between Unknown and I4
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Invalid comparison between Unknown and I4
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			int num = WorldGenerator.instance.GetSeed() + StringExtensionMethods.GetStableHashCode(location.m_prefab.Name);
			State state = Random.state;
			Random.InitState(num);
			float num2 = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius);
			int num3 = (location.m_prioritized ? 200000 : 100000);
			int num4 = instance.CountNrOfLocation(location);
			if (location.m_unique && num4 > 0)
			{
				return;
			}
			float num5 = Settings.WorldRadius - Settings.WorldEdge;
			if (location.m_centerFirst)
			{
				num5 = location.m_minDistance;
			}
			instance.s_tempVeg.Clear();
			int num6 = 0;
			Color val = default(Color);
			float num8 = default(float);
			Vector3 val2 = default(Vector3);
			Color val4 = default(Color);
			while (num6 < num3 && num4 < location.m_quantity)
			{
				num6++;
				Vector2i randomZone = ZoneSystem.GetRandomZone(num5);
				if (location.m_centerFirst)
				{
					num5 += 1f;
				}
				if (instance.m_locationInstances.ContainsKey(randomZone) || instance.IsZoneGenerated(randomZone))
				{
					continue;
				}
				Vector3 zonePos = ZoneSystem.GetZonePos(randomZone);
				BiomeArea biomeArea = WorldGenerator.instance.GetBiomeArea(zonePos);
				if ((location.m_biomeArea & biomeArea) == 0)
				{
					continue;
				}
				for (int i = 0; i < 20; i++)
				{
					Vector3 randomPointInZone = ZoneSystem.GetRandomPointInZone(randomZone, num2);
					float magnitude = ((Vector3)(ref randomPointInZone)).magnitude;
					if ((location.m_minDistance != 0f && magnitude < location.m_minDistance) || (location.m_maxDistance != 0f && magnitude > location.m_maxDistance))
					{
						continue;
					}
					Biome biome = WorldGenerator.instance.GetBiome(randomPointInZone);
					if ((location.m_biome & biome) == 0)
					{
						continue;
					}
					randomPointInZone.y = WorldGenerator.instance.GetHeight(randomPointInZone.x, randomPointInZone.z, ref val);
					float num7 = (float)((double)randomPointInZone.y - 30.0);
					if (num7 < location.m_minAltitude || num7 > location.m_maxAltitude)
					{
						continue;
					}
					if (location.m_inForest)
					{
						float forestFactor = WorldGenerator.GetForestFactor(randomPointInZone);
						if (forestFactor < location.m_forestTresholdMin || forestFactor > location.m_forestTresholdMax)
						{
							continue;
						}
					}
					WorldGenerator.instance.GetTerrainDelta(randomPointInZone, location.m_exteriorRadius, ref num8, ref val2);
					if (num8 > location.m_maxTerrainDelta || num8 < location.m_minTerrainDelta || (location.m_minDistanceFromSimilar > 0f && instance.HaveLocationInRange(location.m_prefab.Name, location.m_group, randomPointInZone, location.m_minDistanceFromSimilar, false)) || (location.m_maxDistanceFromSimilar > 0f && !instance.HaveLocationInRange(location.m_prefabName, location.m_groupMax, randomPointInZone, location.m_maxDistanceFromSimilar, true)))
					{
						continue;
					}
					float a = val.a;
					if ((location.m_minimumVegetation > 0f && a <= location.m_minimumVegetation) || (location.m_maximumVegetation < 1f && a >= location.m_maximumVegetation))
					{
						continue;
					}
					if (location.m_surroundCheckVegetation)
					{
						float num9 = 0f;
						for (int j = 0; j < location.m_surroundCheckLayers; j++)
						{
							float num10 = (float)(j + 1) / (float)location.m_surroundCheckLayers * location.m_surroundCheckDistance;
							for (int k = 0; k < 6; k++)
							{
								float num11 = (float)k / 6f * (float)Math.PI * 2f;
								Vector3 val3 = randomPointInZone + new Vector3(Mathf.Sin(num11) * num10, 0f, Mathf.Cos(num11) * num10);
								WorldGenerator.instance.GetHeight(val3.x, val3.z, ref val4);
								float num12 = (location.m_surroundCheckDistance - num10) / (location.m_surroundCheckDistance * 2f);
								num9 += val4.a * num12;
							}
						}
						instance.s_tempVeg.Add(num9);
						if (instance.s_tempVeg.Count < 10)
						{
							continue;
						}
						float num13 = instance.s_tempVeg.Max();
						float num14 = instance.s_tempVeg.Average();
						float num15 = num14 + (num13 - num14) * location.m_surroundBetterThanAverage;
						if (num9 < num15)
						{
							continue;
						}
					}
					instance.RegisterLocation(location, randomPointInZone, false);
					num4++;
					break;
				}
			}
			Random.state = state;
		}
	}
	[HarmonyPatch(typeof(ZoneSystem), "ClearNonPlacedLocations")]
	public class DummyClearNonPlacedLocations
	{
		public static bool Skip;

		private static bool Prefix()
		{
			return !Skip;
		}
	}
	public class FixLocations : BaseOperation
	{
		private int Fixed = 0;

		public FixLocations(Terminal context, FiltererParameters args)
			: base(context, args.Pin)
		{
			Execute();
		}

		private void Execute()
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ZDOID, ZDO>.ValueCollection values = ZDOMan.instance.m_objectsByID.Values;
			foreach (ZDO item in values)
			{
				if (item.m_prefab != LocationProxyHash)
				{
					continue;
				}
				int @int = item.GetInt(ZDOVars.s_location, 0);
				ZoneLocation location = ZoneSystem.instance.GetLocation(@int);
				if (location == null || !Helper.IsValid(location))
				{
					continue;
				}
				Vector2i zone = ZoneSystem.GetZone(item.m_position);
				if (!ZoneSystem.instance.m_locationInstances.ContainsKey(zone))
				{
					ZoneSystem.instance.m_locationInstances[zone] = new LocationInstance
					{
						m_location = location,
						m_position = item.m_position,
						m_placed = true
					};
					Fixed++;
					AddPin(item.m_position);
					if (Settings.Verbose)
					{
						Print($"Fixed location {location.m_prefabName} at {zone}");
					}
				}
			}
			Print($"{Fixed} locations fixed.");
			PrintPins();
		}
	}
	public class ListLocationPositions : EntityOperation
	{
		public ListLocationPositions(Terminal context, HashSet<string> ids, bool log, FiltererParameters args)
			: base(context, args.Pin)
		{
			ListPositions(ids, log, args);
		}

		private void ListPositions(HashSet<string> ids, bool log, FiltererParameters args)
		{
			//IL_004f: 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_0057: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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)
			HashSet<string> ids2 = ids;
			ZoneSystem instance = ZoneSystem.instance;
			List<string> list = new List<string>();
			List<LocationInstance> list2 = (from l in args.FilterLocations(instance.m_locationInstances.Values)
				where ids2.Count() == 0 || ids2.Contains(l.m_location?.m_prefab.Name ?? "")
				select l).ToList();
			foreach (LocationInstance item in list2)
			{
				ZoneLocation location = item.m_location;
				string name = location.m_prefab.Name;
				list.Add($"{name}: {Helper.PrintVectorXZY(item.m_position)} {WorldGenerator.instance.GetBiome(item.m_position)}");
				AddPin(item.m_position);
			}
			if (log)
			{
				Log(list);
			}
			else
			{
				Print(list, addDot: false);
			}
			PrintPins();
		}
	}
	public abstract class LocationOperation : ZoneOperation
	{
		protected int Operated = 0;

		protected string Verb = "";

		private static readonly Dictionary<string, Func<int, List<string>?>> Named = CreateNamed();

		private static readonly List<string> Parameters;

		private static readonly Func<int, List<string>> AutoComplete;

		public LocationOperation(Terminal context, FiltererParameters args)
			: base(context, args)
		{
			args.TargetZones = TargetZones.Generated;
			Filterers = FiltererFactory.Create(args);
		}

		protected override bool ExecuteZone(Vector2i zone)
		{
			//IL_000f: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			Dictionary<Vector2i, LocationInstance> locationInstances = instance.m_locationInstances;
			if (!locationInstances.TryGetValue(zone, out var value))
			{
				return true;
			}
			if (instance.IsZoneLoaded(zone))
			{
				if (ExecuteLocation(zone, value))
				{
					Operated++;
				}
				Zones.ReleaseZone(zone);
				return true;
			}
			Zones.PokeZone(zone);
			return false;
		}

		protected abstract bool ExecuteLocation(Vector2i zone, LocationInstance location);

		protected override void OnEnd()
		{
			string text = $"{Operation} completed. {Operated} locations {Verb}.";
			if (Failed > 0)
			{
				text = text + " " + Failed + " errors.";
			}
			Print(text);
		}

		protected void SpawnLocation(Vector2i zone, LocationInstance location, float clearRadius)
		{
			//IL_000d: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0028: 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)
			//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_0083: 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)
			ZoneSystem instance = ZoneSystem.instance;
			GameObject root = instance.m_zones[zone].m_root;
			Vector3 zonePos = ZoneSystem.GetZonePos(zone);
			Heightmap heightmap = Zones.GetHeightmap(root);
			Helper.ClearAreaForLocation(zone, location, clearRadius);
			float radius = ((Args.TerrainReset == 0f) ? location.m_location.m_exteriorRadius : Args.TerrainReset);
			ResetTerrain.Execute(location.m_position, radius);
			instance.m_tempSpawnedObjects.Clear();
			instance.m_tempClearAreas.Clear();
			instance.PlaceLocations(zone, zonePos, root.transform, heightmap, instance.m_tempClearAreas, (SpawnMode)2, instance.m_tempSpawnedObjects);
			foreach (GameObject tempSpawnedObject in instance.m_tempSpawnedObjects)
			{
				Object.Destroy((Object)(object)tempSpawnedObject);
			}
			instance.m_tempSpawnedObjects.Clear();
		}

		public static HashSet<string> Ids(List<string> ids, List<string> ignore)
		{
			List<string> ids2 = ids;
			List<string> ignore2 = ignore;
			HashSet<string> hashSet = new HashSet<string>();
			foreach (string item in from id in AllIds()
				where (ids2.Count == 0 || ids2.Contains(id)) && (ignore2.Count == 0 || !ignore2.Contains(id))
				select id)
			{
				hashSet.Add(item);
			}
			return hashSet;
		}

		public static List<string> AllIds()
		{
			List<string> list = new List<string>();
			list.AddRange((from location in ZoneSystem.instance.m_locations.Where(Helper.IsValid)
				select location.m_prefab.Name).Distinct());
			return list;
		}

		public static string IdString(IEnumerable<string> ids)
		{
			if (ids.Count() == AllIds().Count)
			{
				return "";
			}
			if (ids.Count() == 0)
			{
				return "";
			}
			return " " + Helper.JoinRows(ids);
		}

		public static void Register(string name)
		{
			CommandWrapper.Register(name, AutoComplete, Named);
		}

		private static Dictionary<string, Func<int, List<string>?>> CreateNamed()
		{
			Dictionary<string, Func<int, List<string>>> autoComplete = FiltererParameters.GetAutoComplete();
			autoComplete["id"] = (int index) => AllIds();
			autoComplete["ignore"] = (int index) => AllIds();
			return autoComplete;
		}

		static LocationOperation()
		{
			List<string> list = new List<string>();
			list.AddRange(from x in FiltererParameters.Parameters.Concat(new <>z__ReadOnlyArray<string>(new string[2] { "id", "ignore" }))
				orderby x
				select x);
			Parameters = list;
			AutoComplete = (int index) => (index == 0) ? AllIds() : Parameters;
		}
	}
	public class RegisterLocation : BaseOperation
	{
		public RegisterLocation(Terminal context, string id, Vector3 position)
			: base(context)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Register(id, position);
		}

		private void Register(string id, Vector3 position)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			int stableHashCode = StringExtensionMethods.GetStableHashCode(id);
			ZoneSystem instance = ZoneSystem.instance;
			if (!instance.m_locationsByHash.TryGetValue(stableHashCode, out var value))
			{
				throw new InvalidOperationException("Location " + id + " not found.");
			}
			Vector2i zone = ZoneSystem.GetZone(position);
			int num = ZDOMan.instance.SectorToIndex(zone);
			List<ZDO> list = ZDOMan.instance.m_objectsBySector[num];
			if (list != null)
			{
				foreach (ZDO item in list)
				{
					if (item.m_prefab != LocationProxyHash || item.GetInt(LocationHash, 0) != stableHashCode)
					{
						continue;
					}
					position = item.GetPosition();
					Print("Using position " + Helper.PrintVectorXZY(position) + " of already existing location.");
					break;
				}
			}
			instance.m_locationInstances.Remove(zone);
			instance.RegisterLocation(value, position, instance.IsZoneGenerated(zone));
			AddPin(position);
			Print("Location " + id + " registered to " + Helper.PrintVectorXZY(position) + ".");
			Print("To actually spawn the registered locations, reset the zone or spawn them manually.");
		}
	}
	public class RemoveLocations : ExecutedOperation
	{
		private readonly HashSet<string> Ids;

		private readonly FiltererParameters Args;

		public RemoveLocations(Terminal context, HashSet<string> ids, FiltererParameters args)
			: base(context, args.Start)
		{
			Args = new FiltererParameters(args)
			{
				TargetZones = TargetZones.All
			};
			Ids = ids;
			if (Ids.Count == 0)
			{
				Print("Error: No valid location ids.");
			}
		}

		protected override void OnStart()
		{
			if (Args.SafeZones != 0)
			{
				PlayerBaseFilterer playerBaseFilterer = new PlayerBaseFilterer(Args.SafeZones);
				playerBaseFilterer.CalculateExcluded();
			}
		}

		private int RemoveSpawned()
		{
			//IL_0052: 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)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			IEnumerable<ZDO> zdos = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => LocationProxyHash == zdo.m_prefab);
			zdos = Args.FilterZdos(zdos, checkExcludedZones: true);
			int num = 0;
			foreach (ZDO item in zdos)
			{
				Vector2i zone = ZoneSystem.GetZone(item.GetPosition());
				string text = "???";
				if (instance.m_locationsByHash.TryGetValue(item.GetInt(LocationHash, 0), out var value))
				{
					text = value.m_prefab.Name;
					if (!Ids.Contains(text))
					{
						continue;
					}
					float distance = value.m_exteriorRadius;
					if (Args.ObjectReset.HasValue)
					{
						distance = Args.ObjectReset.Value;
					}
					AddPin(item.GetPosition());
					Helper.ClearZDOsWithinDistance(zone, item.GetPosition(), distance);
				}
				Helper.RemoveZDO(item);
				num++;
				instance.m_locationInstances.Remove(zone);
				if (Settings.Verbose)
				{
					Print($"Location {text} removed at {zone}.");
				}
			}
			List<KeyValuePair<Vector2i, LocationInstance>> list = instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => Args.FilterPosition(kvp.Value.m_position, checkExcludedZones: true)).ToList();
			foreach (KeyValuePair<Vector2i, LocationInstance> item2 in list)
			{
				if (!Args.Roll())
				{
					continue;
				}
				Vector2i key = item2.Key;
				ZoneLocation location = item2.Value.m_location;
				string name = location.m_prefab.Name;
				if (Ids.Count <= 0 || Ids.Contains(name))
				{
					float distance2 = location.m_exteriorRadius;
					if (Args.ObjectReset.HasValue)
					{
						distance2 = Args.ObjectReset.Value;
					}
					Helper.ClearZDOsWithinDistance(key, item2.Value.m_position, distance2);
					AddPin(item2.Value.m_position);
					float radius = ((Args.TerrainReset == 0f) ? location.m_exteriorRadius : Args.TerrainReset);
					ResetTerrain.Execute(item2.Value.m_position, radius);
					num++;
					instance.m_locationInstances.Remove(key);
					if (Settings.Verbose)
					{
						Print($