Decompiled source of Upgrade World v1.62.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 UnityEngine;
using UpgradeWorld;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UpgradeWorld")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e9b5709539f4bec33304731c9602dbdaa810c9a6")]
[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);
			Assembly.GetAssembly(typeof(ZNetView));
			Type baseType = typeof(MonoBehaviour);
			return list.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;
				}
			}).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_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: 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_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: 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 num = ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode);
			bool flag = ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode);
			bool flag2 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode);
			bool flag3 = ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode);
			bool flag4 = ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode);
			bool flag5 = ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode);
			bool flag6 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode3);
			if (num && (type == "" || type == "vector"))
			{
				return Helper.PrintVectorXZY(ZDOExtraData.s_vec3[uid][stableHashCode]) + " (vector)";
			}
			if (flag && (type == "" || type == "quat"))
			{
				return Helper.PrintAngleYXZ(ZDOExtraData.s_quats[uid][stableHashCode]) + " (quat)";
			}
			if (flag2 && (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 (flag3 && (type == "" || type == "string"))
			{
				return ZDOExtraData.s_strings[uid][stableHashCode] + " (string)";
			}
			if (flag4 && (type == "" || type == "int"))
			{
				return ZDOExtraData.s_ints[uid][stableHashCode] + " (int)";
			}
			if (flag5 && (type == "" || type == "float"))
			{
				return ZDOExtraData.s_floats[uid][stableHashCode].ToString("F1") + " (float)";
			}
			if (flag6 && (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_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_0024: 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_0046: 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_0069: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0139: 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_016d: 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.Replace('_', ' '));
			}
			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_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_0024: 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_0069: 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_0052: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: 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)
			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.Replace('_', ' ') == 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)
		{
			if (Min.CompareTo(value) <= 0)
			{
				return Max.CompareTo(value) >= 0;
			}
			return false;
		}
	}
	public class Vector3Range
	{
		public Vector3 Min;

		public Vector3 Max;

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

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

		public bool Includes(Vector3 value)
		{
			if (((Vector3)(ref Min)).sqrMagnitude <= ((Vector3)(ref value)).sqrMagnitude)
			{
				return ((Vector3)(ref value)).sqrMagnitude <= ((Vector3)(ref Max)).sqrMagnitude;
			}
			return false;
		}
	}
	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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			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_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0020: 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_0046: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			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_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			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_0012: 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)
			Vector3 min = new Vector3(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_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0020: 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_0046: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			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_0000: 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_0033: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			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_0038: 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_0042: 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_004e: 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)
			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 = ',')
		{
			return (from s in arg.Split(new char[1] { separator })
				select s.Trim() into s
				where s != ""
				select s).ToArray();
		}

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

		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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0010: 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)
			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)
		{
			return Split(arg).Select(Helper.GetBiome).ToHashSet();
		}
	}
	public class ZDOData
	{
		public ZDO Zdo;

		public int Prefab;

		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;

		public int ConnectionHash;

		public ZDOID OriginalId = ZDOID.None;

		public ZDOID TargetConnectionId = ZDOID.None;

		public ZDOData(ZDO zdo)
		{
			//IL_004e: 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_0059: 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)
			Zdo = zdo;
			Load(zdo);
		}

		public ZDO Clone()
		{
			//IL_000b: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0005: 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_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)
			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_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_001a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00d1: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: 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_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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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 (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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0019: 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_002c: 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_0035: 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: Invalid comparison between Unknown and I4
			//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_0058: 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_006b: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Invalid comparison between Unknown and I4
			//IL_009e: 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: Invalid comparison between Unknown and I4
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Invalid comparison between Unknown and I4
			//IL_00d1: 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_0090: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			if (ConnectionHash == 0 || (int)ConnectionType == 0)
			{
				return;
			}
			ZDOID uid = ownZdo.m_uid;
			ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash);
			? val = ConnectionType ^ 0x10;
			bool flag = (ConnectionType & 0x10) == 0;
			ZDOID val2 = ((IEnumerable<ZDOID>)ZDOExtraData.GetAllConnectionZDOIDs((ConnectionType)val)).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_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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: 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_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: 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]
		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_000e: Unknown result type (might be due to invalid IL or missing references)
			if (<pin>P)
			{
				Pins.Add(pos);
			}
		}

		protected void PrintPins()
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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(), "") : 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)
		{
			if (i <= 1)
			{
				return "";
			}
			return "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)
		{
			if (!HashToName.TryGetValue(prefab, out string value))
			{
				return "";
			}
			return value;
		}

		public static HashSet<int> GetPrefabs(IEnumerable<string> id, List<string[]> types)
		{
			List<string[]> types2 = types;
			if (id.Count() != 0)
			{
				return id.SelectMany((string id) => GetPrefabs(id, types2)).ToHashSet();
			}
			return GetPrefabs("*", types2);
		}

		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);
			}
			return source.Select((KeyValuePair<int, GameObject> kvp) => kvp.Key).ToHashSet();
		}

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

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

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

		public static ZDO[] GetZDOs(FiltererParameters args)
		{
			return FilterZdos(ZDOMan.instance.m_objectsByID.Values, args).ToArray();
		}

		public static ZDO[] GetZDOs(DataParameters args)
		{
			return FilterZdos(ZDOMan.instance.m_objectsByID.Values, args).ToArray();
		}

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

		public static ZDO[] GetZDOs(int hash)
		{
			return ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => hash == zdo.m_prefab).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;

		protected int Failed;

		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 num = OnExecute();
				Attempts++;
				if (num)
				{
					PrintPins();
					OnEnd();
				}
				return num;
			}
			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_00e3: 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);
			_ = instance.GetTime().Ticks;
			int num = 0;
			int num2 = 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)
				{
					num2++;
					foreach (int item2 in value.Keys.ToList())
					{
						if (value[item2] != 0L)
						{
							flag = true;
							num++;
							value[item2] = (long)time;
						}
					}
				}
				foreach (int item3 in hashSet)
				{
					if (value.ContainsKey(item3) && value[item3] != 0L)
					{
						value[item3] = (long)time;
						dictionary[item3]++;
						flag = true;
					}
				}
				if (flag)
				{
					value2.IncreaseDataRevision();
				}
			}
			if (Settings.Verbose)
			{
				Print("Updated " + num + " spawn zones in " + num2 + " 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;

		protected int PreOperated;

		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_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_002a: 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)
			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_005a: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00d6: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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
	{
		public Generate(Terminal context, FiltererParameters args)
			: base(context, args)
		{
			Operation = "Generate";
			InitString = args.Print("Generate");
			Filterers = FiltererFactory.Create(args);
		}

		protected override bool ExecuteZone(Vector2i zone)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			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;

		private int Total;

		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)
			: base(context, args.Start)
		{
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			string[] array = new string[ids.Count];
			foreach (string id in ids)
			{
				array[num] = id;
				num++;
			}
			Ids = array;
			if (Ids.Length == 0)
			{
				Ids = (from loc in ZoneSystem.instance.m_locations
					where Helper.IsValid(loc) && loc.m_enable && loc.m_quantity != 0
					orderby loc.m_prioritized descending
					select loc.m_prefab.Name).ToArray();
			}
			Chance = args.Chance;
			args = new FiltererParameters(args)
			{
				TargetZones = TargetZones.All
			};
			List<IZoneFilterer> source = FiltererFactory.Create(args);
			List<string> messages = new List<string>();
			HashSet<Vector2i> hashSet = new HashSet<Vector2i>();
			foreach (Vector2i item in source.Aggregate(Zones.GetZones(args), (Vector2i[] zones, IZoneFilterer filterer) => filterer.FilterZones(zones, ref messages)).Distinct())
			{
				hashSet.Add(item);
			}
			AllowedZones = hashSet;
		}

		protected override bool OnExecute()
		{
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			if (Attempts == 0)
			{
				LoadingIndicator.SetProgressVisibility(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);
				}
				foreach (KeyValuePair<Vector2i, LocationInstance> item in instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_location.m_prefab.Name == id && !kvp.Value.m_placed).ToList())
				{
					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;
			return ZoneSystem.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{Helper.LocationIdString(Ids)} added to the world (total amount in the world: {Total}).");
			}
			else
			{
				Print($"{Math.Abs(Added)} locations{Helper.LocationIdString(Ids)} removed from the world (total amount in the world: {Total}).");
			}
		}

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

		private void GenerateLocations(ZoneLocation location)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: 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 ListLocationPositions : EntityOperation
	{
		public ListLocationPositions(Terminal context, HashSet<string> ids, LocationIdParameters args)
			: base(context, args.Pin)
		{
			ListPositions(ids, args);
		}

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

		protected string Verb = "";

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

		protected override bool ExecuteZone(Vector2i zone)
		{
			//IL_000c: 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_003c: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			if (!instance.m_locationInstances.TryGetValue(zone, out var value))
			{
				return true;
			}
			if (instance.IsZoneLoaded(zone))
			{
				if (ExecuteLocation(zone, value))
				{
					Operated++;
				}
				return true;
			}
			instance.PokeLocalZone(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_000c: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_004d: 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_007e: 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_00e4: 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();
			Object.Destroy((Object)(object)root);
			instance.m_zones.Remove(zone);
		}
	}
	public class RegisterLocation : BaseOperation
	{
		public RegisterLocation(Terminal context, string id, Vector3 position)
			: base(context)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Register(id, position);
		}

		private void Register(string id, Vector3 position)
		{
			//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)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0095: 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)
			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)
					{
						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, IEnumerable<string> ids, FiltererParameters args)
			: base(context, args.Start)
		{
			Args = new FiltererParameters(args)
			{
				TargetZones = TargetZones.All
			};
			Ids = ids.ToHashSet();
		}

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

		private int RemoveSpawned()
		{
			//IL_004d: 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_0106: 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_00db: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: 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_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: 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.Count > 0 && !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}.");
				}
			}
			foreach (KeyValuePair<Vector2i, LocationInstance> item2 in instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => Args.FilterPosition(kvp.Value.m_position, checkExcludedZones: true)).ToList())
			{
				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($"Location {name} removed at {key}.");
					}
				}
			}
			return num;
		}

		private int RemoveNotSpawned()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			List<IZoneFilterer> list = FiltererFactory.Create(Args);
			List<IZoneFilterer> list2 = new List<IZoneFilterer>(1 + list.Count);
			list2.AddRange(list);
			list2.Add(new LocationFilterer(Ids, OnlyMissing: false));
			List<string> messages = new List<string>();
			Vector2i[] array = list2.Aggregate(Zones.GetZones(TargetZones.All), (Vector2i[] zones, IZoneFilterer filterer) => filterer.FilterZones(zones, ref messages));
			int num = 0;
			Vector2i[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				Vector2i key = array2[i];
				if (instance.m_locationInstances.TryGetValue(key, out var value))
				{
					num++;
					AddPin(value.m_position);
					if (Settings.Verbose)
					{
						Print("Location " + value.m_location.m_prefab.Name + " removed at " + ((object)(Vector2i)(ref key)).ToString());
					}
					instance.m_locationInstances.Remove(key);
				}
			}
			return num;
		}

		protected override bool OnExecute()
		{
			int num = RemoveSpawned() + RemoveNotSpawned();
			Print($"Removed {num} locations.");
			return true;
		}

		protected override string OnInit()
		{
			return Args.Print("Remove locations" + Helper.LocationIdString(Ids) + " from");
		}
	}
	public class RegenerateLocations : LocationOperation
	{
		public RegenerateLocations(Terminal context, HashSet<string> ids, FiltererParameters args)
			: base(context, args)
		{
			Operation = "Reset locations";
			InitString = args.Print("Reset locations at");
			Verb = "reseted";
			List<IZoneFilterer> filterers = Filterers;
			List<IZoneFilterer> list = new List<IZoneFilterer>(1 + filterers.Count);
			list.AddRange(filterers);
			list.Add(new LocationFilterer(ids, OnlyMissing: false));
			Filterers = list;
		}

		protected override bool ExecuteLocation(Vector2i zone, LocationInstance location)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			if (!location.m_placed)
			{
				return false;
			}
			location.m_placed = false;
			ZoneSystem.instance.m_locationInstances[zone] = location;
			ZoneLocation location2 = location.m_location;
			if (location2 != null)
			{
				_ = location2.m_prefab;
				if (0 == 0)
				{
					float clearRadius = location.m_location.m_exteriorRadius;
					if (Args.ObjectReset.HasValue)
					{
						clearRadius = Args.ObjectReset.Value;
					}
					SpawnLocation(zone, location, clearRadius);
					AddPin(location.m_position);
					if (Settings.Verbose)
					{
						Print("Location " + location.m_location.m_prefab.Name + " reseted at " + ((object)(Vector2i)(ref zone)).ToString());
					}
					return true;
				}
			}
			Print("Location " + (location.m_location?.m_prefab.Name ?? "???") + " is missing at " + ((object)(Vector2i)(ref zone)).ToString());
			return false;
		}
	}
	public class SpawnLocations : LocationOperation
	{
		private readonly HashSet<string> Ids;

		public SpawnLocations(Terminal context, HashSet<string> ids, FiltererParameters args)
			: base(context, args)
		{
			Operation = "Spawn missing locations";
			InitString = args.Print("Spawn missing locations to");
			Verb = "spawned to already generated areas";
			args.Chance = 1f;
			Ids = ids;
		}

		protected override void OnStart()
		{
			LocationFilterer locationFilterer = new LocationFilterer(Ids, OnlyMissing: true);
			List<string> messages = new List<string>();
			ZonesToUpgrade = locationFilterer.FilterZones(ZonesToUpgrade, ref messages);
		}

		protected override bool ExecuteLocation(Vector2i zone, LocationInstance location)
		{
			//IL_0000: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (location.m_placed)
			{
				return false;
			}
			ZoneLocation location2 = location.m_location;
			if (location2 != null)
			{
				_ = location2.m_prefab;
				if (0 == 0)
				{
					float clearRadius = (location.m_location.m_clearArea ? location.m_location.m_exteriorRadius : 0f);
					if (Args.ObjectReset.HasValue)
					{
						clearRadius = Args.ObjectReset.Value;
					}
					SpawnLocation(zone, location, clearRadius);
					AddPin(location.m_position);
					if (Settings.Verbose)
					{
						Print("Location " + location.m_location.m_prefab.Name + " spawned at " + ((object)(Vector2i)(ref zone)).ToString());
					}
					return true;
				}
			}
			Print("Location " + (location.m_location?.m_prefab.Name ?? "???") + " is missing at " + ((object)(Vector2i)(ref zone)).ToString());
			return false;
		}
	}
	public class SwapLocations : EntityOperation
	{
		public SwapLocations(Terminal context, IEnumerable<string> ids, DataParameters args)
			: base(context, args.Pin)
		{
			Swap(ids, args);
		}

		private void Swap(IEnumerable<string> ids, DataParameters args)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			int stableHashCode = StringExtensionMethods.GetStableHashCode(ids.FirstOrDefault());
			HashSet<int> prefabs = (from id in ids.Skip(1)
				select StringExtensionMethods.GetStableHashCode(id)).ToHashSet();
			int num = 0;
			ZDO[] array = (from zdo in EntityOperation.GetZDOs(args)
				where LocationProxyHash == zdo.m_prefab
				select zdo).ToArray();
			forea