Decompiled source of Expand World Prefabs v1.23.0

ExpandWorldPrefabs.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Data;
using ExpandWorld.Prefab;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Service;
using UnityEngine;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[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("ExpandWorldPrefabs")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+869e1c2083e359efaaea643d3ca3083c09959598")]
[assembly: AssemblyProduct("ExpandWorldPrefabs")]
[assembly: AssemblyTitle("ExpandWorldPrefabs")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Service
{
	public class Log
	{
		private static ManualLogSource Logger;

		public static void Init(ManualLogSource logger)
		{
			Logger = logger;
		}

		public static void Error(string message)
		{
			Logger.LogError((object)message);
		}

		public static void Warning(string message)
		{
			Logger.LogWarning((object)message);
		}

		public static void Info(string message)
		{
			Logger.LogInfo((object)message);
		}

		public static void Debug(string message)
		{
			Logger.LogDebug((object)message);
		}
	}
	public class Range<T>
	{
		public T Min;

		public T Max;

		public bool Uniform = true;

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

		public Range(T min, T max)
		{
			Min = min;
			Max = max;
		}
	}
	public static class Parse
	{
		private static Dictionary<string, Color> Paints = new Dictionary<string, Color>
		{
			{
				"grass",
				Color.black
			},
			{
				"patches",
				new Color(0f, 0.75f, 0f)
			},
			{
				"grass_dark",
				new Color(0.6f, 0.5f, 0f)
			},
			{
				"dirt",
				Color.red
			},
			{
				"cultivated",
				Color.green
			},
			{
				"paved",
				Color.blue
			},
			{
				"paved_moss",
				new Color(0f, 0f, 0.5f)
			},
			{
				"paved_dirt",
				new Color(1f, 0f, 0.5f)
			},
			{
				"paved_dark",
				new Color(0f, 1f, 0.5f)
			}
		};

		public static List<string> ToList(string str, bool removeEmpty = true)
		{
			string[] array = Split(str, removeEmpty);
			List<string> list = new List<string>(array.Length);
			list.AddRange(array);
			return list;
		}

		public static Vector2i Vector2Int(string arg)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			string[] array = SplitWithEmpty(arg);
			return new Vector2i(Int(array[0]), (array.Length > 1) ? Int(array[1]) : 0);
		}

		public static int Int(string arg, int defaultValue = 0)
		{
			if (!TryInt(arg, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		public static uint UInt(string arg, uint defaultValue = 0u)
		{
			if (!TryUInt(arg, out var result))
			{
				return defaultValue;
			}
			return result;
		}

		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 bool TryLong(string arg, out long result)
		{
			return long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out 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 bool TryUInt(string arg, out uint result)
		{
			return uint.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out result);
		}

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

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

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

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

		public static bool TryBoolean(string arg, out bool result)
		{
			result = false;
			if (arg.ToLowerInvariant() == "true")
			{
				result = true;
				return true;
			}
			if (arg.ToLowerInvariant() == "false")
			{
				return true;
			}
			return false;
		}

		public static Quaternion AngleYXZ(string arg)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			return AngleYXZ(Split(arg), 0, Vector3.zero);
		}

		public static Quaternion AngleYXZ(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 AngleYXZ(args, index, Vector3.zero);
		}

		public static Quaternion AngleYXZ(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)
			//IL_0047: 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 Quaternion.Euler(zero);
		}

		public static string[] Split(string arg, bool removeEmpty = true, char split = ',')
		{
			return (from s in arg.Split(new char[1] { split })
				select s.Trim() into s
				where !removeEmpty || s != ""
				select s).ToArray();
		}

		public static KeyValuePair<string, string> Kvp(string str, char separator = ',')
		{
			string[] array = str.Split(new char[1] { separator }, 2);
			if (array.Length < 2)
			{
				return new KeyValuePair<string, string>(array[0], "");
			}
			return new KeyValuePair<string, string>(array[0], array[1].Trim());
		}

		public static string[] SplitWithEmpty(string arg, char split = ',')
		{
			return (from s in arg.Split(new char[1] { split })
				select s.Trim()).ToArray();
		}

		public static string[] SplitWithEscape(string arg, char separator = ',')
		{
			List<string> list = new List<string>();
			string[] array = arg.Split(new char[1] { separator });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].TrimStart(Array.Empty<char>());
				if (text.StartsWith("\""))
				{
					array[i] = text.Substring(1);
					int j;
					for (j = i; j < array.Length; j++)
					{
						text = array[j].TrimEnd(Array.Empty<char>());
						if (text.EndsWith("\""))
						{
							array[j] = text.Substring(0, text.Length - 1);
							break;
						}
					}
					list.Add(string.Join(separator.ToString(), array.Skip(i).Take(j - i + 1)));
					i = j;
				}
				else
				{
					list.Add(array[i].Trim());
				}
			}
			return list.ToArray();
		}

		public static string Name(string arg)
		{
			return arg.Split(new char[1] { ':' })[0];
		}

		public static Vector3 VectorXZY(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 VectorXZY(arg, Vector3.zero);
		}

		public static Vector3 VectorXZY(string arg, Vector3 defaultValue)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return VectorXZY(Split(arg), 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.z = Float(args, index + 1, defaultValue.z);
			zero.y = Float(args, index + 2, defaultValue.y);
			return zero;
		}

		public static Vector2 VectorXY(string arg)
		{
			//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_0036: Unknown result type (might be due to invalid IL or missing references)
			Vector2 zero = Vector2.zero;
			string[] args = Split(arg);
			zero.x = Float(args, 0);
			zero.y = Float(args, 1);
			return zero;
		}

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

		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 Range<string> StringRange(string arg)
		{
			List<string> list = arg.Split('-', ';').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 Range<int> IntRange(string arg)
		{
			Range<string> range = StringRange(arg);
			return new Range<int>(Int(range.Min), Int(range.Max));
		}

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

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

		public static int? IntNull(string arg)
		{
			if (int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return null;
		}

		public static int? IntNull(string[] args, int index)
		{
			if (args.Length <= index)
			{
				return null;
			}
			return IntNull(args[index]);
		}

		public static float? FloatNull(string arg)
		{
			if (float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return null;
		}

		public static float? FloatNull(string[] args, int index)
		{
			if (args.Length <= index)
			{
				return null;
			}
			return FloatNull(args[index]);
		}

		public static long? LongNull(string[] args, int index)
		{
			if (args.Length <= index)
			{
				return null;
			}
			return LongNull(args[index]);
		}

		public static long? LongNull(string arg)
		{
			if (long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return result;
			}
			return null;
		}

		public static Vector3? VectorXZYNull(string? arg)
		{
			if (arg != null)
			{
				return VectorXZYNull(Split(arg));
			}
			return null;
		}

		public static Vector3? VectorXZYNull(string[] args)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			float? num = FloatNull(args, 0);
			float? num2 = FloatNull(args, 2);
			float? num3 = FloatNull(args, 1);
			if (!num.HasValue && !num2.HasValue && !num3.HasValue)
			{
				return null;
			}
			return new Vector3(num.GetValueOrDefault(), num2.GetValueOrDefault(), num3.GetValueOrDefault());
		}

		public static Quaternion? AngleYXZNull(string? arg)
		{
			if (arg != null)
			{
				return AngleYXZNull(Split(arg));
			}
			return null;
		}

		public static Quaternion? AngleYXZNull(string[] values)
		{
			//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)
			float? num = FloatNull(values, 0);
			float? num2 = FloatNull(values, 1);
			float? num3 = FloatNull(values, 2);
			if (!num.HasValue && !num2.HasValue && !num3.HasValue)
			{
				return null;
			}
			return Quaternion.Euler(new Vector3(num2.GetValueOrDefault(), num.GetValueOrDefault(), num3.GetValueOrDefault()));
		}

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

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

		public static bool Boolean(string[] args, int index)
		{
			if (args.Length > index)
			{
				return Boolean(args[index]);
			}
			return false;
		}

		public static bool Boolean(string arg)
		{
			return arg.ToLowerInvariant() == "true";
		}

		public static bool BooleanTrue(string arg)
		{
			return arg.ToLowerInvariant() == "false";
		}

		public static ZDOID ZdoId(string arg)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			string[] array = Split(arg, removeEmpty: true, ':');
			if (array.Length < 2)
			{
				return ZDOID.None;
			}
			return new ZDOID(Long(array[0], 0L), UInt(array[1]));
		}

		public static HitData Hit(ZDO? zdo, string arg)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f->IL036f: Incompatible stack types: O vs I4
			//IL_036d->IL036f: Incompatible stack types: I4 vs O
			//IL_036d->IL036f: Incompatible stack types: O vs I4
			//IL_0374->IL0374: Incompatible stack types: I4 vs O
			HitData val = new HitData
			{
				m_point = (zdo?.m_position ?? Vector3.zero)
			};
			string[] array = Split(arg, removeEmpty: true, ' ');
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<string, string> keyValuePair = Kvp(array[i], '=');
				object obj = keyValuePair.Key;
				string value = keyValuePair.Value;
				if ((string?)obj == "damage")
				{
					val.m_damage.m_damage = Int(value);
				}
				if ((string?)obj == "blunt")
				{
					val.m_damage.m_blunt = Int(value);
				}
				if ((string?)obj == "slash")
				{
					val.m_damage.m_slash = Int(value);
				}
				if ((string?)obj == "pierce")
				{
					val.m_damage.m_pierce = Int(value);
				}
				if ((string?)obj == "chop")
				{
					val.m_damage.m_chop = Int(value);
				}
				if ((string?)obj == "pickaxe")
				{
					val.m_damage.m_pickaxe = Int(value);
				}
				if ((string?)obj == "fire")
				{
					val.m_damage.m_fire = Int(value);
				}
				if ((string?)obj == "frost")
				{
					val.m_damage.m_frost = Int(value);
				}
				if ((string?)obj == "lightning")
				{
					val.m_damage.m_lightning = Int(value);
				}
				if ((string?)obj == "poison")
				{
					val.m_damage.m_poison = Int(value);
				}
				if ((string?)obj == "spirit")
				{
					val.m_damage.m_spirit = Int(value);
				}
				if ((string?)obj == "tier")
				{
					val.m_toolTier = (short)Int(value);
				}
				if ((string?)obj == "force")
				{
					val.m_pushForce = Float(value);
				}
				if ((string?)obj == "backstab")
				{
					val.m_backstabBonus = Float(value);
				}
				if ((string?)obj == "stagger")
				{
					val.m_staggerMultiplier = Int(value);
				}
				if ((string?)obj == "dodge")
				{
					val.m_dodgeable = Boolean(value);
				}
				if ((string?)obj == "block")
				{
					val.m_blockable = Boolean(value);
				}
				if ((string?)obj == "dir")
				{
					val.m_dir = VectorXZY(value);
				}
				if ((string?)obj == "ranged")
				{
					val.m_ranged = Boolean(value);
				}
				if ((string?)obj == "pvp")
				{
					val.m_ignorePVP = Boolean(value);
				}
				if ((string?)obj == "pos")
				{
					val.m_point = VectorXZY(value);
				}
				if ((string?)obj == "status")
				{
					val.m_statusEffectHash = StringExtensionMethods.GetStableHashCode(value);
				}
				if ((string?)obj == "attacker")
				{
					val.m_attacker = ZdoId(value);
				}
				if ((string?)obj == "skill")
				{
					val.m_skillLevel = Float(value);
				}
				if ((string?)obj == "level")
				{
					val.m_itemLevel = (short)Int(value);
				}
				if ((string?)obj == "world")
				{
					val.m_itemWorldLevel = (byte)Int(value);
				}
				if ((string?)obj == "type")
				{
					int num;
					if (Enum.TryParse<HitType>(value, ignoreCase: true, out HitType result))
					{
						obj = result;
						num = (int)obj;
					}
					else
					{
						num = 0;
						obj = num;
						num = (int)obj;
					}
					val.m_hitType = (HitType)obj;
					obj = num;
				}
				if ((string?)obj == "spot")
				{
					val.m_weakSpot = (short)Int(value);
				}
			}
			return val;
		}

		public static int EnumMessage(string arg)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected I4, but got Unknown
			if (!Enum.TryParse<MessageType>(arg, ignoreCase: true, out MessageType result))
			{
				return Int(arg, 2);
			}
			return (int)result;
		}

		public static int EnumReason(string arg)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected I4, but got Unknown
			if (!Enum.TryParse<AggravatedReason>(arg, ignoreCase: true, out AggravatedReason result))
			{
				return Int(arg);
			}
			return (int)result;
		}

		public static int EnumTrap(string arg)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected I4, but got Unknown
			if (!Enum.TryParse<TrapState>(arg, ignoreCase: true, out TrapState result))
			{
				return Int(arg);
			}
			return (int)result;
		}

		public static int EnumDamageText(string arg)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected I4, but got Unknown
			if (!Enum.TryParse<TextType>(arg, ignoreCase: true, out TextType result))
			{
				return Int(arg);
			}
			return (int)result;
		}

		public static int EnumTerrainPaint(string arg)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected I4, but got Unknown
			if (!Enum.TryParse<PaintType>(arg, ignoreCase: true, out PaintType result))
			{
				return Int(arg);
			}
			return (int)result;
		}

		public static Color? Color(string arg)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			string key = arg.ToLowerInvariant();
			if (Paints.TryGetValue(key, out var value))
			{
				return value;
			}
			string[] array = Split(arg, removeEmpty: true, ' ');
			if (array.Length < 3)
			{
				return null;
			}
			return new Color(Float(array[0]), Float(array[1]), Float(array[2]), (array.Length > 3) ? Float(array[3]) : 1f);
		}
	}
	public class Yaml
	{
		public static string BaseDirectory = Path.Combine(Paths.ConfigPath, "expand_world");

		public static string BackupDirectory = Path.Combine(Paths.ConfigPath, "expand_world_backups");

		public static List<T> Read<T>(string pattern, bool migrate)
		{
			if (!Directory.Exists(BaseDirectory))
			{
				Directory.CreateDirectory(BaseDirectory);
			}
			return Read<T>(Directory.GetFiles(BaseDirectory, pattern, SearchOption.AllDirectories).Reverse().ToList(), migrate);
		}

		public static List<T> Read<T>(List<string> files, bool migrate)
		{
			List<T> list = new List<T>();
			foreach (string file in files)
			{
				try
				{
					string raw = (migrate ? PreParse(File.ReadAllLines(file)) : File.ReadAllText(file));
					list.AddRange(Deserialize<T>(raw, file));
				}
				catch (Exception ex)
				{
					Log.Error("Error reading " + Path.GetFileName(file) + ": " + ex.Message);
				}
			}
			return list;
		}

		private static string PreParse(string[] lines)
		{
			bool flag = false;
			List<string> list = new List<string>();
			foreach (string text in lines)
			{
				if (flag)
				{
					if (text.StartsWith("  - ") && !text.Contains(":"))
					{
						HandleObjects(list, text);
						continue;
					}
					flag = false;
				}
				if (text.StartsWith("  spawn: "))
				{
					list.Add("  spawns:");
					list.Add("  - " + text.Substring(9));
				}
				else if (text.StartsWith("  swap: "))
				{
					list.Add("  swaps:");
					list.Add("  - " + text.Substring(8));
				}
				else if (text.StartsWith("  objects:") || text.StartsWith("  bannedObjects:"))
				{
					flag = true;
					list.Add(text);
				}
				else
				{
					list.Add(text);
				}
			}
			return string.Join("\n", list);
		}

		private static void HandleObjects(List<string> result, string line)
		{
			string[] array = line.Substring(4).Split(new char[1] { ',' });
			result.Add("  - prefab: " + array[0]);
			if (array.Length > 1)
			{
				Range<string> range = Parse.StringRange(array[1]);
				if (range.Min != range.Max)
				{
					result.Add("    minDistance: " + range.Min);
				}
				result.Add("    maxDistance: " + range.Max);
			}
			if (array.Length > 2)
			{
				result.Add("    data: " + array[2]);
			}
			if (array.Length > 3)
			{
				result.Add("    weight: " + array[3]);
			}
			if (array.Length > 4)
			{
				Range<string> range2 = Parse.StringRange(array[4]);
				if (range2.Min != range2.Max)
				{
					result.Add("    minHeight: " + range2.Min);
				}
				result.Add("    maxHeight: " + range2.Max);
			}
		}

		public static Biome ToBiomes(string biomeStr)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_002f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			Biome val = (Biome)0;
			if (biomeStr == "")
			{
				foreach (object value in Enum.GetValues(typeof(Biome)))
				{
					val = (Biome)(val | (Biome)value);
				}
			}
			else
			{
				string[] array = Parse.Split(biomeStr);
				foreach (string text in array)
				{
					if (Enum.TryParse<Biome>(text, ignoreCase: true, out Biome result))
					{
						val |= result;
						continue;
					}
					if (int.TryParse(text, out var result2))
					{
						val = (Biome)(val + result2);
						continue;
					}
					throw new InvalidOperationException("Invalid biome " + text + ".");
				}
			}
			return val;
		}

		public static void SetupWatcher(ConfigFile config)
		{
			ConfigFile config2 = config;
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Path.GetDirectoryName(config2.ConfigFilePath), Path.GetFileName(config2.ConfigFilePath));
			fileSystemWatcher.Changed += delegate(object s, FileSystemEventArgs e)
			{
				ReadConfigValues(e.FullPath, config2);
			};
			fileSystemWatcher.Created += delegate(object s, FileSystemEventArgs e)
			{
				ReadConfigValues(e.FullPath, config2);
			};
			fileSystemWatcher.Renamed += delegate(object s, RenamedEventArgs e)
			{
				ReadConfigValues(e.FullPath, config2);
			};
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private static void ReadConfigValues(string path, ConfigFile config)
		{
			if (!File.Exists(path))
			{
				return;
			}
			BackupFile(path);
			try
			{
				config.Reload();
			}
			catch
			{
				Log.Error("There was an issue loading your " + config.ConfigFilePath);
				Log.Error("Please check your config entries for spelling and format!");
			}
		}

		public static void SetupWatcher(string pattern, Action<string> action)
		{
			SetupWatcher(Paths.ConfigPath, pattern, action);
		}

		public static void SetupWatcher(string folder, string pattern, Action<string> action)
		{
			Action<string> action2 = action;
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(folder, pattern);
			fileSystemWatcher.Created += delegate(object s, FileSystemEventArgs e)
			{
				action2(e.FullPath);
			};
			fileSystemWatcher.Changed += delegate(object s, FileSystemEventArgs e)
			{
				action2(e.FullPath);
			};
			fileSystemWatcher.Renamed += delegate(object s, RenamedEventArgs e)
			{
				action2(e.FullPath);
			};
			fileSystemWatcher.Deleted += delegate(object s, FileSystemEventArgs e)
			{
				action2(e.FullPath);
			};
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		public static void SetupWatcher(string folder, string pattern, Action action)
		{
			Action action2 = action;
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(folder, pattern);
			fileSystemWatcher.Created += delegate
			{
				action2();
			};
			fileSystemWatcher.Changed += delegate
			{
				action2();
			};
			fileSystemWatcher.Renamed += delegate
			{
				action2();
			};
			fileSystemWatcher.Deleted += delegate
			{
				action2();
			};
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		public static void SetupWatcher(string pattern, Action action)
		{
			Action action2 = action;
			SetupWatcher(BaseDirectory, pattern, delegate(string file)
			{
				BackupFile(file);
				action2();
			});
		}

		private static void BackupFile(string path)
		{
			if (File.Exists(path))
			{
				if (!Directory.Exists(BackupDirectory))
				{
					Directory.CreateDirectory(BackupDirectory);
				}
				string text = DateTime.Now.ToString("yyyy-MM-dd");
				string path2 = Path.GetFileNameWithoutExtension(path) + "_" + text + Path.GetExtension(path) + ".bak";
				File.Copy(path, Path.Combine(BackupDirectory, path2), overwrite: true);
			}
		}

		public static void Init()
		{
			if (!Directory.Exists(BaseDirectory))
			{
				Directory.CreateDirectory(BaseDirectory);
			}
		}

		private static IDeserializer Deserializer()
		{
			return new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
		}

		private static IDeserializer DeserializerUnSafe()
		{
			return new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build();
		}

		private static List<T> Deserialize<T>(string raw, string file)
		{
			try
			{
				return Deserializer().Deserialize<List<T>>(raw) ?? new List<T>();
			}
			catch (Exception ex)
			{
				Log.Error(Path.GetFileName(file) + ": " + ex.Message);
				try
				{
					return DeserializerUnSafe().Deserialize<List<T>>(raw) ?? new List<T>();
				}
				catch (Exception)
				{
					return new List<T>();
				}
			}
		}
	}
}
namespace Data
{
	public class Calculator
	{
		public static Vector3 EvaluateVector3(string expression)
		{
			//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_0061: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			string[] array = Parse.Split(expression);
			zero.x = EvaluateFloat(array[0]).GetValueOrDefault();
			if (array.Length > 1)
			{
				zero.z = EvaluateFloat(array[1]).GetValueOrDefault();
			}
			if (array.Length > 2)
			{
				zero.y = EvaluateFloat(array[2]).GetValueOrDefault();
			}
			return zero;
		}

		public static Vector3 EvaluateVector3(string[] s, int index)
		{
			//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_0065: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			if (s.Length > index)
			{
				zero.x = EvaluateFloat(s[index]).GetValueOrDefault();
			}
			if (s.Length > index + 1)
			{
				zero.z = EvaluateFloat(s[index + 1]).GetValueOrDefault();
			}
			if (s.Length > index + 2)
			{
				zero.y = EvaluateFloat(s[index + 2]).GetValueOrDefault();
			}
			return zero;
		}

		public static Quaternion EvaluateQuaternion(string expression)
		{
			//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_0061: 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)
			Vector3 zero = Vector3.zero;
			string[] array = Parse.Split(expression);
			zero.y = EvaluateFloat(array[0]).GetValueOrDefault();
			if (array.Length > 1)
			{
				zero.x = EvaluateFloat(array[1]).GetValueOrDefault();
			}
			if (array.Length > 2)
			{
				zero.z = EvaluateFloat(array[2]).GetValueOrDefault();
			}
			return Quaternion.Euler(zero);
		}

		public static Quaternion EvaluateQuaternion(string[] s, int index)
		{
			//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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			if (s.Length > index)
			{
				zero.y = EvaluateFloat(s[index]).GetValueOrDefault();
			}
			if (s.Length > index + 1)
			{
				zero.x = EvaluateFloat(s[index + 1]).GetValueOrDefault();
			}
			if (s.Length > index + 2)
			{
				zero.z = EvaluateFloat(s[index + 2]).GetValueOrDefault();
			}
			return Quaternion.Euler(zero);
		}

		public static int? EvaluateInt(string expression)
		{
			try
			{
				return (int?)EvaluateLong(expression);
			}
			catch
			{
				return null;
			}
		}

		public static float? EvaluateFloat(string expression)
		{
			try
			{
				return (float)EvaluateDouble(expression);
			}
			catch
			{
				return null;
			}
		}

		private static double EvaluateDouble(string expression)
		{
			string[] array = expression.Split(new char[1] { '+' });
			if (array.Length > 1)
			{
				double num = 0.0;
				string[] array2 = array;
				foreach (string expression2 in array2)
				{
					num += EvaluateDouble(expression2);
				}
				return num;
			}
			string[] array3 = expression.Split(new char[1] { '-' });
			if (array3.Where((string s) => s != "").Count() > 1)
			{
				double? num2 = null;
				for (int j = 0; j < array3.Length; j++)
				{
					if (!(array3[j] == "") || j + 1 >= array3.Length)
					{
						num2 = (num2.HasValue ? (num2 - EvaluateDouble(array3[j])) : new double?(EvaluateDouble(array3[j])));
					}
					else
					{
						array3[j + 1] = "-" + array3[j + 1];
					}
				}
				return num2.GetValueOrDefault();
			}
			string[] array4 = expression.Split(new char[1] { '*' });
			if (array4.Length > 1)
			{
				double num3 = 1.0;
				string[] array2 = array4;
				foreach (string expression3 in array2)
				{
					num3 *= EvaluateDouble(expression3);
				}
				return num3;
			}
			string[] array5 = expression.Split(new char[1] { '/' });
			if (array5.Length > 1)
			{
				double num4 = EvaluateDouble(array5[0]);
				for (int k = 1; k < array5.Length; k++)
				{
					num4 /= EvaluateDouble(array5[k]);
				}
				return num4;
			}
			try
			{
				return double.Parse(expression.Trim(), NumberFormatInfo.InvariantInfo);
			}
			catch
			{
				throw new InvalidOperationException("Failed to parse expression: " + expression);
			}
		}

		public static long? EvaluateLong(string expression)
		{
			try
			{
				return EvalLong(expression);
			}
			catch
			{
				return null;
			}
		}

		private static long EvalLong(string expression)
		{
			string[] array = expression.Split(new char[1] { '+' });
			if (array.Length > 1)
			{
				long num = 0L;
				string[] array2 = array;
				foreach (string expression2 in array2)
				{
					num += EvalLong(expression2);
				}
				return num;
			}
			string[] array3 = expression.Split(new char[1] { '-' });
			if (array3.Where((string s) => s != "").Count() > 1)
			{
				long? num2 = null;
				for (int j = 0; j < array3.Length; j++)
				{
					if (!(array3[j] == "") || j + 1 >= array3.Length)
					{
						num2 = (num2.HasValue ? (num2 - EvalLong(array3[j])) : new long?(EvalLong(array3[j])));
					}
					else
					{
						array3[j + 1] = "-" + array3[j + 1];
					}
				}
				return num2.GetValueOrDefault();
			}
			string[] array4 = expression.Split(new char[1] { '*' });
			if (array4.Length > 1)
			{
				long num3 = 1L;
				string[] array2 = array4;
				foreach (string expression3 in array2)
				{
					num3 *= EvalLong(expression3);
				}
				return num3;
			}
			string[] array5 = expression.Split(new char[1] { '/' });
			if (array5.Length > 1)
			{
				long num4 = EvalLong(array5[0]);
				for (int k = 1; k < array5.Length; k++)
				{
					num4 /= EvalLong(array5[k]);
				}
				return num4;
			}
			try
			{
				return long.Parse(expression.Trim());
			}
			catch
			{
				throw new InvalidOperationException("Failed to parse expression: " + expression);
			}
		}
	}
	public class DataData
	{
		[DefaultValue(null)]
		public string? name;

		[DefaultValue(null)]
		public string? position;

		[DefaultValue(null)]
		public string? rotation;

		[DefaultValue(null)]
		public string? connection;

		[DefaultValue(null)]
		public string[]? bools;

		[DefaultValue(null)]
		public string[]? ints;

		[DefaultValue(null)]
		public string[]? hashes;

		[DefaultValue(null)]
		public string[]? floats;

		[DefaultValue(null)]
		public string[]? strings;

		[DefaultValue(null)]
		public string[]? longs;

		[DefaultValue(null)]
		public string[]? vecs;

		[DefaultValue(null)]
		public string[]? quats;

		[DefaultValue(null)]
		public string[]? bytes;

		[DefaultValue(null)]
		public ItemData[]? items;

		[DefaultValue(null)]
		public string? containerSize;

		[DefaultValue(null)]
		public string? itemAmount;

		[DefaultValue(null)]
		public string? valueGroup;

		[DefaultValue(null)]
		public string? value;

		[DefaultValue(null)]
		public string[]? values;
	}
	public class ItemData
	{
		public string pos = "";

		[DefaultValue(1f)]
		public float chance = 1f;

		[DefaultValue("")]
		public string prefab = "";

		public string? stack;

		public string? quality;

		public string? variant;

		public string? durability;

		public string? crafterID;

		public string? crafterName;

		public string? worldLevel;

		public string? equipped;

		public string? pickedUp;

		public Dictionary<string, string>? customData;
	}
	public class DataEntry
	{
		public Dictionary<int, IStringValue>? Strings;

		public Dictionary<int, IFloatValue>? Floats;

		public Dictionary<int, IIntValue>? Ints;

		public Dictionary<int, IBoolValue>? Bools;

		public Dictionary<int, IHashValue>? Hashes;

		public Dictionary<int, ILongValue>? Longs;

		public Dictionary<int, IVector3Value>? Vecs;

		public Dictionary<int, IQuaternionValue>? Quats;

		public Dictionary<int, byte[]>? ByteArrays;

		public List<ItemValue>? Items;

		public Vector2i? ContainerSize;

		public IIntValue? ItemAmount;

		public ConnectionType ConnectionType;

		public int ConnectionHash;

		public IZdoIdValue? OriginalId;

		public IZdoIdValue? TargetConnectionId;

		public IVector3Value? Position;

		public IQuaternionValue? Rotation;

		public DataEntry()
		{
		}

		public DataEntry(string base64)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			this.Load(new ZPackage(base64));
		}

		public DataEntry(DataData data)
		{
			Load(data);
		}

		public DataEntry(ZDO zdo)
		{
			Load(zdo);
		}

		private Vector2i GetContainerSize()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return (Vector2i)(((??)ContainerSize) ?? new Vector2i(4, 2));
		}

		public 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: 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_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			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) => DataValue.Simple(kvp.Value)) : null);
			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) => DataValue.Simple(kvp.Value)) : null);
			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) => DataValue.Simple(kvp.Value)) : null);
			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) => DataValue.Simple(kvp.Value)) : null);
			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) => DataValue.Simple(kvp.Value)) : null);
			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) => DataValue.Simple(kvp.Value)) : null);
			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) : null);
			if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value))
			{
				ConnectionType = value.m_type;
				ConnectionHash = value.m_hash;
			}
			OriginalId = new SimpleZdoIdValue(uid);
			if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None)
			{
				TargetConnectionId = new SimpleZdoIdValue(value2.m_target);
				ConnectionType = value2.m_type;
			}
		}

		public void Load(DataEntry data)
		{
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			if (data.Floats != null)
			{
				if (Floats == null)
				{
					Floats = new Dictionary<int, IFloatValue>();
				}
				foreach (KeyValuePair<int, IFloatValue> @float in data.Floats)
				{
					Floats[@float.Key] = @float.Value;
				}
			}
			if (data.Vecs != null)
			{
				if (Vecs == null)
				{
					Vecs = new Dictionary<int, IVector3Value>();
				}
				foreach (KeyValuePair<int, IVector3Value> vec in data.Vecs)
				{
					Vecs[vec.Key] = vec.Value;
				}
			}
			if (data.Quats != null)
			{
				if (Quats == null)
				{
					Quats = new Dictionary<int, IQuaternionValue>();
				}
				foreach (KeyValuePair<int, IQuaternionValue> quat in data.Quats)
				{
					Quats[quat.Key] = quat.Value;
				}
			}
			if (data.Ints != null)
			{
				if (Ints == null)
				{
					Ints = new Dictionary<int, IIntValue>();
				}
				foreach (KeyValuePair<int, IIntValue> @int in data.Ints)
				{
					Ints[@int.Key] = @int.Value;
				}
			}
			if (data.Strings != null)
			{
				if (Strings == null)
				{
					Strings = new Dictionary<int, IStringValue>();
				}
				foreach (KeyValuePair<int, IStringValue> @string in data.Strings)
				{
					Strings[@string.Key] = @string.Value;
				}
			}
			if (data.ByteArrays != null)
			{
				if (ByteArrays == null)
				{
					ByteArrays = new Dictionary<int, byte[]>();
				}
				foreach (KeyValuePair<int, byte[]> byteArray in data.ByteArrays)
				{
					ByteArrays[byteArray.Key] = byteArray.Value;
				}
			}
			if (data.Longs != null)
			{
				if (Longs == null)
				{
					Longs = new Dictionary<int, ILongValue>();
				}
				foreach (KeyValuePair<int, ILongValue> @long in data.Longs)
				{
					Longs[@long.Key] = @long.Value;
				}
			}
			if (data.Bools != null)
			{
				if (Bools == null)
				{
					Bools = new Dictionary<int, IBoolValue>();
				}
				foreach (KeyValuePair<int, IBoolValue> @bool in data.Bools)
				{
					Bools[@bool.Key] = @bool.Value;
				}
			}
			if (data.Hashes != null)
			{
				if (Hashes == null)
				{
					Hashes = new Dictionary<int, IHashValue>();
				}
				foreach (KeyValuePair<int, IHashValue> hash in data.Hashes)
				{
					Hashes[hash.Key] = hash.Value;
				}
			}
			if (data.Items != null)
			{
				if (Items == null)
				{
					Items = new List<ItemValue>();
				}
				foreach (ItemValue item in data.Items)
				{
					Items.Add(item);
				}
			}
			if (data.ContainerSize.HasValue)
			{
				ContainerSize = data.ContainerSize;
			}
			if (data.ItemAmount != null)
			{
				ItemAmount = data.ItemAmount;
			}
			ConnectionType = data.ConnectionType;
			ConnectionHash = data.ConnectionHash;
			OriginalId = data.OriginalId;
			TargetConnectionId = data.TargetConnectionId;
			if (data.Position != null)
			{
				Position = data.Position;
			}
			if (data.Rotation != null)
			{
				Rotation = data.Rotation;
			}
		}

		public DataEntry Reset(DataData data)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Floats = null;
			Vecs = null;
			Quats = null;
			Ints = null;
			Strings = null;
			ByteArrays = null;
			Longs = null;
			Bools = null;
			Hashes = null;
			Items = null;
			ContainerSize = null;
			ItemAmount = null;
			ConnectionType = (ConnectionType)0;
			ConnectionHash = 0;
			OriginalId = null;
			TargetConnectionId = null;
			Position = null;
			Rotation = null;
			Load(data);
			return this;
		}

		public void Load(DataData data)
		{
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_089e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			HashSet<string> hashSet = new HashSet<string>();
			if (data.floats != null)
			{
				if (Floats == null)
				{
					Floats = new Dictionary<int, IFloatValue>();
				}
				string[] floats = data.floats;
				foreach (string text in floats)
				{
					KeyValuePair<string, string> keyValuePair = Parse.Kvp(text);
					if (keyValuePair.Key == "")
					{
						throw new InvalidOperationException("Failed to parse float " + text + ".");
					}
					if (keyValuePair.Key.Contains("."))
					{
						hashSet.Add(keyValuePair.Key.Split(new char[1] { '.' })[0]);
					}
					Floats.Add(Hash(keyValuePair.Key), DataValue.Float(keyValuePair.Value));
				}
			}
			if (data.ints != null)
			{
				if (Ints == null)
				{
					Ints = new Dictionary<int, IIntValue>();
				}
				string[] floats = data.ints;
				foreach (string text2 in floats)
				{
					KeyValuePair<string, string> keyValuePair2 = Parse.Kvp(text2);
					if (keyValuePair2.Key == "")
					{
						throw new InvalidOperationException("Failed to parse int " + text2 + ".");
					}
					if (keyValuePair2.Key.Contains("."))
					{
						hashSet.Add(keyValuePair2.Key.Split(new char[1] { '.' })[0]);
					}
					Ints.Add(Hash(keyValuePair2.Key), DataValue.Int(keyValuePair2.Value));
				}
			}
			if (data.bools != null)
			{
				if (Bools == null)
				{
					Bools = new Dictionary<int, IBoolValue>();
				}
				string[] floats = data.bools;
				foreach (string text3 in floats)
				{
					KeyValuePair<string, string> keyValuePair3 = Parse.Kvp(text3);
					if (keyValuePair3.Key == "")
					{
						throw new InvalidOperationException("Failed to parse bool " + text3 + ".");
					}
					if (keyValuePair3.Key.Contains("."))
					{
						hashSet.Add(keyValuePair3.Key.Split(new char[1] { '.' })[0]);
					}
					Bools.Add(Hash(keyValuePair3.Key), DataValue.Bool(keyValuePair3.Value));
				}
			}
			if (data.hashes != null)
			{
				if (Hashes == null)
				{
					Hashes = new Dictionary<int, IHashValue>();
				}
				string[] floats = data.hashes;
				foreach (string text4 in floats)
				{
					KeyValuePair<string, string> keyValuePair4 = Parse.Kvp(text4);
					if (keyValuePair4.Key == "")
					{
						throw new InvalidOperationException("Failed to parse hash " + text4 + ".");
					}
					if (keyValuePair4.Key.Contains("."))
					{
						hashSet.Add(keyValuePair4.Key.Split(new char[1] { '.' })[0]);
					}
					Hashes.Add(Hash(keyValuePair4.Key), DataValue.Hash(keyValuePair4.Value));
				}
			}
			if (data.longs != null)
			{
				if (Longs == null)
				{
					Longs = new Dictionary<int, ILongValue>();
				}
				string[] floats = data.longs;
				foreach (string text5 in floats)
				{
					KeyValuePair<string, string> keyValuePair5 = Parse.Kvp(text5);
					if (keyValuePair5.Key == "")
					{
						throw new InvalidOperationException("Failed to parse long " + text5 + ".");
					}
					if (keyValuePair5.Key.Contains("."))
					{
						hashSet.Add(keyValuePair5.Key.Split(new char[1] { '.' })[0]);
					}
					Longs.Add(Hash(keyValuePair5.Key), DataValue.Long(keyValuePair5.Value));
				}
			}
			if (data.strings != null)
			{
				if (Strings == null)
				{
					Strings = new Dictionary<int, IStringValue>();
				}
				string[] floats = data.strings;
				foreach (string text6 in floats)
				{
					KeyValuePair<string, string> keyValuePair6 = Parse.Kvp(text6);
					if (keyValuePair6.Key == "")
					{
						throw new InvalidOperationException("Failed to parse string " + text6 + ".");
					}
					if (keyValuePair6.Key.Contains("."))
					{
						hashSet.Add(keyValuePair6.Key.Split(new char[1] { '.' })[0]);
					}
					Strings.Add(Hash(keyValuePair6.Key), DataValue.String(keyValuePair6.Value));
				}
			}
			if (data.vecs != null)
			{
				if (Vecs == null)
				{
					Vecs = new Dictionary<int, IVector3Value>();
				}
				string[] floats = data.vecs;
				foreach (string text7 in floats)
				{
					KeyValuePair<string, string> keyValuePair7 = Parse.Kvp(text7);
					if (keyValuePair7.Key == "")
					{
						throw new InvalidOperationException("Failed to parse vector " + text7 + ".");
					}
					if (keyValuePair7.Key.Contains("."))
					{
						hashSet.Add(keyValuePair7.Key.Split(new char[1] { '.' })[0]);
					}
					Vecs.Add(Hash(keyValuePair7.Key), DataValue.Vector3(keyValuePair7.Value));
				}
			}
			if (data.quats != null)
			{
				if (Quats == null)
				{
					Quats = new Dictionary<int, IQuaternionValue>();
				}
				string[] floats = data.quats;
				foreach (string text8 in floats)
				{
					KeyValuePair<string, string> keyValuePair8 = Parse.Kvp(text8);
					if (keyValuePair8.Key == "")
					{
						throw new InvalidOperationException("Failed to parse quaternion " + text8 + ".");
					}
					if (keyValuePair8.Key.Contains("."))
					{
						hashSet.Add(keyValuePair8.Key.Split(new char[1] { '.' })[0]);
					}
					Quats.Add(Hash(keyValuePair8.Key), DataValue.Quaternion(keyValuePair8.Value));
				}
			}
			if (data.bytes != null)
			{
				if (ByteArrays == null)
				{
					ByteArrays = new Dictionary<int, byte[]>();
				}
				string[] floats = data.bytes;
				foreach (string text9 in floats)
				{
					KeyValuePair<string, string> keyValuePair9 = Parse.Kvp(text9);
					if (keyValuePair9.Key == "")
					{
						throw new InvalidOperationException("Failed to parse byte array " + text9 + ".");
					}
					if (keyValuePair9.Key.Contains("."))
					{
						hashSet.Add(keyValuePair9.Key.Split(new char[1] { '.' })[0]);
					}
					ByteArrays.Add(Hash(keyValuePair9.Key), Convert.FromBase64String(keyValuePair9.Value));
				}
			}
			if (data.items != null)
			{
				Items = data.items.Select((ItemData item) => new ItemValue(item)).ToList();
			}
			if (!string.IsNullOrWhiteSpace(data.containerSize))
			{
				ContainerSize = Parse.Vector2Int(data.containerSize);
			}
			if (!string.IsNullOrWhiteSpace(data.itemAmount))
			{
				ItemAmount = DataValue.Int(data.itemAmount);
			}
			if (hashSet.Count > 0)
			{
				if (Ints == null)
				{
					Ints = new Dictionary<int, IIntValue>();
				}
				Ints[StringExtensionMethods.GetStableHashCode("HasFields")] = DataValue.Simple(1);
				foreach (string item in hashSet)
				{
					Ints[StringExtensionMethods.GetStableHashCode("HasFields" + item)] = DataValue.Simple(1);
				}
			}
			if (!string.IsNullOrWhiteSpace(data.position))
			{
				Position = DataValue.Vector3(data.position);
			}
			if (!string.IsNullOrWhiteSpace(data.rotation))
			{
				Rotation = DataValue.Quaternion(data.rotation);
			}
			if (string.IsNullOrWhiteSpace(data.connection))
			{
				return;
			}
			string[] array = Parse.SplitWithEmpty(data.connection);
			if (array.Length <= 1)
			{
				return;
			}
			List<string> list = array.Take(array.Length - 1).ToList();
			string text10 = array[^1];
			ConnectionType = ToByteEnum<ConnectionType>(list);
			if (text10.Contains(":") || text10.Contains("<"))
			{
				TargetConnectionId = DataValue.ZdoId(text10);
				OriginalId = TargetConnectionId;
				return;
			}
			ConnectionHash = Parse.Int(text10);
			if (ConnectionHash == 0)
			{
				ConnectionHash = StringExtensionMethods.GetStableHashCode(text10);
			}
		}

		public void Load(ZPackage pkg)
		{
			//IL_0086: 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_0232: Unknown result type (might be due to invalid IL or missing references)
			pkg.SetPos(0);
			int num = pkg.ReadInt();
			if (((uint)num & (true ? 1u : 0u)) != 0)
			{
				if (Floats == null)
				{
					Floats = new Dictionary<int, IFloatValue>();
				}
				byte b = pkg.ReadByte();
				for (int i = 0; i < b; i++)
				{
					Floats[pkg.ReadInt()] = new SimpleFloatValue(pkg.ReadSingle());
				}
			}
			if (((uint)num & 2u) != 0)
			{
				if (Vecs == null)
				{
					Vecs = new Dictionary<int, IVector3Value>();
				}
				byte b2 = pkg.ReadByte();
				for (int j = 0; j < b2; j++)
				{
					Vecs[pkg.ReadInt()] = new SimpleVector3Value(pkg.ReadVector3());
				}
			}
			if (((uint)num & 4u) != 0)
			{
				if (Quats == null)
				{
					Quats = new Dictionary<int, IQuaternionValue>();
				}
				byte b3 = pkg.ReadByte();
				for (int k = 0; k < b3; k++)
				{
					Quats[pkg.ReadInt()] = new SimpleQuaternionValue(pkg.ReadQuaternion());
				}
			}
			if (((uint)num & 8u) != 0)
			{
				if (Ints == null)
				{
					Ints = new Dictionary<int, IIntValue>();
				}
				byte b4 = pkg.ReadByte();
				for (int l = 0; l < b4; l++)
				{
					Ints[pkg.ReadInt()] = new SimpleIntValue(pkg.ReadInt());
				}
			}
			if (((uint)num & 0x40u) != 0)
			{
				if (Longs == null)
				{
					Longs = new Dictionary<int, ILongValue>();
				}
				byte b5 = pkg.ReadByte();
				for (int m = 0; m < b5; m++)
				{
					Longs[pkg.ReadInt()] = new SimpleLongValue(pkg.ReadLong());
				}
			}
			if (((uint)num & 0x10u) != 0)
			{
				if (Strings == null)
				{
					Strings = new Dictionary<int, IStringValue>();
				}
				byte b6 = pkg.ReadByte();
				for (int n = 0; n < b6; n++)
				{
					Strings[pkg.ReadInt()] = new SimpleStringValue(pkg.ReadString());
				}
			}
			if (((uint)num & 0x80u) != 0)
			{
				if (ByteArrays == null)
				{
					ByteArrays = new Dictionary<int, byte[]>();
				}
				byte b7 = pkg.ReadByte();
				for (int num2 = 0; num2 < b7; num2++)
				{
					ByteArrays[pkg.ReadInt()] = pkg.ReadByteArray();
				}
			}
			if (((uint)num & 0x100u) != 0)
			{
				ConnectionType = (ConnectionType)pkg.ReadByte();
				ConnectionHash = pkg.ReadInt();
			}
		}

		public bool Match(Parameters pars, ZDO zdo)
		{
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: 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)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			Parameters pars2 = pars;
			ZDO zdo2 = zdo;
			if (Strings != null && Strings.Any<KeyValuePair<int, IStringValue>>((KeyValuePair<int, IStringValue> pair) => pair.Value.Match(pars2, zdo2.GetString(pair.Key, "")) == false))
			{
				return false;
			}
			if (Floats != null && Floats.Any<KeyValuePair<int, IFloatValue>>((KeyValuePair<int, IFloatValue> pair) => pair.Value.Match(pars2, zdo2.GetFloat(pair.Key, 0f)) == false))
			{
				return false;
			}
			if (Ints != null && Ints.Any<KeyValuePair<int, IIntValue>>((KeyValuePair<int, IIntValue> pair) => pair.Value.Match(pars2, zdo2.GetInt(pair.Key, 0)) == false))
			{
				return false;
			}
			if (Longs != null && Longs.Any<KeyValuePair<int, ILongValue>>((KeyValuePair<int, ILongValue> pair) => pair.Value.Match(pars2, zdo2.GetLong(pair.Key, 0L)) == false))
			{
				return false;
			}
			if (Bools != null && Bools.Any<KeyValuePair<int, IBoolValue>>((KeyValuePair<int, IBoolValue> pair) => pair.Value.Match(pars2, zdo2.GetBool(pair.Key, false)) == false))
			{
				return false;
			}
			if (Hashes != null && Hashes.Any<KeyValuePair<int, IHashValue>>((KeyValuePair<int, IHashValue> pair) => pair.Value.Match(pars2, zdo2.GetInt(pair.Key, 0)) == false))
			{
				return false;
			}
			if (Vecs != null && Vecs.Any<KeyValuePair<int, IVector3Value>>((KeyValuePair<int, IVector3Value> pair) => pair.Value.Match(pars2, zdo2.GetVec3(pair.Key, Vector3.zero)) == false))
			{
				return false;
			}
			if (Quats != null && Quats.Any<KeyValuePair<int, IQuaternionValue>>((KeyValuePair<int, IQuaternionValue> pair) => pair.Value.Match(pars2, zdo2.GetQuaternion(pair.Key, Quaternion.identity)) == false))
			{
				return false;
			}
			if (ByteArrays != null && ByteArrays.Any<KeyValuePair<int, byte[]>>((KeyValuePair<int, byte[]> pair) => !pair.Value.SequenceEqual(zdo2.GetByteArray(pair.Key, (byte[])null))))
			{
				return false;
			}
			if (Items != null)
			{
				return ItemValue.Match(pars2, Items, zdo2, ItemAmount);
			}
			if (ItemAmount != null)
			{
				return ItemValue.Match(pars2, zdo2, ItemAmount);
			}
			if ((int)ConnectionType != 0 && TargetConnectionId != null)
			{
				ZDOID connectionZDOID = zdo2.GetConnectionZDOID(ConnectionType);
				ZDOID? val = TargetConnectionId.Get(pars2);
				if (val.HasValue)
				{
					ZDOID val2 = connectionZDOID;
					ZDOID? val3 = val;
					if (!val3.HasValue || val2 != val3.GetValueOrDefault())
					{
						return false;
					}
				}
			}
			return true;
		}

		public bool Unmatch(Parameters pars, ZDO zdo)
		{
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			Parameters pars2 = pars;
			ZDO zdo2 = zdo;
			if (Strings != null && Strings.Any<KeyValuePair<int, IStringValue>>((KeyValuePair<int, IStringValue> pair) => pair.Value.Match(pars2, zdo2.GetString(pair.Key, "")).GetValueOrDefault()))
			{
				return false;
			}
			if (Floats != null && Floats.Any<KeyValuePair<int, IFloatValue>>((KeyValuePair<int, IFloatValue> pair) => pair.Value.Match(pars2, zdo2.GetFloat(pair.Key, 0f)).GetValueOrDefault()))
			{
				return false;
			}
			if (Ints != null && Ints.Any<KeyValuePair<int, IIntValue>>((KeyValuePair<int, IIntValue> pair) => pair.Value.Match(pars2, zdo2.GetInt(pair.Key, 0)).GetValueOrDefault()))
			{
				return false;
			}
			if (Longs != null && Longs.Any<KeyValuePair<int, ILongValue>>((KeyValuePair<int, ILongValue> pair) => pair.Value.Match(pars2, zdo2.GetLong(pair.Key, 0L)).GetValueOrDefault()))
			{
				return false;
			}
			if (Bools != null && Bools.Any<KeyValuePair<int, IBoolValue>>((KeyValuePair<int, IBoolValue> pair) => pair.Value.Match(pars2, zdo2.GetBool(pair.Key, false)).GetValueOrDefault()))
			{
				return false;
			}
			if (Hashes != null && Hashes.Any<KeyValuePair<int, IHashValue>>((KeyValuePair<int, IHashValue> pair) => pair.Value.Match(pars2, zdo2.GetInt(pair.Key, 0)).GetValueOrDefault()))
			{
				return false;
			}
			if (Vecs != null && Vecs.Any<KeyValuePair<int, IVector3Value>>((KeyValuePair<int, IVector3Value> pair) => pair.Value.Match(pars2, zdo2.GetVec3(pair.Key, Vector3.zero)).GetValueOrDefault()))
			{
				return false;
			}
			if (Quats != null && Quats.Any<KeyValuePair<int, IQuaternionValue>>((KeyValuePair<int, IQuaternionValue> pair) => pair.Value.Match(pars2, zdo2.GetQuaternion(pair.Key, Quaternion.identity)).GetValueOrDefault()))
			{
				return false;
			}
			if (ByteArrays != null && ByteArrays.Any<KeyValuePair<int, byte[]>>((KeyValuePair<int, byte[]> pair) => pair.Value.SequenceEqual(zdo2.GetByteArray(pair.Key, (byte[])null))))
			{
				return false;
			}
			if (Items != null)
			{
				return !ItemValue.Match(pars2, Items, zdo2, ItemAmount);
			}
			if (ItemAmount != null)
			{
				return !ItemValue.Match(pars2, zdo2, ItemAmount);
			}
			if ((int)ConnectionType != 0 && TargetConnectionId != null)
			{
				ZDOID connectionZDOID = zdo2.GetConnectionZDOID(ConnectionType);
				ZDOID? val = TargetConnectionId.Get(pars2);
				if (val.HasValue)
				{
					ZDOID val2 = connectionZDOID;
					ZDOID? val3 = val;
					if (val3.HasValue && val2 == val3.GetValueOrDefault())
					{
						return false;
					}
				}
			}
			return true;
		}

		private static string Format(float value)
		{
			return value.ToString("0.#####", NumberFormatInfo.InvariantInfo);
		}

		private static string Format(double value)
		{
			return value.ToString("0.#####", NumberFormatInfo.InvariantInfo);
		}

		public static string PrintVectorXZY(Vector3 vector)
		{
			return vector.x.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.z.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.y.ToString("0.##", CultureInfo.InvariantCulture);
		}

		public static string PrintAngleYXZ(Quaternion quaternion)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return PrintVectorYXZ(((Quaternion)(ref quaternion)).eulerAngles);
		}

		private static string PrintVectorYXZ(Vector3 vector)
		{
			return vector.y.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.x.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.z.ToString("0.##", CultureInfo.InvariantCulture);
		}

		private static T ToByteEnum<T>(List<string> list) where T : struct, Enum
		{
			byte b = 0;
			foreach (string item in list)
			{
				string text = item.Trim();
				if (Enum.TryParse<T>(text, ignoreCase: true, out var result))
				{
					b += (byte)(object)result;
				}
				else
				{
					Log.Warning("Failed to parse value " + text + " as T.");
				}
			}
			return (T)(object)b;
		}

		public void RollItems(Parameters pars)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			List<ItemValue>? items = Items;
			if (items != null && items.Count > 0)
			{
				string value = ItemValue.LoadItems(pars, Items, GetContainerSize(), (ItemAmount?.Get(pars)).GetValueOrDefault());
				if (Strings == null)
				{
					Strings = new Dictionary<int, IStringValue>();
				}
				Strings[ZDOVars.s_items] = DataValue.Simple(value);
			}
		}

		public void AddItems(Parameters parameters, ZDO zdo)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0032: 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_006d: Expected O, but got Unknown
			if (Items == null || Items.Count == 0)
			{
				return;
			}
			Vector2i containerSize = GetContainerSize();
			Inventory val = ItemValue.CreateInventory(zdo, containerSize.x, containerSize.y);
			foreach (ItemValue item in GenerateItems(parameters, containerSize))
			{
				item.AddTo(parameters, val);
			}
			ZPackage val2 = new ZPackage();
			val.Save(val2);
			zdo.Set(ZDOVars.s_items, val2.GetBase64());
		}

		public void RemoveItems(Parameters parameters, ZDO zdo)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			if (Items == null || Items.Count == 0)
			{
				return;
			}
			Inventory val = ItemValue.CreateInventory(zdo);
			if (val.m_inventory.Count == 0)
			{
				return;
			}
			foreach (ItemValue item in GenerateItems(parameters, new Vector2i(10000, 10000)))
			{
				item.RemoveFrom(parameters, val);
			}
			ZPackage val2 = new ZPackage();
			val.Save(val2);
			zdo.Set(ZDOVars.s_items, val2.GetBase64());
		}

		public List<ItemValue> GenerateItems(Parameters pars, Vector2i size)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Items == null)
			{
				throw new ArgumentNullException("Items");
			}
			return ItemValue.Generate(pars, Items, size, (ItemAmount?.Get(pars)).GetValueOrDefault());
		}

		private void HandleConnection(ZDO ownZdo, Parameters pars)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (OriginalId == null)
			{
				return;
			}
			ZDOID uid = ownZdo.m_uid;
			if (TargetConnectionId != null)
			{
				ZDOID? val = TargetConnectionId.Get(pars);
				if (!val.HasValue)
				{
					return;
				}
				ZDO zDO = ZDOMan.instance.GetZDO(val.Value);
				if (zDO != null)
				{
					ownZdo.SetConnection(ConnectionType, val.Value);
					if ((int)ConnectionType == 1)
					{
						zDO.SetConnection((ConnectionType)1, uid);
					}
				}
				return;
			}
			ZDOID originalZdoId = OriginalId.Get(pars).Value;
			KeyValuePair<ZDOID, ZDOConnection> keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair<ZDOID, ZDOConnection> kvp) => kvp.Value.m_target == originalZdoId);
			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 static int Hash(string key)
		{
			if (Parse.TryInt(key, out var result))
			{
				return result;
			}
			if (key.StartsWith("$", StringComparison.InvariantCultureIgnoreCase))
			{
				int hash = ZSyncAnimation.GetHash(key.Substring(1));
				if (key == "$anim_speed")
				{
					return hash;
				}
				return 438569 + hash;
			}
			return StringExtensionMethods.GetStableHashCode(key);
		}
	}
	public class DataHelper
	{
		public static DataEntry? Merge(params DataEntry?[] datas)
		{
			DataEntry[] array = datas.Where((DataEntry d) => d != null).ToArray();
			if (array.Length == 0)
			{
				return null;
			}
			if (array.Length == 1)
			{
				return array[0];
			}
			DataEntry dataEntry = new DataEntry();
			DataEntry[] array2 = array;
			foreach (DataEntry data in array2)
			{
				dataEntry.Load(data);
			}
			return dataEntry;
		}

		public static bool Exists(int hash)
		{
			return DataLoading.Data.ContainsKey(hash);
		}

		public static bool Match(int hash, ZDO zdo, Parameters pars)
		{
			if (DataLoading.Data.TryGetValue(hash, out DataEntry value))
			{
				return value.Match(pars, zdo);
			}
			return false;
		}

		public static DataEntry? Get(string name)
		{
			if (!(name == ""))
			{
				return DataLoading.Get(name);
			}
			return null;
		}

		public static List<string>? GetValuesFromGroup(string group)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(group.ToLowerInvariant());
			if (DataLoading.ValueGroups.TryGetValue(stableHashCode, out List<string> value))
			{
				return value;
			}
			return null;
		}

		public static List<string> ResolvePrefabs(string values)
		{
			HashSet<string> hashSet = new HashSet<string>();
			ResolvePrefabsSub(hashSet, values);
			HashSet<string> hashSet2 = hashSet;
			List<string> list = new List<string>(hashSet2.Count);
			list.AddRange(hashSet2);
			return list;
		}

		private static void ResolvePrefabsSub(HashSet<string> prefabs, string value)
		{
			if (value == "all" || ZNetScene.instance.m_namedPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(value)))
			{
				prefabs.Add(value);
				return;
			}
			List<string> valuesFromGroup = GetValuesFromGroup(value);
			if (valuesFromGroup != null)
			{
				foreach (string item in valuesFromGroup)
				{
					ResolvePrefabsSub(prefabs, item);
				}
				return;
			}
			Log.Warning("Failed to resolve prefab: " + value);
		}

		public static string GetGlobalKey(string key)
		{
			string lower = key.ToLowerInvariant();
			return ZoneSystem.instance.m_globalKeysValues.FirstOrDefault((KeyValuePair<string, string> kvp) => kvp.Key.ToLowerInvariant() == lower).Value ?? "0";
		}
	}
	public class DataLoading
	{
		private static readonly string GamePath = Path.GetFullPath(Path.Combine("BepInEx", "config", "data"));

		private static readonly string ProfilePath = Path.GetFullPath(Path.Combine(Paths.ConfigPath, "data"));

		public static Dictionary<int, DataEntry> Data = new Dictionary<int, DataEntry>();

		public static readonly Dictionary<int, List<string>> ValueGroups = new Dictionary<int, List<string>>();

		private static readonly Dictionary<int, List<string>> DefaultValueGroups = new Dictionary<int, List<string>>();

		private static readonly int WearNTearHash = StringExtensionMethods.GetStableHashCode("wearntear");

		private static readonly int HumanoidHash = StringExtensionMethods.GetStableHashCode("humanoid");

		private static readonly int CreatureHash = StringExtensionMethods.GetStableHashCode("creature");

		private static readonly int StructureHash = StringExtensionMethods.GetStableHashCode("structure");

		public static string Pattern = "expand_data*.yaml";

		public static DataEntry Get(string name)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(name);
			if (!Data.ContainsKey(stableHashCode))
			{
				try
				{
					Data[stableHashCode] = new DataEntry(name);
				}
				catch (Exception innerException)
				{
					if (name.Contains("=") || name.Length > 32)
					{
						throw new InvalidOperationException("Can't load data value: " + name, innerException);
					}
					throw new InvalidOperationException("Can't find data entry: " + name, innerException);
				}
			}
			return Data[stableHashCode];
		}

		public static DataEntry? Get(int hash)
		{
			if (!Data.ContainsKey(hash))
			{
				return null;
			}
			return Data[hash];
		}

		public static void LoadEntries()
		{
			Dictionary<int, DataEntry> data = Data;
			Data = new Dictionary<int, DataEntry>();
			ValueGroups.Clear();
			List<DataData> list = Yaml.Read<DataData>(Directory.GetFiles(GamePath, "*.yaml").Concat(Directory.GetFiles(ProfilePath, "*.yaml")).Concat(Directory.GetFiles(Yaml.BaseDirectory, Pattern))
				.Select(Path.GetFullPath)
				.Distinct()
				.ToList(), migrate: false);
			foreach (DataData item in list)
			{
				LoadValues(item);
			}
			if (ValueGroups.Count > 0)
			{
				Log.Info($"Loaded {ValueGroups.Count} value groups.");
			}
			LoadDefaultValueGroups();
			foreach (KeyValuePair<int, List<string>> valueGroup in ValueGroups)
			{
				ResolveValues(valueGroup.Value);
			}
			foreach (KeyValuePair<int, List<string>> defaultValueGroup in DefaultValueGroups)
			{
				if (!ValueGroups.ContainsKey(defaultValueGroup.Key))
				{
					ValueGroups[defaultValueGroup.Key] = defaultValueGroup.Value;
				}
			}
			foreach (DataData item2 in list)
			{
				LoadEntry(item2, data);
			}
			PrefabHelper.ClearCache();
			Log.Info($"Loaded {Data.Count} data entries.");
		}

		private static void LoadValues(DataData data)
		{
			if (data.value != null)
			{
				KeyValuePair<string, string> keyValuePair = Parse.Kvp(data.value);
				int stableHashCode = StringExtensionMethods.GetStableHashCode(keyValuePair.Key.ToLowerInvariant());
				if (ValueGroups.ContainsKey(stableHashCode))
				{
					Log.Warning("Duplicate value group entry: " + keyValuePair.Key);
				}
				if (!ValueGroups.ContainsKey(stableHashCode))
				{
					ValueGroups[stableHashCode] = new List<string>();
				}
				ValueGroups[stableHashCode].Add(keyValuePair.Value);
			}
			if (data.valueGroup != null && data.values != null)
			{
				int stableHashCode2 = StringExtensionMethods.GetStableHashCode(data.valueGroup.ToLowerInvariant());
				if (ValueGroups.ContainsKey(stableHashCode2))
				{
					Log.Warning("Duplicate value group entry: " + data.valueGroup);
				}
				if (!ValueGroups.ContainsKey(stableHashCode2))
				{
					ValueGroups[stableHashCode2] = new List<string>();
				}
				string[] values = data.values;
				foreach (string item in values)
				{
					ValueGroups[stableHashCode2].Add(item);
				}
			}
		}

		private static void LoadEntry(DataData data, Dictionary<int, DataEntry> oldData)
		{
			if (data.name != null)
			{
				int stableHashCode = StringExtensionMethods.GetStableHashCode(data.name);
				if (Data.ContainsKey(stableHashCode))
				{
					Log.Warning("Duplicate data entry: " + data.name);
				}
				Data[stableHashCode] = (oldData.TryGetValue(stableHashCode, out DataEntry value) ? value.Reset(data) : new DataEntry(data));
			}
		}

		private static void LoadDefaultValueGroups()
		{
			if (DefaultValueGroups.Count != 0)
			{
				return;
			}
			foreach (GameObject value in ZNetScene.instance.m_namedPrefabs.Values)
			{
				if (!Object.op_Implicit((Object)(object)value))
				{
					continue;
				}
				value.GetComponentsInChildren<MonoBehaviour>(ZNetView.m_tempComponents);
				foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents)
				{
					int stableHashCode = StringExtensionMethods.GetStableHashCode(((object)tempComponent).GetType().Name.ToLowerInvariant());
					if (!DefaultValueGroups.ContainsKey(stableHashCode))
					{
						DefaultValueGroups[stableHashCode] = new List<string>();
					}
					DefaultValueGroups[stableHashCode].Add(((Object)value).name);
				}
			}
			DefaultValueGroups[CreatureHash] = DefaultValueGroups[HumanoidHash];
			DefaultValueGroups[StructureHash] = DefaultValueGroups[WearNTearHash];
		}

		private static void ResolveValues(List<string> values)
		{
			for (int i = 0; i < values.Count; i++)
			{
				string text = values[i];
				if (text.StartsWith("<", StringComparison.OrdinalIgnoreCase) && text.EndsWith(">", StringComparison.OrdinalIgnoreCase))
				{
					string text2 = text.Substring(1, text.Length - 2);
					List<string> value2;
					if (ValueGroups.TryGetValue(StringExtensionMethods.GetStableHashCode(text2.ToLowerInvariant()), out List<string> value))
					{
						values.RemoveAt(i);
						values.InsertRange(i, value);
						i--;
					}
					else if (DefaultValueGroups.TryGetValue(StringExtensionMethods.GetStableHashCode(text2.ToLowerInvariant()), out value2))
					{
						values.RemoveAt(i);
						values.InsertRange(i, value2);
						i += value2.Count - 1;
					}
				}
			}
		}

		public static void SetupWatcher()
		{
			if (!Directory.Exists(GamePath))
			{
				Directory.CreateDirectory(GamePath);
			}
			if (!Directory.Exists(ProfilePath))
			{
				Directory.CreateDirectory(ProfilePath);
			}
			if (!Directory.Exists(Yaml.BaseDirectory))
			{
				Directory.CreateDirectory(Yaml.BaseDirectory);
			}
			Yaml.SetupWatcher(GamePath, "*", LoadEntries);
			if (GamePath != ProfilePath)
			{
				Yaml.SetupWatcher(ProfilePath, "*", LoadEntries);
			}
			Yaml.SetupWatcher(Pattern, LoadEntries);
		}
	}
	public class DataValue
	{
		public static IZdoIdValue ZdoId(string values)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			string[] array = SplitWithValues(values);
			ZDOID val = Parse.ZdoId(array[0]);
			if (array.Length == 1 && val != ZDOID.None)
			{
				return new SimpleZdoIdValue(val);
			}
			return new ZdoIdValue(array);
		}

		public static IIntValue Simple(int value)
		{
			return new SimpleIntValue(value);
		}

		public static IStringValue Simple(string value)
		{
			return new SimpleStringValue(value);
		}

		public static IFloatValue Simple(float value)
		{
			return new SimpleFloatValue(value);
		}

		public static ILongValue Simple(long value)
		{
			return new SimpleLongValue(value);
		}

		public static IVector3Value Simple(Vector3 value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return new SimpleVector3Value(value);
		}

		public static IQuaternionValue Simple(Quaternion value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return new SimpleQuaternionValue(value);
		}

		public static IIntValue Int(string values)
		{
			string[] array = SplitWithValues(values);
			if (array.Length == 1 && int.TryParse(array[0], out var result))
			{
				return new SimpleIntValue(result);
			}
			return new IntValue(array);
		}

		public static IFloatValue Float(string values)
		{
			string[] array = SplitWithValues(values);
			if (array.Length == 1 && Parse.TryFloat(array[0], out var result))
			{
				return new SimpleFloatValue(result);
			}
			return new FloatValue(array);
		}

		public static ILongValue Long(string values)
		{
			string[] array = SplitWithValues(values);
			if (array.Length == 1 && long.TryParse(array[0], out var result))
			{
				return new SimpleLongValue(result);
			}
			return new LongValue(array);
		}

		public static IStringValue String(string values)
		{
			string[] array = SplitWithValues(values);
			if (array.Length == 1 && !HasParameters(array[0]))
			{
				return new SimpleStringValue(array[0]);
			}
			return new StringValue(array);
		}

		public static IBoolValue Bool(string values)
		{
			string[] array = SplitWithValues(values);
			if (array.Length == 1 && bool.TryParse(array[0], out var result))
			{
				return new SimpleBoolValue(result);
			}
			return new BoolValue(array);
		}

		public static IHashValue Hash(string values)
		{
			string[] array = SplitWithValues(values);
			if (array.Length == 1 && !HasParameters(array[0]))
			{
				return new SimpleHashValue(array[0]);
			}
			return new HashValue(array);
		}

		public static IPrefabValue Prefab(string values)
		{
			if (HasParameters(values))
			{
				return new PrefabValue(SplitWithValues(values));
			}
			List<int> prefabs = PrefabHelper.GetPrefabs(values);
			if (prefabs.Count == 0)
			{
				return new SimplePrefabValue(null);
			}
			if (prefabs.Count == 1)
			{
				return new SimplePrefabValue(prefabs[0]);
			}
			return new SimplePrefabsValue(prefabs);
		}

		public static IVector3Value Vector3(string values)
		{
			//IL_008a: 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)
			string[] array = SplitWithValues(values);
			if (HasParameters(values) || array.Length > 3)
			{
				List<string> list = new List<string>();
				for (int i = 0; i < array.Length; i += 3)
				{
					string[] value = ((i + 3 < array.Length) ? array.Skip(i).Take(3).ToArray() : array.Skip(i).ToArray());
					list.Add(string.Join(",", value));
				}
				return new Vector3Value(list.ToArray());
			}
			Vector3? val = Parse.VectorXZYNull(array);
			return new SimpleVector3Value(val.HasValue ? val.Value : Vector3.zero);
		}

		public static IQuaternionValue Quaternion(string values)
		{
			//IL_008a: 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)
			string[] array = SplitWithValues(values);
			if (HasParameters(values) || array.Length > 3)
			{
				List<string> list = new List<string>();
				for (int i = 0; i < array.Length; i += 3)
				{
					string[] value = ((i + 3 < array.Length) ? array.Skip(i).Take(3).ToArray() : array.Skip(i).ToArray());
					list.Add(string.Join(",", value));
				}
				return new QuaternionValue(list.ToArray());
			}
			Quaternion? val = Parse.AngleYXZNull(array);
			return new SimpleQuaternionValue(val.HasValue ? val.Value : Quaternion.identity);
		}

		private static bool HasParameters(string value)
		{
			if (value.Contains("<"))
			{
				return value.Contains(">");
			}
			return false;
		}

		private static string[] SplitWithValues(string str)
		{
			List<string> list = new List<string>();
			string[] array = Parse.SplitWithEmpty(str);
			foreach (string text in array)
			{
				if (!text.Contains("<") || !text.Contains(">"))
				{
					list.Add(text);
					continue;
				}
				string[] array2 = text.Split('<', '>');
				List<string> list2 = new List<string>();
				List<int> list3 = new List<int>();
				for (int j = 1; j < array2.Length; j += 2)
				{
					int stableHashCode = StringExtensionMethods.GetStableHashCode(array2[j].ToLowerInvariant());
					if (DataLoading.ValueGroups.ContainsKey(stableHashCode))
					{
						list2.Add("<" + array2[j] + ">");
						list3.Add(stableHashCode);
					}
				}
				if (list2.Count == 0)
				{
					list.Add(text);
				}
				else
				{
					SubstitueValues(list, text, list2, list3, 0);
				}
			}
			return list.ToArray();
		}

		private static void SubstitueValues(List<string> result, string format, List<string> parameters, List<int> hashes, int index)
		{
			foreach (string item in DataLoading.ValueGroups[hashes[index]])
			{
				string text = format.Replace(parameters[index], item);
				if (index == parameters.Count - 1)
				{
					result.Add(text);
				}
				else
				{
					SubstitueValues(result, text, parameters, hashes, index + 1);
				}
			}
		}
	}
	public class AnyValue
	{
		protected readonly string[] Values;

		public AnyValue(string[] values)
		{
			Values = values;
			base..ctor();
		}

		private string? RollValue()
		{
			if (Values.Length == 1)
			{
				return Values[0];
			}
			return Values[Random.Range(0, Values.Length)];
		}

		protected string? GetValue(Parameters pars)
		{
			string text = RollValue();
			if (text == null || text == "<none>")
			{
				return null;
			}
			return pars.Replace(text);
		}

		protected string? GetValue()
		{
			string text = RollValue();
			if (text != null && !(text == "<none>"))
			{
				return text;
			}
			return null;
		}

		protected List<string> GetAllValues(Parameters pars)
		{
			return (from v in Values.Select(pars.Replace)
				where v != null && v != "<none"
				select v).ToList();
		}
	}
	public class ItemValue
	{
		public IPrefabValue Prefab = DataValue.Prefab(data.prefab);

		public float Chance = data.chance;

		public IIntValue? Stack = ((data.stack == null) ? null : DataValue.Int(data.stack));

		public IFloatValue? Durability = ((data.durability == null) ? null : DataValue.Float(data.durability));

		public string Position = data.pos;

		private Vector2i RolledPosition = Parse.Vector2Int(data.pos);

		public IBoolValue? Equipped = ((data.equipped == null) ? null : DataValue.Bool(data.equipped));

		public IIntValue? Quality = ((data.quality == null) ? null : DataValue.Int(data.quality));

		public IIntValue? Variant = ((data.variant == null) ? null : DataValue.Int(data.variant));

		public ILongValue? CrafterID = ((data.crafterID == null) ? null : DataValue.Long(data.crafterID));

		public IStringValue? CrafterName = ((data.crafterName == null) ? null : DataValue.String(data.crafterName));

		public Dictionary<string, IStringValue>? CustomData = data.customData?.ToDictionary((KeyValuePair<string, string> kvp) => kvp.Key, (KeyValuePair<string, string> kvp) => DataValue.String(kvp.Value));

		public IIntValue? WorldLevel = ((data.worldLevel == null) ? null : DataValue.Int(data.worldLevel));

		public IBoolValue? PickedUp = ((data.pickedUp == null) ? null : DataValue.Bool(data.pickedUp));

		private int RolledPrefab;

		private int RolledStack;

		public ItemValue(ItemData data)
		{
		}//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)


		public static bool Match(Parameters pars, List<ItemValue> data, ZDO zdo, IIntValue? amount)
		{
			Parameters pars2 = pars;
			Inventory inv = CreateInventory(zdo);
			int num = data.Where((ItemValue item) => item.Match(pars2, inv)).Count();
			if (amount == null)
			{
				if (num == data.Count)
				{
					return inv.m_inventory.Count == 0;
				}
				return false;
			}
			return amount.Match(pars2, num).GetValueOrDefault();
		}

		public static bool Match(Parameters pars, ZDO zdo, IIntValue amount)
		{
			Inventory val = CreateInventory(zdo);
			return amount.Match(pars, val.m_inventory.Count).GetValueOrDefault();
		}

		public static Inventory CreateInventory(ZDO zdo, int width = 100000, int height = 10000)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Inventory val = new Inventory("", (Sprite)null, width, height);
			string @string = zdo.GetString(ZDOVars.s_items, "");
			if (@string != "")
			{
				ZPackage val2 = new ZPackage(@string);
				val.Load(val2);
			}
			return val;
		}

		public static string LoadItems(Parameters pars, List<ItemValue> items, Vector2i size, int amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			ZPackage val = new ZPackage();
			val.Write(106);
			items = Generate(pars, items, size, amount);
			val.Write(items.Count);
			foreach (ItemValue item in items)
			{
				item.Write(pars, val);
			}
			return val.GetBase64();
		}

		public static List<ItemValue> Generate(Parameters pars, List<ItemValue> data, Vector2i size, int amount)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			List<ItemValue> list = data.Where((ItemValue item) => item.Position != "").ToList();
			List<ItemValue> items = data.Where((ItemValue item) => item.Position == "").ToList();
			Dictionary<Vector2i, ItemValue> dictionary = new Dictionary<Vector2i, ItemValue>();
			foreach (ItemValue item in list)
			{
				if (item.Roll(pars))
				{
					dictionary[item.RolledPosition] = item;
				}
			}
			if (amount == 0)
			{
				GenerateEach(pars, dictionary, size, items);
			}
			else
			{
				GenerateAmount(pars, dictionary, size, items, amount);
			}
			Dictionary<Vector2i, ItemValue>.ValueCollection values = dictionary.Values;
			List<ItemValue> list2 = new List<ItemValue>(values.Count);
			list2.AddRange(values);
			return list2;
		}

		private static void GenerateEach(Parameters pars, Dictionary<Vector2i, ItemValue> inventory, Vector2i size, List<ItemValue> items)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			foreach (ItemValue item in items)
			{
				if (item.Roll(pars))
				{
					Vector2i? val = FindNextFreeSlot(inventory, size);
					if (!val.HasValue)
					{
						break;
					}
					item.RolledPosition = val.Value;
					inventory[val.Value] = item;
				}
			}
		}

		private static void GenerateAmount(Parameters pars, Dictionary<Vector2i, ItemValue> inventory, Vector2i size, List<ItemValue> items, int amount)
		{
			//IL_002b: 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_004b: 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)
			float num = items.Sum((ItemValue item) => item.Chance);
			for (int i = 0; i < amount; i++)
			{
				if (items.Count <= 0)
				{
					break;
				}
				Vector2i? val = FindNextFreeSlot(inventory, size);
				if (val.HasValue)
				{
					ItemValue itemValue = RollItem(items, num);
					itemValue.RolledPosition = val.Value;
					if (itemValue.RollPrefab(pars))
					{
						inventory[val.Value] = itemValue;
					}
					num -= itemValue.Chance;
					items.Remove(itemValue);
					continue;
				}
				break;
			}
		}

		private static ItemValue RollItem(List<ItemValue> items, float maxWeight)
		{
			float num = Random.Range(0f, maxWeight);
			foreach (ItemValue item in items)
			{
				if (num < item.Chance)
				{
					return item;
				}
				num -= item.Chance;
			}
			return items.Last();
		}

		private static Vector2i? FindNextFreeSlot(Dictionary<Vector2i, ItemValue> inventory, Vector2i size)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			int x = size.x;
			int y = size.y;
			Vector2i val = default(Vector2i);
			for (int i = 0; i < y; i++)
			{
				for (int j = 0; j < x; j++)
				{
					((Vector2i)(ref val))..ctor(j, i);
					if (!inventory.ContainsKey(val))
					{
						return val;
					}
				}
			}
			return null;
		}

		public bool RollPrefab(Parameters pars)
		{
			RolledPrefab = Prefab.Get(pars).GetValueOrDefault();
			RolledStack = (Stack?.Get(pars)).GetValueOrDefault(1);
			if (RolledPrefab != 0)
			{
				return RolledStack != 0;
			}
			return false;
		}

		public bool RollChance()
		{
			if (!(Chance >= 1f))
			{
				return Random.value <= Chance;
			}
			return true;
		}

		public bool Roll(Parameters pars)
		{
			if (RollChance())
			{
				return RollPrefab(pars);
			}
			return false;
		}

		public void Write(Parameters pars, ZPackage pkg)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(RolledPrefab);
			pkg.Write(((itemPrefab != null) ? ((Object)itemPrefab).name : null) ?? "");
			int valueOrDefault = (Quality?.Get(pars)).GetValueOrDefault(1);
			float? num = Durability?.Get(pars);
			if (!num.HasValue)
			{
				ItemDrop val = default(ItemDrop);
				num = ((!((Object)(object)itemPrefab != (Object)null) || !itemPrefab.TryGetComponent<ItemDrop>(ref val)) ? new float?(100f) : new float?(val.m_itemData.GetMaxDurability(valueOrDefault)));
			}
			pkg.Write(RolledStack);
			pkg.Write(num.Value);
			pkg.Write(RolledPosition);
			pkg.Write((Equipped?.GetBool(pars)).GetValueOrDefault());
			pkg.Write(valueOrDefault);
			pkg.Write((Variant?.Get(pars)).GetValueOrDefault());
			pkg.Write((CrafterID?.Get(pars)).GetValueOrDefault());
			pkg.Write(CrafterName?.Get(pars) ?? "");
			pkg.Write(CustomData?.Count ?? 0);