Decompiled source of Upgrade World v1.82.0

UpgradeWorld.dll

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

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.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+cc4008be494b374ca97a2d0ff08036dbaf170d6b")]
[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]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Service
{
	public class ComponentInfo
	{
		private static Type[]? types;

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

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

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

		public static IEnumerable<KeyValuePair<int, GameObject>> HaveComponent(IEnumerable<KeyValuePair<int, GameObject>> objs, List<string[]> typeSets)
		{
			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) => typeSets.Any((string[] types) => types.All((string type) => PrefabComponents.TryGetValue(type.ToLowerInvariant(), out value) && value.Contains(obj.Key))));
		}
	}
	public class DataHelper
	{
		private static readonly HashSet<string> DataTypes = new HashSet<string> { "float", "id", "int", "long", "quat", "string", "vector" };

		public static bool IsDataType(string type)
		{
			return DataTypes.Contains(type.ToLowerInvariant());
		}

		public static bool HasDataOfType(ZDO zdo, 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_0179: 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_01d9: 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_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			BinarySearchDictionary<int, Vector3> value;
			BinarySearchDictionary<int, Quaternion> value2;
			BinarySearchDictionary<int, long> value3;
			BinarySearchDictionary<int, long> value4;
			BinarySearchDictionary<int, string> value5;
			BinarySearchDictionary<int, int> value6;
			BinarySearchDictionary<int, float> value7;
			return type.ToLowerInvariant() switch
			{
				"vector" => ZDOExtraData.s_vec3.TryGetValue(uid, out value) && value.Count > 0, 
				"quat" => ZDOExtraData.s_quats.TryGetValue(uid, out value2) && value2.Count > 0, 
				"long" => ZDOExtraData.s_longs.TryGetValue(uid, out value3) && value3.Count > 0, 
				"id" => ZDOExtraData.s_longs.TryGetValue(uid, out value4) && value4.Count > 0, 
				"string" => ZDOExtraData.s_strings.TryGetValue(uid, out value5) && value5.Count > 0, 
				"int" => ZDOExtraData.s_ints.TryGetValue(uid, out value6) && value6.Count > 0, 
				"float" => ZDOExtraData.s_floats.TryGetValue(uid, out value7) && value7.Count > 0, 
				_ => false, 
			};
		}

		public static bool HasDataOfType(ZDO zdo, string type, string data)
		{
			//IL_0028: 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_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: 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_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			if (data == "")
			{
				return HasDataOfType(zdo, type);
			}
			ZDOID uid = zdo.m_uid;
			BinarySearchDictionary<int, Vector3> value;
			BinarySearchDictionary<int, Quaternion> value2;
			BinarySearchDictionary<int, long> value3;
			BinarySearchDictionary<int, string> value4;
			BinarySearchDictionary<int, int> value5;
			BinarySearchDictionary<int, float> value6;
			BinarySearchDictionary<int, long> value7;
			return type.ToLowerInvariant() switch
			{
				"vector" => ZDOExtraData.s_vec3.TryGetValue(uid, out value) && ((IEnumerable<KeyValuePair<int, Vector3>>)value).Any((KeyValuePair<int, Vector3> pair) => Parse.VectorXZYRange(data, Vector3.zero).Includes(pair.Value)), 
				"quat" => ZDOExtraData.s_quats.TryGetValue(uid, out value2) && ((IEnumerable<KeyValuePair<int, Quaternion>>)value2).Any((KeyValuePair<int, Quaternion> pair) => Parse.AngleYXZ(data) == pair.Value), 
				"long" => ZDOExtraData.s_longs.TryGetValue(uid, out value3) && ((IEnumerable<KeyValuePair<int, long>>)value3).Any((KeyValuePair<int, long> pair) => (pair.Key != ZDOVars.s_timeOfDeath) ? Parse.LongRange(data, 0L).Includes(pair.Value) : Parse.LongRange(data, 0L).Includes(Helper.ToDay(pair.Value))), 
				"string" => ZDOExtraData.s_strings.TryGetValue(uid, out value4) && ((IEnumerable<KeyValuePair<int, string>>)value4).Any((KeyValuePair<int, string> pair) => data == pair.Value), 
				"int" => ZDOExtraData.s_ints.TryGetValue(uid, out value5) && ((IEnumerable<KeyValuePair<int, int>>)value5).Any((KeyValuePair<int, int> pair) => Parse.IntRange(data).Includes(pair.Value)), 
				"float" => ZDOExtraData.s_floats.TryGetValue(uid, out value6) && ((IEnumerable<KeyValuePair<int, float>>)value6).Any((KeyValuePair<int, float> pair) => Parse.FloatRange(data).Includes(pair.Value)), 
				"id" => ZDOExtraData.s_longs.TryGetValue(uid, out value7) && HasAnyIdData(value7.Values, data), 
				_ => false, 
			};
		}

		private static bool HasAnyIdData(IEnumerable<long> values, string data)
		{
			string[] array = Parse.SplitWithEmpty(data, '/');
			long userId = Parse.Long(array[0], 0L);
			long valueId = Parse.Long(array, 1, 0L);
			if (values.Any((long value) => value == userId))
			{
				return values.Any((long value) => value == valueId);
			}
			return false;
		}

		public static bool ClearData(ZDO zdo, string key)
		{
			//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_0038: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			int stableHashCode = StringExtensionMethods.GetStableHashCode(key);
			int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u");
			int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i");
			bool flag = false;
			if (ZDOExtraData.s_vec3.TryGetValue(uid, out var value))
			{
				flag |= value.Remove(stableHashCode);
			}
			if (ZDOExtraData.s_quats.TryGetValue(uid, out var value2))
			{
				flag |= value2.Remove(stableHashCode);
			}
			if (ZDOExtraData.s_longs.TryGetValue(uid, out var value3))
			{
				flag |= value3.Remove(stableHashCode);
				flag |= value3.Remove(stableHashCode2);
				flag |= value3.Remove(stableHashCode3);
			}
			if (ZDOExtraData.s_strings.TryGetValue(uid, out var value4))
			{
				flag |= value4.Remove(stableHashCode);
			}
			if (ZDOExtraData.s_ints.TryGetValue(uid, out var value5))
			{
				flag |= value5.Remove(stableHashCode);
			}
			if (ZDOExtraData.s_floats.TryGetValue(uid, out var value6))
			{
				flag |= value6.Remove(stableHashCode);
			}
			return flag;
		}

		public static string GetData(ZDO zdo, string key, string type)
		{
			//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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			if (key == "*")
			{
				List<string> allData = GetAllData(zdo, type);
				if (allData.Count <= 0)
				{
					return "No data";
				}
				return string.Join("; ", allData);
			}
			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.SplitWithEmpty(data), Vector3.zero));
			}
			else if (type == "quat" || (type == "" && flag2))
			{
				zdo.Set(stableHashCode, Parse.AngleYXZ(data));
			}
			else if (type == "long" || (type == "" && flag3))
			{
				if (stableHashCode == ZDOVars.s_timeOfDeath)
				{
					zdo.Set(stableHashCode, Helper.ToTick(Parse.Long(data, 0L)));
				}
				else
				{
					zdo.Set(stableHashCode, Parse.Long(data, 0L));
				}
			}
			else if (type == "string" || (type == "" && flag4))
			{
				zdo.Set(stableHashCode, data);
			}
			else if (type == "int" || (type == "" && flag5))
			{
				zdo.Set(stableHashCode, Parse.Int(data), false);
			}
			else if (type == "float" || (type == "" && flag6))
			{
				zdo.Set(stableHashCode, Parse.Float(data));
			}
			else
			{
				if (!(type == "id") && !(type == "" && flag7))
				{
					return false;
				}
				string[] array = Parse.SplitWithEmpty(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_0016: 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_0039: 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_007e: 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_0067: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: 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_0254: Unknown result type (might be due to invalid IL or missing references)
			if (key == "*")
			{
				return HasAnyData(zdo, data);
			}
			ZDOID uid = zdo.m_uid;
			int stableHashCode = StringExtensionMethods.GetStableHashCode(key);
			int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u");
			if (ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode))
			{
				return Parse.VectorXZYRange(data, Vector3.zero).Includes(ZDOExtraData.s_vec3[uid][stableHashCode]);
			}
			if (ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode))
			{
				return Parse.AngleYXZ(data) == ZDOExtraData.s_quats[uid][stableHashCode];
			}
			if (ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode))
			{
				if (stableHashCode == ZDOVars.s_timeOfDeath)
				{
					return Parse.LongRange(data, 0L).Includes(Helper.ToDay(ZDOExtraData.s_longs[uid][stableHashCode]));
				}
				return Parse.LongRange(data, 0L).Includes(ZDOExtraData.s_longs[uid][stableHashCode]);
			}
			if (ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode))
			{
				return data == ZDOExtraData.s_strings[uid][stableHashCode];
			}
			if (ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode))
			{
				return Parse.IntRange(data).Includes(ZDOExtraData.s_ints[uid][stableHashCode]);
			}
			if (ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode))
			{
				return Parse.FloatRange(data).Includes(ZDOExtraData.s_floats[uid][stableHashCode]);
			}
			int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i");
			if (ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode3))
			{
				return data == ZDOExtraData.s_longs[uid][stableHashCode2] + "/" + ZDOExtraData.s_longs[uid][stableHashCode3];
			}
			return includeEmpty;
		}

		private static List<string> GetAllData(ZDO zdo, 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			List<string> list = new List<string>();
			if ((type == "" || type == "vector") && ZDOExtraData.s_vec3.TryGetValue(uid, out var value))
			{
				list.AddRange(((IEnumerable<KeyValuePair<int, Vector3>>)value).Select((KeyValuePair<int, Vector3> pair) => pair.Key + "=" + Helper.PrintVectorXZY(pair.Value) + " (vector)"));
			}
			if ((type == "" || type == "quat") && ZDOExtraData.s_quats.TryGetValue(uid, out var value2))
			{
				list.AddRange(((IEnumerable<KeyValuePair<int, Quaternion>>)value2).Select((KeyValuePair<int, Quaternion> pair) => pair.Key + "=" + Helper.PrintAngleYXZ(pair.Value) + " (quat)"));
			}
			if ((type == "" || type == "long") && ZDOExtraData.s_longs.TryGetValue(uid, out var value3))
			{
				list.AddRange(((IEnumerable<KeyValuePair<int, long>>)value3).Select((KeyValuePair<int, long> pair) => (pair.Key == ZDOVars.s_timeOfDeath) ? (pair.Key + "=" + Helper.PrintDay(pair.Value) + " (long)") : (pair.Key + "=" + pair.Value + " (long)")));
			}
			if ((type == "" || type == "string") && ZDOExtraData.s_strings.TryGetValue(uid, out var value4))
			{
				list.AddRange(((IEnumerable<KeyValuePair<int, string>>)value4).Select((KeyValuePair<int, string> pair) => pair.Key + "=" + pair.Value + " (string)"));
			}
			if ((type == "" || type == "int") && ZDOExtraData.s_ints.TryGetValue(uid, out var value5))
			{
				list.AddRange(((IEnumerable<KeyValuePair<int, int>>)value5).Select((KeyValuePair<int, int> pair) => pair.Key + "=" + pair.Value + " (int)"));
			}
			if ((type == "" || type == "float") && ZDOExtraData.s_floats.TryGetValue(uid, out var value6))
			{
				list.AddRange(((IEnumerable<KeyValuePair<int, float>>)value6).Select((KeyValuePair<int, float> pair) => pair.Key + "=" + pair.Value.ToString("F1") + " (float)"));
			}
			return list;
		}

		private static bool HasAnyData(ZDO zdo, string data)
		{
			//IL_000e: 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_0019: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			if (ZDOExtraData.s_strings.TryGetValue(uid, out var value) && ((IEnumerable<KeyValuePair<int, string>>)value).Any((KeyValuePair<int, string> pair) => data == pair.Value))
			{
				return true;
			}
			if (int.TryParse(data, NumberStyles.Integer, CultureInfo.InvariantCulture, out var intValue) && ZDOExtraData.s_ints.TryGetValue(uid, out var value2) && ((IEnumerable<KeyValuePair<int, int>>)value2).Any((KeyValuePair<int, int> pair) => pair.Value == intValue))
			{
				return true;
			}
			if (long.TryParse(data, NumberStyles.Integer, CultureInfo.InvariantCulture, out var longValue) && ZDOExtraData.s_longs.TryGetValue(uid, out var value3) && ((IEnumerable<KeyValuePair<int, long>>)value3).Any((KeyValuePair<int, long> pair) => pair.Value == longValue))
			{
				return true;
			}
			if (Parse.TryFloat(data, out var floatValue) && ZDOExtraData.s_floats.TryGetValue(uid, out var value4) && ((IEnumerable<KeyValuePair<int, float>>)value4).Any((KeyValuePair<int, float> pair) => Mathf.Approximately(pair.Value, floatValue)))
			{
				return true;
			}
			return false;
		}
	}
	public static class Hash
	{
		public static int Changed = StringExtensionMethods.GetStableHashCode("override_changed");

		public static int OverrideItems = StringExtensionMethods.GetStableHashCode("override_items");
	}
	public class ItemRecord
	{
		public int PrefabHash;

		public string PrefabName = "";

		public int Stack;

		public float Durability;

		public Vector2i GridPos;

		public bool Equipped;

		public int Quality = 1;

		public int Variant;

		public long CrafterID;

		public string CrafterName = "";

		public Dictionary<string, string> CustomData = new Dictionary<string, string>();

		public int WorldLevel;

		public bool PickedUp;

		public bool Cheated;
	}
	public static class ItemDataHelper
	{
		public static ZPackage? GetPackage(ZDO zdo)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			byte[] byteArray = zdo.GetByteArray(ZDOVars.s_items, (byte[])null);
			if (byteArray != null && byteArray.Length != 0)
			{
				return new ZPackage(byteArray);
			}
			string text = zdo.GetString(ZDOVars.s_items, "");
			if (!(text != ""))
			{
				return null;
			}
			return new ZPackage(text);
		}

		public static List<ItemRecord> Load(ZDO zdo)
		{
			ZPackage package = GetPackage(zdo);
			if (package != null)
			{
				return Load(package);
			}
			return new List<ItemRecord>();
		}

		public static List<ItemRecord> Load(ZPackage pkg)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0024: 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)
			List<ItemRecord> list = new List<ItemRecord>();
			try
			{
				Item val = (Item)pkg.ReadInt();
				if ((int)val == 0)
				{
					return list;
				}
				if ((int)val >= 108)
				{
					LoadNew(pkg, val, list);
				}
				else
				{
					LoadOld(pkg, val, list);
				}
			}
			catch
			{
			}
			return list;
		}

		private static void LoadNew(ZPackage pkg, Item version, List<ItemRecord> records)
		{
			//IL_000f: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			ushort num = pkg.ReadUShort();
			for (int i = 0; i < num; i++)
			{
				var (num2, val) = ItemData.Load(pkg, version);
				object obj;
				if (num2 == 0)
				{
					obj = "";
				}
				else
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(num2);
					obj = ((itemPrefab != null) ? ((Object)itemPrefab).name : null) ?? "";
				}
				string prefabName = (string)obj;
				records.Add(new ItemRecord
				{
					PrefabHash = num2,
					PrefabName = prefabName,
					Stack = val.m_stack,
					Durability = val.m_durability,
					GridPos = val.m_gridPos,
					Equipped = val.m_equipped,
					Quality = val.m_quality,
					Variant = val.m_variant,
					CrafterID = val.m_crafterID,
					CrafterName = val.m_crafterName,
					CustomData = val.m_customData,
					WorldLevel = val.m_worldLevel,
					PickedUp = val.m_pickedUp,
					Cheated = val.m_cheated
				});
			}
		}

		private static void LoadOld(ZPackage pkg, Item version, List<ItemRecord> records)
		{
			//IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Invalid comparison between Unknown and I4
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Invalid comparison between Unknown and I4
			//IL_0148: 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 num = pkg.ReadInt();
			for (int i = 0; i < num; i++)
			{
				string text = pkg.ReadString();
				int stack = pkg.ReadInt();
				float durability = pkg.ReadSingle();
				Vector2i gridPos = pkg.ReadVector2i();
				bool equipped = pkg.ReadBool();
				int quality = (((int)version < 101) ? 1 : pkg.ReadInt());
				int variant = (((int)version >= 102) ? pkg.ReadInt() : 0);
				long crafterID = 0L;
				string crafterName = "";
				if ((int)version >= 103)
				{
					crafterID = pkg.ReadLong();
					crafterName = pkg.ReadString();
				}
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				if ((int)version >= 104)
				{
					int num2 = pkg.ReadInt();
					for (int j = 0; j < num2; j++)
					{
						dictionary[pkg.ReadString()] = pkg.ReadString();
					}
				}
				int worldLevel = (((int)version >= 105) ? pkg.ReadInt() : 0);
				bool pickedUp = (int)version >= 106 && pkg.ReadBool();
				bool cheated = (int)version == 107 && pkg.ReadBool();
				int num3 = ((text != "") ? StringExtensionMethods.GetStableHashCode(text) : 0);
				object obj;
				if (num3 == 0)
				{
					obj = "";
				}
				else
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(num3);
					obj = ((itemPrefab != null) ? ((Object)itemPrefab).name : null) ?? "";
				}
				string prefabName = (string)obj;
				records.Add(new ItemRecord
				{
					PrefabHash = num3,
					PrefabName = prefabName,
					Stack = stack,
					Durability = durability,
					GridPos = gridPos,
					Equipped = equipped,
					Quality = quality,
					Variant = variant,
					CrafterID = crafterID,
					CrafterName = crafterName,
					CustomData = dictionary,
					WorldLevel = worldLevel,
					PickedUp = pickedUp,
					Cheated = cheated
				});
			}
		}

		public static int CountInvalid(List<ItemRecord> records)
		{
			return records.Count((ItemRecord r) => r.PrefabName == "");
		}

		public static List<ItemRecord> RemoveInvalid(List<ItemRecord> records)
		{
			List<ItemRecord> list = new List<ItemRecord>();
			list.AddRange(records.Where((ItemRecord r) => r.PrefabName != ""));
			return list;
		}

		public static byte[] Save(List<ItemRecord> records)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			Save(records, val);
			return val.GetArray();
		}

		public static void Save(List<ItemRecord> records, ZPackage pkg)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0098: 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_00b0: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			pkg.Write(109);
			pkg.Write((ushort)records.Count);
			foreach (ItemRecord record in records)
			{
				new ItemData
				{
					m_dropPrefab = ObjectDB.instance.GetItemPrefab(record.PrefabHash),
					m_stack = record.Stack,
					m_durability = record.Durability,
					m_gridPos = record.GridPos,
					m_equipped = record.Equipped,
					m_quality = record.Quality,
					m_variant = record.Variant,
					m_crafterID = record.CrafterID,
					m_crafterName = record.CrafterName,
					m_customData = record.CustomData,
					m_worldLevel = record.WorldLevel,
					m_pickedUp = record.PickedUp,
					m_cheated = record.Cheated
				}.Save(pkg);
			}
		}
	}
	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)
		{
			ref T min = ref Min;
			object obj = value;
			if (min.CompareTo(obj) <= 0)
			{
				ref T max = ref Max;
				object obj2 = value;
				return max.CompareTo(obj2) >= 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 = SplitWithEmpty(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 = SplitWithEmpty(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 = SplitWithEmpty(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 = SplitWithEmpty(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 = SplitWithEmpty(arg);
			Range<float> x = FloatRange(args, 0);
			Range<float> y = FloatRange(args, 1);
			Range<float> z = FloatRange(args, 2);
			Vector3Range vector3Range = ToVectorRange(x, y, z);
			vector3Range.Min = SanityCheck(vector3Range.Min);
			vector3Range.Max = SanityCheck(vector3Range.Max);
			return vector3Range;
		}

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

		public static string[] SplitWithEmpty(string arg, char separator = ',')
		{
			string[] array = arg.Split(new char[1] { separator });
			int num = 0;
			string[] array2 = new string[array.Length];
			string[] array3 = array;
			foreach (string text in array3)
			{
				array2[num] = text;
				num++;
			}
			return array2;
		}

		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)
		{
			value = parameters.FirstOrDefault((string arg) => arg.ToLower() == flag) != null;
			return parameters.Where((string arg) => arg.ToLower() != flag);
		}

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

		public static Vector2s Zone(string arg)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			string[] array = SplitWithEmpty(arg).ToArray();
			int num = ((array.Length != 0) ? Int(array[0]) : 0);
			int num2 = ((array.Length > 1) ? Int(array[1]) : 0);
			return new Vector2s(num, num2);
		}

		public static Vector2 Pos(string arg)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			string[] array = SplitWithEmpty(arg).ToArray();
			float num = ((array.Length != 0) ? Float(array[0]) : 0f);
			float num2 = ((array.Length > 1) ? Float(array[1]) : 0f);
			return new Vector2(num, num2);
		}

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

		public int Prefab;

		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;
			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;
			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);
			zdo.DataRevision += 100;
		}

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

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

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

		protected static string S(int i)
		{
			if (i <= 1)
			{
				return "";
			}
			return "s";
		}

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

		public static HashSet<int> GetPrefabs(IEnumerable<string> id, IEnumerable<string> ignore, List<string[]> types)
		{
			HashSet<int> hashSet;
			if (id.Count() == 0)
			{
				hashSet = GetPrefabs("*", types);
			}
			else
			{
				HashSet<int> hashSet2 = new HashSet<int>();
				foreach (int item in id.SelectMany((string id2) => GetPrefabs(id2, types)))
				{
					hashSet2.Add(item);
				}
				hashSet = hashSet2;
			}
			HashSet<int> hashSet3 = hashSet;
			if (ignore.Count() > 0)
			{
				HashSet<int> prefabs = GetPrefabs(ignore, Array.Empty<string>(), new List<string[]>());
				hashSet3.ExceptWith(prefabs);
			}
			return hashSet3;
		}

		public static HashSet<int> GetPrefabs(IEnumerable<string> id, List<string[]> types)
		{
			return GetPrefabs(id, Array.Empty<string>(), types);
		}

		public static HashSet<int> GetPrefabs(string id, List<string[]> types)
		{
			if (int.TryParse(id, out var result))
			{
				return new HashSet<int> { result };
			}
			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 (!(id == "*"))
			{
				source = ((!id.Contains("*")) ? source.Where((KeyValuePair<int, GameObject> kvp) => string.Equals(((Object)kvp.Value).name, id, StringComparison.OrdinalIgnoreCase)) : source.Where((KeyValuePair<int, GameObject> kvp) => Helper.IsIncluded(id, ((Object)kvp.Value).name)));
			}
			if (types.Count > 0)
			{
				source = ComponentInfo.HaveComponent(source.ToArray(), types);
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (int item in source.Select((KeyValuePair<int, GameObject> kvp) => kvp.Key))
			{
				hashSet.Add(item);
			}
			return hashSet;
		}

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

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

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

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

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

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

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

		public static ZDOID[] GetZDOIDs(DataParameters args, HashSet<int> prefabs)
		{
			List<ZDOID> list = new List<ZDOID>();
			list.AddRange(from zdo in GetZDOs(args, prefabs)
				select zdo.m_uid);
			return list.ToArray();
		}

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

		public static IEnumerable<ZDO> FilterZdos(IEnumerable<ZDO> zdos, FiltererParameters args)
		{
			return args.LimitZdos(args.FilterZdos(zdos, checkExcludedZones: false));
		}
	}
	public abstract class ExecutedEntityOperation : ExecutedOperation
	{
		protected readonly IEnumerable<string> Ids;

		protected readonly DataParameters Args;

		protected HashSet<int> Prefabs;

		protected ZDOID[] ZdosToProcess;

		protected Dictionary<int, int> Counts;

		protected int ProcessedCount;

		protected int TotalCount;

		protected ExecutedEntityOperation(Terminal context, IEnumerable<string> ids, DataParameters args)
		{
			Ids = ids;
			Args = args;
			Prefabs = new HashSet<int>();
			ZdosToProcess = Array.Empty<ZDOID>();
			Counts = new Dictionary<int, int>();
			base..ctor(context, args.Pin);
		}

		protected override string OnInit()
		{
			Prefabs = GetPrefabsForOperation();
			ZdosToProcess = EntityOperation.GetZDOIDs(Args, Prefabs);
			TotalCount = ZdosToProcess.Length;
			Counts = Prefabs.ToDictionary((int prefab) => prefab, (int prefab) => 0);
			if (TotalCount == 0)
			{
				Print(GetNoObjectsMessage());
				return "";
			}
			return GetInitMessage();
		}

		protected override IEnumerator OnExecute(Stopwatch sw)
		{
			if (TotalCount == 0)
			{
				yield break;
			}
			int processed = 0;
			ZDOID[] zdosToProcess = ZdosToProcess;
			foreach (ZDOID key in zdosToProcess)
			{
				if (ZDOMan.instance.m_objectsByID.TryGetValue(key, out var value))
				{
					if (ProcessZDO(value))
					{
						Counts[value.m_prefab]++;
						ProcessedCount++;
						AddPin(value.GetPosition());
					}
					processed++;
					if (processed >= 10000)
					{
						processed = 0;
						yield return null;
					}
				}
			}
		}

		protected override void OnEnd()
		{
			IEnumerable<string> collection = from kvp in Counts
				where kvp.Value > 0
				select GetCountMessage(kvp.Value, kvp.Key) into msg
				where !string.IsNullOrEmpty(msg)
				select msg;
			List<string> list = new List<string>();
			list.Add(GetProcessedMessage());
			list.AddRange(collection);
			string[] values = list.ToArray();
			if (Args.Log)
			{
				Log(values);
			}
			else
			{
				Print(values, addDot: false);
			}
			PrintPins();
		}

		protected virtual HashSet<int> GetPrefabsForOperation()
		{
			return EntityOperation.GetPrefabs(Ids, Args.Ignore, Args.Types);
		}

		protected abstract bool ProcessZDO(ZDO zdo);

		protected abstract string GetNoObjectsMessage();

		protected abstract string GetInitMessage();

		protected abstract string GetProcessedMessage();

		protected abstract string GetCountMessage(int count, int prefab);
	}
	public abstract class ExecutedOperation : BaseOperation
	{
		protected int Failed;

		private string queuedInfo = "";

		public bool ExecutionFailed { get; private set; }

		protected ExecutedOperation(Terminal context, bool pin = false)
			: base(context, pin)
		{
		}

		public IEnumerator Execute(Stopwatch sw)
		{
			Stack<IEnumerator> stack = new Stack<IEnumerator>();
			Exception failure = null;
			try
			{
				OnStart();
				stack.Push(OnExecute(sw));
			}
			catch (Exception ex)
			{
				failure = ex;
			}
			try
			{
				while (failure == null && stack.Count > 0)
				{
					object obj = null;
					try
					{
						IEnumerator enumerator = stack.Peek();
						if (!enumerator.MoveNext())
						{
							stack.Pop();
							(enumerator as IDisposable)?.Dispose();
							continue;
						}
						obj = enumerator.Current;
						if (obj is IEnumerator item)
						{
							stack.Push(item);
							continue;
						}
					}
					catch (Exception ex2)
					{
						failure = ex2;
					}
					if (failure == null)
					{
						yield return obj;
					}
				}
			}
			finally
			{
				DisposeStack(stack, ref failure);
			}
			if (failure == null)
			{
				try
				{
					PrintPins();
					OnEnd();
				}
				catch (Exception ex3)
				{
					failure = ex3;
				}
			}
			if (failure != null)
			{
				ReportFailure(failure);
			}
		}

		private void ReportFailure(Exception failure)
		{
			ExecutionFailed = true;
			Print("Operation failed: " + failure.Message + ". Remaining queued operations will be cancelled. Changes already made are not rolled back.");
			UpgradeWorld.Log.LogError((object)failure);
		}

		private static void DisposeStack(Stack<IEnumerator> stack, ref Exception? failure)
		{
			while (stack.Count > 0)
			{
				try
				{
					(stack.Pop() as IDisposable)?.Dispose();
				}
				catch (Exception ex)
				{
					if (failure == null)
					{
						failure = ex;
					}
				}
			}
		}

		protected abstract IEnumerator OnExecute(Stopwatch sw);

		public bool Init(bool autoStart)
		{
			queuedInfo = OnInit();
			if (queuedInfo == "")
			{
				return false;
			}
			string text = queuedInfo;
			if (!autoStart)
			{
				text += Helper.GetStartMessage();
			}
			Print(text);
			return true;
		}

		protected abstract string OnInit();

		public string GetInfo()
		{
			if (!(queuedInfo != ""))
			{
				return GetType().Name;
			}
			return queuedInfo;
		}

		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.DataRevision += 100;
				}
			}
			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 Vector2s[] ZonesToUpgrade = Zones.GetZones(args);

		protected int ZoneIndex;

		protected int PreOperated;

		protected FiltererParameters Args;

		protected List<IZoneFilterer> Filterers;

		protected string InitString;

		private readonly Stopwatch LastSuccessTimer;

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

		protected override string OnInit()
		{
			List<string> messages = new List<string>();
			ZonesToUpgrade = Filterers.Aggregate(ZonesToUpgrade, (Vector2s[] 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(Vector2s zone);

		protected override IEnumerator OnExecute(Stopwatch sw)
		{
			if (ZonesToUpgrade == null || ZonesToUpgrade.Length == 0)
			{
				yield break;
			}
			LastSuccessTimer.Restart();
			while (ZoneIndex < ZonesToUpgrade.Length)
			{
				Vector2s zone = ZonesToUpgrade[ZoneIndex];
				bool flag = ExecuteZone(zone);
				MoveToNextZone(flag);
				if (flag)
				{
					if (sw.ElapsedMilliseconds >= 100)
					{
						UpdateConsole();
						yield return null;
						sw.Restart();
					}
				}
				else
				{
					yield return null;
					sw.Restart();
				}
			}
			UpdateConsole();
		}

		private void MoveToNextZone(bool success)
		{
			if (success)
			{
				LastSuccessTimer.Restart();
				ZoneIndex++;
			}
			else if (LastSuccessTimer.ElapsedMilliseconds >= 10000)
			{
				Failed++;
				LastSuccessTimer.Restart();
				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
	{
		private readonly bool Empty;

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

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

		protected override void OnEnd()
		{
			int num = ZonesToUpgrade.Length - Failed;
			string text = Operation + " completed. " + num + " zones generated.";
			if (Failed > 0)
			{
				text = text + " " + Failed + " errors.";
			}
			Print(text);
		}
	}
	public class CountLocations : EntityOperation
	{
		public CountLocations(Terminal context, HashSet<string> ids, bool log, FiltererParameters args)
			: base(context, args.Pin)
		{
			CountPositions(ids, log, args);
		}

		private void CountPositions(HashSet<string> ids, bool log, FiltererParameters args)
		{
			//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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			ZoneSystem instance = ZoneSystem.instance;
			List<LocationInstance> list = (from l in args.FilterLocations(instance.m_locationInstances.Values)
				where ids.Count() == 0 || ids.Contains(l.m_location?.m_prefab.Name ?? "")
				select l).ToList();
			int num = 0;
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (LocationInstance item in list)
			{
				string name = item.m_location.m_prefab.Name;
				if (!dictionary.ContainsKey(name))
				{
					dictionary[name] = 0;
				}
				dictionary[name]++;
				num++;
				AddPin(item.m_position);
			}
			IEnumerable<string> collection = from kvp in dictionary
				orderby kvp.Key
				select $"{kvp.Key}: {kvp.Value}";
			List<string> list2 = new List<string>();
			list2.Add($"Total: {num}");
			list2.AddRange(collection);
			string[] values = list2.ToArray();
			if (log)
			{
				Log(values);
			}
			else
			{
				Print(values, addDot: false);
			}
			PrintPins();
		}
	}
	public class DistributeLocations : ExecutedOperation
	{
		private readonly string[] Ids = Array.Empty<string>();

		public float Chance = 1f;

		public int Added;

		private int Total;

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

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

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

		protected override IEnumerator OnExecute(Stopwatch sw)
		{
			if (Ids.Length == 0)
			{
				Print("No locations to generate.");
				yield break;
			}
			ClearNotSpawned(Ids);
			ZoneSystem zs = ZoneSystem.instance;
			string[] ids;
			if (LPA.IsAvailable())
			{
				Print("LPA detected. Handing off spatial allocation.");
				Dictionary<ZoneLocation, int> dictionary = new Dictionary<ZoneLocation, int>();
				ids = Ids;
				foreach (string id in ids)
				{
					foreach (ZoneLocation item in zs.m_locations.Where((ZoneLocation loc) => Helper.IsValid(loc) && loc.m_prefab.Name == id))
					{
						dictionary[item] = item.m_quantity;
					}
				}
				if (dictionary.Count > 0)
				{
					yield return LPA.RunCustomPlacement(dictionary, AllowedZones);
				}
			}
			else
			{
				int counter = 0;
				string[] ids2 = Ids;
				foreach (string id2 in ids2)
				{
					counter++;
					ZoneLocation[] array = zs.m_locations.Where((ZoneLocation val) => Helper.IsValid(val) && val.m_prefab.Name == id2).ToArray();
					if (array.Length != 0)
					{
						Print("Generating locations " + id2 + ". This may take a while...");
						ZoneLocation[] array2 = array;
						foreach (ZoneLocation location in array2)
						{
							yield return GenerateLocationsTimeSliced(location, sw);
						}
					}
				}
			}
			ids = Ids;
			foreach (string id3 in ids)
			{
				int value;
				int num3 = (Counts.TryGetValue(id3, out value) ? value : 0);
				if (Chance < 1f)
				{
					zs.m_locationInstances = zs.m_locationInstances.Where((KeyValuePair<Vector2s, LocationInstance> kvp) => kvp.Value.m_placed || kvp.Value.m_location.m_prefab.Name != id3 || FiltererParameters.random.NextDouble() < (double)Chance).ToDictionary((KeyValuePair<Vector2s, LocationInstance> kvp) => kvp.Key, (KeyValuePair<Vector2s, LocationInstance> kvp) => kvp.Value);
				}
				foreach (KeyValuePair<Vector2s, LocationInstance> item2 in zs.m_locationInstances.Where((KeyValuePair<Vector2s, LocationInstance> kvp) => kvp.Value.m_location.m_prefab.Name == id3 && !kvp.Value.m_placed).ToList())
				{
					AddPin(item2.Value.m_position);
				}
				Total += Count(id3);
				Added += Total - num3;
			}
			if (Object.op_Implicit((Object)(object)Hud.instance))
			{
				Hud.instance.m_loadingIndicator.SetShowProgress(false);
			}
		}

		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<Vector2s, LocationInstance> kvp) => kvp.Value.m_placed || !Counts.ContainsKey(kvp.Value.m_location.m_prefab.Name)).ToDictionary((KeyValuePair<Vector2s, LocationInstance> kvp) => kvp.Key, (KeyValuePair<Vector2s, LocationInstance> kvp) => kvp.Value);
			DummyClearNonPlacedLocations.Skip = true;
			instance.ClearNonPlacedLocations();
			DummyClearNonPlacedLocations.Skip = false;
		}

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

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

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

		private IEnumerator GenerateLocationsTimeSliced(ZoneLocation location, Stopwatch tim