Decompiled source of World Edit Commands v1.66.0

WorldEditCommands.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using Data;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ServerDevcommands;
using Service;
using TMPro;
using UnityEngine;
using WorldEditCommands;

[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("WorldEditCommands")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+137064a250f5a376b653248dc60ad5c853e9692c")]
[assembly: AssemblyProduct("WorldEditCommands")]
[assembly: AssemblyTitle("WorldEditCommands")]
[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;
		}
	}
}
public static class Hash
{
	public static int Damage = StringExtensionMethods.GetStableHashCode("RandomSkillFactor");

	public static int Ammo = StringExtensionMethods.GetStableHashCode("ammo");

	public static int AmmoType = StringExtensionMethods.GetStableHashCode("ammoType");

	public static int PlantTime = StringExtensionMethods.GetStableHashCode("plantTime");

	public static int Status = StringExtensionMethods.GetStableHashCode("override_status");

	public static int Weather = StringExtensionMethods.GetStableHashCode("override_weather");

	public static int DungeonWeather = StringExtensionMethods.GetStableHashCode("override_dungeon_weather");

	public static int DungeonEnterText = StringExtensionMethods.GetStableHashCode("override_dungeon_enter_text");

	public static int DungeonEnterHover = StringExtensionMethods.GetStableHashCode("override_dungeon_enter_hover");

	public static int DungeonExitText = StringExtensionMethods.GetStableHashCode("override_dungeon_exit_text");

	public static int DungeonExitHover = StringExtensionMethods.GetStableHashCode("override_dungeon_exit_hover");

	public static int Water = StringExtensionMethods.GetStableHashCode("override_water");

	public static int Event = StringExtensionMethods.GetStableHashCode("override_event");

	public static int Effect = StringExtensionMethods.GetStableHashCode("override_effect");

	public static int Respawn = StringExtensionMethods.GetStableHashCode("override_respawn");

	public static int RespawnSpawnArea = StringExtensionMethods.GetStableHashCode("override_spawnarea_respawn");

	public static int RespawnPickable = StringExtensionMethods.GetStableHashCode("override_pickable_respawn");

	public static int SpawnHealth = StringExtensionMethods.GetStableHashCode("override_health");

	public static int TriggerNoise = StringExtensionMethods.GetStableHashCode("override_trigger_noise");

	public static int Spawn = StringExtensionMethods.GetStableHashCode("override_spawn");

	public static int SpawnSpawnArea = StringExtensionMethods.GetStableHashCode("override_spawnarea_spawn");

	public static int SpawnPickable = StringExtensionMethods.GetStableHashCode("override_pickable_spawn");

	public static int Biome = StringExtensionMethods.GetStableHashCode("override_biome");

	public static int Data = StringExtensionMethods.GetStableHashCode("override_data");

	public static int OverrideItem = StringExtensionMethods.GetStableHashCode("override_item");

	public static int OverrideItems = StringExtensionMethods.GetStableHashCode("override_items");

	public static int Items = StringExtensionMethods.GetStableHashCode("items");

	public static int SpawnEffect = StringExtensionMethods.GetStableHashCode("override_spawn_effect");

	public static int DestroyEffect = StringExtensionMethods.GetStableHashCode("override_destroy_effect");

	public static int UseEffect = StringExtensionMethods.GetStableHashCode("override_use_effect");

	public static int StartEffect = StringExtensionMethods.GetStableHashCode("override_start_effect");

	public static int SpawnItem = StringExtensionMethods.GetStableHashCode("override_spawn_item");

	public static int Faction = StringExtensionMethods.GetStableHashCode("faction");

	public static int Command = StringExtensionMethods.GetStableHashCode("override_command");

	public static int Resistances = StringExtensionMethods.GetStableHashCode("override_resistances");

	public static int Attacks = StringExtensionMethods.GetStableHashCode("override_attacks");

	public static int SpawnOffset = StringExtensionMethods.GetStableHashCode("override_spawn_offset");

	public static int Component = StringExtensionMethods.GetStableHashCode("override_component");

	public static int MinAmount = StringExtensionMethods.GetStableHashCode("override_minimum_amount");

	public static int MaxAmount = StringExtensionMethods.GetStableHashCode("override_maximum_amount");

	public static int MinLevel = StringExtensionMethods.GetStableHashCode("override_minimum_level");

	public static int MaxLevel = StringExtensionMethods.GetStableHashCode("override_maximum_level");

	public static int Conversion = StringExtensionMethods.GetStableHashCode("override_conversion");

	public static int MaxFuel = StringExtensionMethods.GetStableHashCode("override_maximum_fuel");

	public static int FuelUsage = StringExtensionMethods.GetStableHashCode("override_fuel_usage");

	public static int Speed = StringExtensionMethods.GetStableHashCode("override_speed");

	public static int MaxCover = StringExtensionMethods.GetStableHashCode("override_maximum_cover");

	public static int InputEffect = StringExtensionMethods.GetStableHashCode("override_input_effect");

	public static int OpenEffect = StringExtensionMethods.GetStableHashCode("override_open_effect");

	public static int CloseEffect = StringExtensionMethods.GetStableHashCode("override_close_effect");

	public static int LockedEffect = StringExtensionMethods.GetStableHashCode("override_locked_effect");

	public static int FuelEffect = StringExtensionMethods.GetStableHashCode("override_fuel_effect");

	public static int OutputEffect = StringExtensionMethods.GetStableHashCode("override_output_effect");

	public static int MaxNear = StringExtensionMethods.GetStableHashCode("override_max_near");

	public static int MaxTotal = StringExtensionMethods.GetStableHashCode("override_max_total");

	public static int LevelChance = StringExtensionMethods.GetStableHashCode("override_level_chance");

	public static int TriggerDistance = StringExtensionMethods.GetStableHashCode("override_trigger_distance");

	public static int OverrideText = StringExtensionMethods.GetStableHashCode("override_text");

	public static int Compendium = StringExtensionMethods.GetStableHashCode("override_compendium");

	public static int Topic = StringExtensionMethods.GetStableHashCode("override_topic");

	public static int Discover = StringExtensionMethods.GetStableHashCode("override_discover");

	public static int Delay = StringExtensionMethods.GetStableHashCode("override_delay");

	public static int ItemOffset = StringExtensionMethods.GetStableHashCode("override_item_offset");

	public static int CoverOffset = StringExtensionMethods.GetStableHashCode("override_cover_offset");

	public static int SpawnMaxY = StringExtensionMethods.GetStableHashCode("override_spawn_max_y");

	public static int Destroy = StringExtensionMethods.GetStableHashCode("override_destroy");

	public static int ItemStandPrefix = StringExtensionMethods.GetStableHashCode("override_item_stand_prefix");

	public static int ItemStandRange = StringExtensionMethods.GetStableHashCode("override_item_stand_range");

	public static int GlobalKey = StringExtensionMethods.GetStableHashCode("override_globalkey");

	public static int SpawnRadius = StringExtensionMethods.GetStableHashCode("override_spawn_radius");

	public static int NearRadius = StringExtensionMethods.GetStableHashCode("override_near_radius");

	public static int FarRadius = StringExtensionMethods.GetStableHashCode("override_far_radius");

	public static int OverrideName = StringExtensionMethods.GetStableHashCode("override_name");

	public static int TextBiome = StringExtensionMethods.GetStableHashCode("override_text_biome");

	public static int TextSpace = StringExtensionMethods.GetStableHashCode("override_text_space");

	public static int TextSleep = StringExtensionMethods.GetStableHashCode("override_text_sleep");

	public static int TextHappy = StringExtensionMethods.GetStableHashCode("override_text_happy");

	public static int TextCheck = StringExtensionMethods.GetStableHashCode("override_text_check");

	public static int TextExtract = StringExtensionMethods.GetStableHashCode("override_text_extract");

	public static int SpawnCondition = StringExtensionMethods.GetStableHashCode("override_spawn_condition");

	public static int Amount = StringExtensionMethods.GetStableHashCode("override_amount");

	public static int Wear = StringExtensionMethods.GetStableHashCode("override_wear");

	public static int Fall = StringExtensionMethods.GetStableHashCode("override_fall");

	public static int Growth = StringExtensionMethods.GetStableHashCode("override_growth");

	public static int NoInteract = StringExtensionMethods.GetStableHashCode("override_interact");

	public static int NoRender = StringExtensionMethods.GetStableHashCode("override_render");

	public static int NoCollision = StringExtensionMethods.GetStableHashCode("override_collision");

	public static int NoRestrict = StringExtensionMethods.GetStableHashCode("override_restrict");

	public static int Boss = StringExtensionMethods.GetStableHashCode("override_boss");

	public static int Smoke = StringExtensionMethods.GetStableHashCode("override_smoke");

	public static int CLLC_BossEffect = StringExtensionMethods.GetStableHashCode("CL&LC effect");

	public static int CLLC_Infusion = StringExtensionMethods.GetStableHashCode("CL&LC infusion");

	public static int CLLC_Effect = StringExtensionMethods.GetStableHashCode("CL&LC effect");

	public static int Unlock = StringExtensionMethods.GetStableHashCode("override_unlock");

	public static int DoorConsume = StringExtensionMethods.GetStableHashCode("override_door_consume");

	public static int DoorNoClose = StringExtensionMethods.GetStableHashCode("override_door_no_close");

	public static int DoorKey = StringExtensionMethods.GetStableHashCode("override_door_key");

	public static int Health = StringExtensionMethods.GetStableHashCode("health");

	public static int Level = StringExtensionMethods.GetStableHashCode("level");

	public static int Text = StringExtensionMethods.GetStableHashCode("text");

	public static int Pose = StringExtensionMethods.GetStableHashCode("pose");

	public static int Item = StringExtensionMethods.GetStableHashCode("item");

	public static int HasFields = StringExtensionMethods.GetStableHashCode("HasFields");

	public static int Variant = StringExtensionMethods.GetStableHashCode("variant");

	public static int Tamed = StringExtensionMethods.GetStableHashCode("tamed");

	public static int HuntPlayer = StringExtensionMethods.GetStableHashCode("huntplayer");

	public static int Quality = StringExtensionMethods.GetStableHashCode("quality");

	public static int Creator = StringExtensionMethods.GetStableHashCode("creator");

	public static int Stack = StringExtensionMethods.GetStableHashCode("stack");

	public static int AliveTime = StringExtensionMethods.GetStableHashCode("alive_time");

	public static int CrafterID = StringExtensionMethods.GetStableHashCode("crafterID");

	public static int CrafterName = StringExtensionMethods.GetStableHashCode("crafterName");

	public static int AddedDefaultItems = StringExtensionMethods.GetStableHashCode("addedDefaultItems");

	public static int OverrideFuel = StringExtensionMethods.GetStableHashCode("override_fuel");

	public static int Fuel = StringExtensionMethods.GetStableHashCode("fuel");

	public static int Durability = StringExtensionMethods.GetStableHashCode("durability");

	public static int Sleeping = StringExtensionMethods.GetStableHashCode("sleeping");

	public static int SpawnTime = StringExtensionMethods.GetStableHashCode("spawntime");

	public static int TamedName = StringExtensionMethods.GetStableHashCode("TamedName");

	public static int Tag = StringExtensionMethods.GetStableHashCode("tag");

	public static int Seed = StringExtensionMethods.GetStableHashCode("seed");

	public static int Location = StringExtensionMethods.GetStableHashCode("location");

	public static int SpawnPoint = StringExtensionMethods.GetStableHashCode("spawnpoint");

	public static int Scale = StringExtensionMethods.GetStableHashCode("scale");

	public static int Player = StringExtensionMethods.GetStableHashCode("Player");

	public static int BuildingSkillLevel = StringExtensionMethods.GetStableHashCode("BuildingSkill Level");

	public static int Interact = StringExtensionMethods.GetStableHashCode("override_interact");

	public static int Restrict = StringExtensionMethods.GetStableHashCode("override_restrict");

	public static int Render = StringExtensionMethods.GetStableHashCode("override_render");

	public static int Collision = StringExtensionMethods.GetStableHashCode("override_collision");

	public static int Portal = StringExtensionMethods.GetStableHashCode("portal_wood");
}
namespace Data
{
	public class DataHelper
	{
		public static ZDO Regen(ZDO existing, ZDO zdo)
		{
			ZNetScene.instance.CreateObject(zdo);
			Destroy(existing);
			return zdo;
		}

		public static ZDO Regen(ZDO existing, PlainDataEntry data)
		{
			ZDO val = CloneBase(existing);
			data.Write(val);
			ZNetScene.instance.CreateObject(val);
			Destroy(existing);
			return val;
		}

		public static void Destroy(ZDO zdo)
		{
			zdo.SetOwner(ZDOMan.instance.m_sessionID);
			if (ZNetScene.instance.m_instances.TryGetValue(zdo, out var value) && Object.op_Implicit((Object)(object)value))
			{
				ZNetScene.instance.Destroy(((Component)value).gameObject);
			}
			else
			{
				ZDOMan.instance.DestroyZDO(zdo);
			}
		}

		public static ZDO CloneBase(ZDO zdo)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			ZDO obj = ZDOMan.instance.CreateNewZDO(zdo.m_position, zdo.m_prefab);
			obj.m_prefab = zdo.m_prefab;
			obj.m_rotation = zdo.m_rotation;
			obj.Type = zdo.Type;
			obj.Distant = zdo.Distant;
			obj.Persistent = zdo.Persistent;
			obj.IncreaseDataRevision();
			return obj;
		}

		public static ZDO CloneWithKeys(ZDO zdo, string[] keys)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00af: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			HashSet<int> hashSet = keys.Select((string s) => StringExtensionMethods.GetStableHashCode(s)).ToHashSet();
			ZDO val = CloneBase(zdo);
			ZDOID uid = zdo.m_uid;
			ZDOID uid2 = val.m_uid;
			float num = default(float);
			Vector3 val2 = default(Vector3);
			Quaternion val3 = default(Quaternion);
			int num2 = default(int);
			long num3 = default(long);
			string text = default(string);
			byte[] array = default(byte[]);
			foreach (int item in hashSet)
			{
				if (ZDOExtraData.GetFloat(uid, item, ref num))
				{
					ZDOExtraData.Set(uid2, item, num);
				}
				if (ZDOExtraData.GetVec3(uid, item, ref val2))
				{
					ZDOExtraData.Set(uid2, item, val2);
				}
				if (ZDOExtraData.GetQuaternion(uid, item, ref val3))
				{
					ZDOExtraData.Set(uid2, item, val3);
				}
				if (ZDOExtraData.GetInt(uid, item, ref num2))
				{
					ZDOExtraData.Set(uid2, item, num2);
				}
				if (ZDOExtraData.GetLong(uid, item, ref num3))
				{
					ZDOExtraData.Set(uid2, item, num3);
				}
				if (ZDOExtraData.GetString(uid, item, ref text))
				{
					ZDOExtraData.Set(uid2, item, text);
				}
				if (ZDOExtraData.GetByteArray(uid, item, ref array))
				{
					ZDOExtraData.Set(uid2, item, array);
				}
			}
			return val;
		}

		public static bool HasKey(ZDO zdo, string[] keys)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			HashSet<int> hashSet = keys.Select((string s) => StringExtensionMethods.GetStableHashCode(s)).ToHashSet();
			ZDOID uid = zdo.m_uid;
			IEnumerable<int> first = from kvp in ZDOExtraData.GetFloats(uid)
				select kvp.Key;
			IEnumerable<int> second = from kvp in ZDOExtraData.GetVec3s(uid)
				select kvp.Key;
			IEnumerable<int> second2 = from kvp in ZDOExtraData.GetQuaternions(uid)
				select kvp.Key;
			IEnumerable<int> second3 = from kvp in ZDOExtraData.GetInts(uid)
				select kvp.Key;
			IEnumerable<int> second4 = from kvp in ZDOExtraData.GetLongs(uid)
				select kvp.Key;
			IEnumerable<int> second5 = from kvp in ZDOExtraData.GetStrings(uid)
				select kvp.Key;
			IEnumerable<int> second6 = from kvp in ZDOExtraData.GetByteArrays(uid)
				select kvp.Key;
			return first.Concat(second).Concat(second2).Concat(second3)
				.Concat(second4)
				.Concat(second5)
				.Concat(second6)
				.Any(hashSet.Contains);
		}

		public static ZDO CloneWithoutKeys(ZDO zdo, string[] keys)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: 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_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			HashSet<int> hashed = keys.Select((string s) => StringExtensionMethods.GetStableHashCode(s)).ToHashSet();
			ZDO val = CloneBase(zdo);
			ZDOID uid = zdo.m_uid;
			ZDOID uid2 = val.m_uid;
			Dictionary<int, float> dictionary = (from kvp in ZDOExtraData.GetFloats(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, float> kvp) => kvp.Key, (KeyValuePair<int, float> kvp) => kvp.Value);
			Dictionary<int, Vector3> dictionary2 = (from kvp in ZDOExtraData.GetVec3s(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, Vector3> kvp) => kvp.Key, (KeyValuePair<int, Vector3> kvp) => kvp.Value);
			Dictionary<int, Quaternion> dictionary3 = (from kvp in ZDOExtraData.GetQuaternions(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, Quaternion> kvp) => kvp.Key, (KeyValuePair<int, Quaternion> kvp) => kvp.Value);
			Dictionary<int, int> dictionary4 = (from kvp in ZDOExtraData.GetInts(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, int> kvp) => kvp.Key, (KeyValuePair<int, int> kvp) => kvp.Value);
			Dictionary<int, long> dictionary5 = (from kvp in ZDOExtraData.GetLongs(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, long> kvp) => kvp.Key, (KeyValuePair<int, long> kvp) => kvp.Value);
			Dictionary<int, string> dictionary6 = (from kvp in ZDOExtraData.GetStrings(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, string> kvp) => kvp.Key, (KeyValuePair<int, string> kvp) => kvp.Value);
			Dictionary<int, byte[]> dictionary7 = (from kvp in ZDOExtraData.GetByteArrays(uid)
				where !hashed.Contains(kvp.Key)
				select kvp).ToDictionary((KeyValuePair<int, byte[]> kvp) => kvp.Key, (KeyValuePair<int, byte[]> kvp) => kvp.Value);
			foreach (KeyValuePair<int, float> item in dictionary)
			{
				ZDOExtraData.Set(uid2, item.Key, item.Value);
			}
			foreach (KeyValuePair<int, Vector3> item2 in dictionary2)
			{
				ZDOExtraData.Set(uid2, item2.Key, item2.Value);
			}
			foreach (KeyValuePair<int, Quaternion> item3 in dictionary3)
			{
				ZDOExtraData.Set(uid2, item3.Key, item3.Value);
			}
			foreach (KeyValuePair<int, int> item4 in dictionary4)
			{
				ZDOExtraData.Set(uid2, item4.Key, item4.Value);
			}
			foreach (KeyValuePair<int, long> item5 in dictionary5)
			{
				ZDOExtraData.Set(uid2, item5.Key, item5.Value);
			}
			foreach (KeyValuePair<int, string> item6 in dictionary6)
			{
				ZDOExtraData.Set(uid2, item6.Key, item6.Value);
			}
			foreach (KeyValuePair<int, byte[]> item7 in dictionary7)
			{
				ZDOExtraData.Set(uid2, item7.Key, item7.Value);
			}
			return val;
		}

		public static List<string> Print(ZDO zdo)
		{
			//IL_0012: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab(zdo.m_prefab);
			ZDOID uid = zdo.m_uid;
			List<string> collection = new List<string>(6)
			{
				$"Id: {uid}",
				"Prefab: " + (Object.op_Implicit((Object)(object)prefab) ? ((Object)prefab).name : "Unknown"),
				$"Owner: {zdo.GetOwner()}",
				"Position: " + Helper.PrintVectorXZY(zdo.m_position) + " (vec x,z,y)",
				"Rotation: " + Helper.PrintVectorYXZ(zdo.m_rotation) + " (quat y,x,z)",
				$"Revision: {zdo.DataRevision} + {zdo.OwnerRevision}"
			};
			IEnumerable<string> collection2 = from kvp in ZDOExtraData.GetVec3s(uid)
				select ZDOKeys.Convert(kvp.Key) + ": " + Helper.PrintVectorXZY(kvp.Value) + " (vec x,z,y)";
			IEnumerable<string> collection3 = from kvp in ZDOExtraData.GetInts(uid)
				select $"{ZDOKeys.Convert(kvp.Key)}: {kvp.Value} (int)";
			IEnumerable<string> collection4 = from kvp in ZDOExtraData.GetFloats(uid)
				select $"{ZDOKeys.Convert(kvp.Key)}: {kvp.Value} (float)";
			IEnumerable<string> collection5 = from kvp in ZDOExtraData.GetQuaternions(uid)
				select ZDOKeys.Convert(kvp.Key) + ": " + Helper.PrintAngleYXZ(kvp.Value) + " (quat y,x,z)";
			IEnumerable<string> collection6 = from kvp in ZDOExtraData.GetStrings(uid)
				select ZDOKeys.Convert(kvp.Key) + ": " + kvp.Value + " (string)";
			IEnumerable<string> collection7 = from kvp in ZDOExtraData.GetLongs(uid)
				select $"{ZDOKeys.Convert(kvp.Key)}: {kvp.Value} (long)";
			IEnumerable<string> collection8 = from kvp in ZDOExtraData.GetByteArrays(uid)
				select ZDOKeys.Convert(kvp.Key) + ": " + Convert.ToBase64String(kvp.Value) + " (byte array)";
			List<string> list = new List<string>();
			list.AddRange(collection);
			list.AddRange(collection2);
			list.AddRange(collection3);
			list.AddRange(collection4);
			list.AddRange(collection5);
			list.AddRange(collection6);
			list.AddRange(collection7);
			list.AddRange(collection8);
			return list;
		}

		public static ZDO? Init(int prefab, Transform tr, DataEntry? data)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			CleanUp();
			GameObject prefab2 = ZNetScene.instance.GetPrefab(prefab);
			if (!Object.op_Implicit((Object)(object)prefab2))
			{
				return null;
			}
			return Init(prefab2, tr.position, tr.rotation, tr.lossyScale, data, new Dictionary<string, string>());
		}

		public static ZDO? Init(GameObject obj, Vector3 pos, Quaternion rot, Vector3? scale, DataEntry? data, Dictionary<string, string> pars)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			CleanUp();
			if (data == null && !scale.HasValue)
			{
				return null;
			}
			ZNetView val = default(ZNetView);
			if (!obj.TryGetComponent<ZNetView>(ref val))
			{
				return null;
			}
			int stableHashCode = StringExtensionMethods.GetStableHashCode(Utils.GetPrefabName(obj));
			ZNetView.m_initZDO = ZDOMan.instance.CreateNewZDO(pos, stableHashCode);
			data?.Write(pars, ZNetView.m_initZDO);
			ZNetView.m_initZDO.m_rotation = ((Quaternion)(ref rot)).eulerAngles;
			ZNetView.m_initZDO.Type = val.m_type;
			ZNetView.m_initZDO.Distant = val.m_distant;
			ZNetView.m_initZDO.Persistent = val.m_persistent;
			ZNetView.m_initZDO.m_prefab = stableHashCode;
			if (!val.m_syncInitialScale && scale.HasValue && global::WorldEditCommands.WorldEditCommands.IsTweaks)
			{
				ZNetView.m_initZDO.Set(Hash.HasFields, true);
				ZNetView.m_initZDO.Set("HasFieldsZNetView", true);
				ZNetView.m_initZDO.Set("ZNetView.m_syncInitialScale", true);
				val.m_syncInitialScale = true;
				((Terminal)Console.instance).AddString("Note: Scaling set to true.");
			}
			if (val.m_syncInitialScale && scale.HasValue)
			{
				ZNetView.m_initZDO.Set(ZDOVars.s_scaleHash, scale.Value);
			}
			ZNetView.m_initZDO.DataRevision = 0u;
			ZNetView.m_initZDO.IncreaseDataRevision();
			return ZNetView.m_initZDO;
		}

		public static void CleanUp()
		{
			ZNetView.m_initZDO = null;
		}

		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 DataEntry Get(string name)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(name);
			if (!DataLoading.Data.ContainsKey(stableHashCode))
			{
				try
				{
					DataLoading.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 DataLoading.Data[stableHashCode];
		}

		public static string Base64(Dictionary<string, string> pars, string data)
		{
			if (!DataLoading.Data.TryGetValue(StringExtensionMethods.GetStableHashCode(data), out DataEntry value))
			{
				return data;
			}
			return value.GetBase64(pars);
		}
	}
	public class Calculator
	{
		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(), NumberFormatInfo.InvariantInfo);
			}
			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 = "";

		[DefaultValue("1")]
		public string stack = "1";

		[DefaultValue("1")]
		public string quality = "1";

		[DefaultValue("0")]
		public string variant = "0";

		[DefaultValue("0")]
		public string durability = "0";

		[DefaultValue("0")]
		public string crafterID = "0";

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

		[DefaultValue("0")]
		public string worldLevel = "0";

		[DefaultValue("false")]
		public string equipped = "false";

		[DefaultValue("false")]
		public string pickedUp = "false";

		[DefaultValue(null)]
		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 ZDOID OriginalId = ZDOID.None;

		public ZDOID TargetConnectionId = ZDOID.None;

		public HashSet<string> RequiredParameters = new HashSet<string>();

		public DataEntry()
		{
		}//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_000c: 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)


		public DataEntry(string base64)
		{
			//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_000c: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			this.Load(new ZPackage(base64));
		}

		public DataEntry(DataData data)
		{
			//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_000c: 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)
			Load(data);
		}

		public DataEntry(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_000c: 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)
			Load(zdo);
		}

		public void Set(int key, string value)
		{
			if (Strings == null)
			{
				Strings = new Dictionary<int, IStringValue>();
			}
			Strings[key] = new SimpleStringValue(value);
		}

		public void Set(int key, float value)
		{
			if (Floats == null)
			{
				Floats = new Dictionary<int, IFloatValue>();
			}
			Floats[key] = new SimpleFloatValue(value);
		}

		public void Set(int key, int value)
		{
			if (Ints == null)
			{
				Ints = new Dictionary<int, IIntValue>();
			}
			Ints[key] = new SimpleIntValue(value);
		}

		public void Set(int key, bool value)
		{
			if (Bools == null)
			{
				Bools = new Dictionary<int, IBoolValue>();
			}
			Bools[key] = new SimpleBoolValue(value);
		}

		public void Set(int key, long value)
		{
			if (Longs == null)
			{
				Longs = new Dictionary<int, ILongValue>();
			}
			Longs[key] = new SimpleLongValue(value);
		}

		public void Set(int key, Vector3 value)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Vecs == null)
			{
				Vecs = new Dictionary<int, IVector3Value>();
			}
			Vecs[key] = new SimpleVector3Value(value);
		}

		public void Set(int key, Quaternion value)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Quats == null)
			{
				Quats = new Dictionary<int, IQuaternionValue>();
			}
			Quats[key] = new SimpleQuaternionValue(value);
		}

		public void Set(int key, byte[] value)
		{
			if (ByteArrays == null)
			{
				ByteArrays = new Dictionary<int, byte[]>();
			}
			ByteArrays[key] = value;
		}

		public bool TryGetString(Dictionary<string, string> pars, int key, out string value)
		{
			value = "";
			if (Strings == null || !Strings.TryGetValue(key, out IStringValue value2))
			{
				return false;
			}
			string text = value2.Get(pars);
			if (text == null)
			{
				return false;
			}
			value = text;
			return true;
		}

		public bool TryGetFloat(Dictionary<string, string> pars, int key, out float value)
		{
			value = 0f;
			if (Floats == null || !Floats.TryGetValue(key, out IFloatValue value2))
			{
				return false;
			}
			float? num = value2.Get(pars);
			if (!num.HasValue)
			{
				return false;
			}
			value = num.Value;
			return true;
		}

		public bool TryGetInt(Dictionary<string, string> pars, int key, out int value)
		{
			value = 0;
			if (Ints == null || !Ints.TryGetValue(key, out IIntValue value2))
			{
				return false;
			}
			int? num = value2.Get(pars);
			if (!num.HasValue)
			{
				return false;
			}
			value = num.Value;
			return true;
		}

		public bool TryGetBool(Dictionary<string, string> pars, int key, out bool value)
		{
			value = false;
			if (Bools == null || !Bools.TryGetValue(key, out IBoolValue value2))
			{
				return false;
			}
			int? @int = value2.GetInt(pars);
			if (!@int.HasValue)
			{
				return false;
			}
			value = @int.Value != 0;
			return true;
		}

		public bool TryGetHash(Dictionary<string, string> pars, int key, out int value)
		{
			value = 0;
			if (Hashes == null || !Hashes.TryGetValue(key, out IHashValue value2))
			{
				return false;
			}
			int? num = value2.Get(pars);
			if (!num.HasValue)
			{
				return false;
			}
			value = num.Value;
			return true;
		}

		public bool TryGetLong(Dictionary<string, string> pars, int key, out long value)
		{
			value = 0L;
			if (Longs == null || !Longs.TryGetValue(key, out ILongValue value2))
			{
				return false;
			}
			long? num = value2.Get(pars);
			if (!num.HasValue)
			{
				return false;
			}
			value = num.Value;
			return true;
		}

		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)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: 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;
			foreach (string requiredParameter in data.RequiredParameters)
			{
				RequiredParameters.Add(requiredParameter);
			}
		}

		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_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: 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_0301: 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_0314: 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_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			ZDOID uid = zdo.m_uid;
			Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, float>>)ZDOExtraData.s_floats[uid]).ToDictionary((Func<KeyValuePair<int, float>, int>)((KeyValuePair<int, float> kvp) => kvp.Key), (Func<KeyValuePair<int, float>, IFloatValue>)((KeyValuePair<int, float> kvp) => new SimpleFloatValue(kvp.Value))) : null);
			Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Vector3>>)ZDOExtraData.s_vec3[uid]).ToDictionary((Func<KeyValuePair<int, Vector3>, int>)((KeyValuePair<int, Vector3> kvp) => kvp.Key), (Func<KeyValuePair<int, Vector3>, IVector3Value>)((KeyValuePair<int, Vector3> kvp) => new SimpleVector3Value(kvp.Value))) : null);
			Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Quaternion>>)ZDOExtraData.s_quats[uid]).ToDictionary((Func<KeyValuePair<int, Quaternion>, int>)((KeyValuePair<int, Quaternion> kvp) => kvp.Key), (Func<KeyValuePair<int, Quaternion>, IQuaternionValue>)((KeyValuePair<int, Quaternion> kvp) => new SimpleQuaternionValue(kvp.Value))) : null);
			Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, int>>)ZDOExtraData.s_ints[uid]).ToDictionary((Func<KeyValuePair<int, int>, int>)((KeyValuePair<int, int> kvp) => kvp.Key), (Func<KeyValuePair<int, int>, IIntValue>)((KeyValuePair<int, int> kvp) => new SimpleIntValue(kvp.Value))) : null);
			Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, string>>)ZDOExtraData.s_strings[uid]).ToDictionary((Func<KeyValuePair<int, string>, int>)((KeyValuePair<int, string> kvp) => kvp.Key), (Func<KeyValuePair<int, string>, IStringValue>)((KeyValuePair<int, string> kvp) => new SimpleStringValue(kvp.Value))) : null);
			Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, long>>)ZDOExtraData.s_longs[uid]).ToDictionary((Func<KeyValuePair<int, long>, int>)((KeyValuePair<int, long> kvp) => kvp.Key), (Func<KeyValuePair<int, long>, ILongValue>)((KeyValuePair<int, long> kvp) => new SimpleLongValue(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 = uid;
			if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None)
			{
				TargetConnectionId = value2.m_target;
				ConnectionType = value2.m_type;
			}
		}

		public void Load(DataData data)
		{
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0884: 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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters));
				}
			}
			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, RequiredParameters)).ToList();
			}
			if (!string.IsNullOrWhiteSpace(data.containerSize))
			{
				ContainerSize = Parse.Vector2Int(data.containerSize);
			}
			if (!string.IsNullOrWhiteSpace(data.itemAmount))
			{
				ItemAmount = DataValue.Int(data.itemAmount, RequiredParameters);
			}
			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.connection))
			{
				return;
			}
			string[] array = Parse.SplitWithEmpty(data.connection, ',');
			if (array.Length > 1)
			{
				List<string> list = array.Take(array.Length - 1).ToList();
				string text10 = array[^1];
				ConnectionType = ToByteEnum<ConnectionType>(list);
				ConnectionHash = Parse.Int(text10, 0);
				if (ConnectionHash == 0)
				{
					ConnectionHash = StringExtensionMethods.GetStableHashCode(text10);
				}
			}
		}

		public void Load(ZPackage pkg)
		{
			//IL_0214: 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()] = DataValue.Float(pkg);
				}
			}
			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()] = DataValue.Vector3(pkg);
				}
			}
			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()] = DataValue.Quaternion(pkg);
				}
			}
			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()] = DataValue.Int(pkg);
				}
			}
			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()] = DataValue.Long(pkg);
				}
			}
			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()] = DataValue.String(pkg);
				}
			}
			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(Dictionary<string, string> pars, ZDO zdo)
		{
			Dictionary<string, string> pars2 = pars;
			ZDO zdo2 = zdo;
			AddParameters(pars2, zdo2);
			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;
			}
			return true;
		}

		public bool Unmatch(Dictionary<string, string> pars, ZDO zdo)
		{
			Dictionary<string, string> pars2 = pars;
			ZDO zdo2 = zdo;
			AddParameters(pars2, zdo2);
			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;
			}
			return true;
		}

		private void AddParameters(Dictionary<string, string> pars, ZDO? zdo)
		{
			string[] array = pars.Values.ToArray();
			foreach (string value in array)
			{
				AddNestedParameters(value, pars, zdo);
			}
			foreach (string requiredParameter in RequiredParameters)
			{
				string key = "<" + requiredParameter + ">";
				if (!pars.ContainsKey(key))
				{
					AddParameter(requiredParameter, pars, zdo);
				}
			}
		}

		private void AddNestedParameters(string value, Dictionary<string, string> pars, ZDO? zdo)
		{
			if (!value.Contains("<"))
			{
				return;
			}
			string[] array = value.Split('<', '>');
			for (int i = 1; i < array.Length; i += 2)
			{
				string key = "<" + array[i] + ">";
				if (!pars.ContainsKey(key))
				{
					AddParameter(array[i], pars, zdo);
				}
			}
		}

		private void AddParameter(string par, Dictionary<string, string> pars, ZDO? zdo)
		{
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			string text = "<" + par + ">";
			if (DataLoading.TryGetValueFromGroup(par, out string value))
			{
				pars[text] = value;
				AddNestedParameters(value, pars, zdo);
			}
			else if (text.Contains("_"))
			{
				if (zdo == null)
				{
					return;
				}
				string[] array = par.Split(new char[1] { '_' });
				if (array.Length >= 2)
				{
					string text2 = array[0];
					string text3 = array[1];
					text = "<" + text2 + "_" + text3 + ">";
					switch (text2)
					{
					case "string":
						pars[text] = zdo.GetString(text3, "");
						break;
					case "float":
						pars[text] = zdo.GetFloat(text3, 0f).ToString(CultureInfo.InvariantCulture);
						break;
					case "int":
						pars[text] = zdo.GetInt(text3, 0).ToString(CultureInfo.InvariantCulture);
						break;
					case "long":
						pars[text] = zdo.GetLong(text3, 0L).ToString(CultureInfo.InvariantCulture);
						break;
					case "bool":
						pars[text] = zdo.GetBool(text3, false).ToString();
						break;
					case "hash":
						pars[text] = zdo.GetInt(text3, 0).ToString(CultureInfo.InvariantCulture);
						break;
					case "vec":
						pars[text] = Helper.PrintVectorXZY(zdo.GetVec3(text3, Vector3.zero));
						break;
					case "quat":
						pars[text] = Helper.PrintAngleYXZ(zdo.GetQuaternion(text3, Quaternion.identity));
						break;
					case "byte":
						pars[text] = Convert.ToBase64String(zdo.GetByteArray(text3, (byte[])null));
						break;
					}
				}
			}
			else if (text == "<x>" && zdo != null)
			{
				pars[text] = zdo.m_position.x.ToString(CultureInfo.InvariantCulture);
			}
			else if (text == "<y>" && zdo != null)
			{
				pars[text] = zdo.m_position.y.ToString(CultureInfo.InvariantCulture);
			}
			else if (text == "<z>" && zdo != null)
			{
				pars[text] = zdo.m_position.z.ToString(CultureInfo.InvariantCulture);
			}
			else if (text == "<rot>" && zdo != null)
			{
				pars[text] = Helper.PrintAngleYXZ(zdo.GetRotation());
			}
		}

		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
				{
					ServerDevcommands.Log.LogWarning((object)("Failed to parse value " + text + " as T."));
				}
			}
			return (T)(object)b;
		}

		public void Write(Dictionary<string, string> pars, ZDO zdo)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			AddParameters(pars, zdo);
			RollItems(pars);
			ZDOID uid = zdo.m_uid;
			Dictionary<int, IFloatValue>? floats = Floats;
			if (floats != null && floats.Count > 0)
			{
				ZDOHelper.Init<float>(ZDOExtraData.s_floats, uid);
				foreach (KeyValuePair<int, IFloatValue> @float in Floats)
				{
					float? num = @float.Value.Get(pars);
					if (num.HasValue)
					{
						ZDOExtraData.s_floats[uid].SetValue(@float.Key, num.Value);
					}
				}
			}
			Dictionary<int, IVector3Value>? vecs = Vecs;
			if (vecs != null && vecs.Count > 0)
			{
				ZDOHelper.Init<Vector3>(ZDOExtraData.s_vec3, uid);
				foreach (KeyValuePair<int, IVector3Value> vec in Vecs)
				{
					Vector3? val = vec.Value.Get(pars);
					if (val.HasValue)
					{
						ZDOExtraData.s_vec3[uid].SetValue(vec.Key, val.Value);
					}
				}
			}
			Dictionary<int, IQuaternionValue>? quats = Quats;
			if (quats != null && quats.Count > 0)
			{
				ZDOHelper.Init<Quaternion>(ZDOExtraData.s_quats, uid);
				foreach (KeyValuePair<int, IQuaternionValue> quat in Quats)
				{
					Quaternion? val2 = quat.Value.Get(pars);
					if (val2.HasValue)
					{
						ZDOExtraData.s_quats[uid].SetValue(quat.Key, val2.Value);
					}
				}
			}
			Dictionary<int, IIntValue>? ints = Ints;
			if (ints != null && ints.Count > 0)
			{
				ZDOHelper.Init<int>(ZDOExtraData.s_ints, uid);
				foreach (KeyValuePair<int, IIntValue> int2 in Ints)
				{
					int? num2 = int2.Value.Get(pars);
					if (num2.HasValue)
					{
						ZDOExtraData.s_ints[uid].SetValue(int2.Key, num2.Value);
					}
				}
			}
			Dictionary<int, IHashValue>? hashes = Hashes;
			if (hashes != null && hashes.Count > 0)
			{
				ZDOHelper.Init<int>(ZDOExtraData.s_ints, uid);
				foreach (KeyValuePair<int, IHashValue> hash in Hashes)
				{
					int? num3 = hash.Value.Get(pars);
					if (num3.HasValue)
					{
						ZDOExtraData.s_ints[uid].SetValue(hash.Key, num3.Value);
					}
				}
			}
			Dictionary<int, IBoolValue>? bools = Bools;
			if (bools != null && bools.Count > 0)
			{
				ZDOHelper.Init<int>(ZDOExtraData.s_ints, uid);
				foreach (KeyValuePair<int, IBoolValue> @bool in Bools)
				{
					int? @int = @bool.Value.GetInt(pars);
					if (@int.HasValue)
					{
						ZDOExtraData.s_ints[uid].SetValue(@bool.Key, @int.Value);
					}
				}
			}
			Dictionary<int, ILongValue>? longs = Longs;
			if (longs != null && longs.Count > 0)
			{
				ZDOHelper.Init<long>(ZDOExtraData.s_longs, uid);
				foreach (KeyValuePair<int, ILongValue> @long in Longs)
				{
					long? num4 = @long.Value.Get(pars);
					if (num4.HasValue)
					{
						ZDOExtraData.s_longs[uid].SetValue(@long.Key, num4.Value);
					}
				}
			}
			Dictionary<int, IStringValue>? strings = Strings;
			if (strings != null && strings.Count > 0)
			{
				ZDOHelper.Init<string>(ZDOExtraData.s_strings, uid);
				foreach (KeyValuePair<int, IStringValue> @string in Strings)
				{
					string text = @string.Value.Get(pars);
					if (text != null)
					{
						ZDOExtraData.s_strings[uid].SetValue(@string.Key, text);
					}
				}
			}
			Dictionary<int, byte[]>? byteArrays = ByteArrays;
			if (byteArrays != null && byteArrays.Count > 0)
			{
				ZDOHelper.Init<byte[]>(ZDOExtraData.s_byteArrays, uid);
				foreach (KeyValuePair<int, byte[]> byteArray in ByteArrays)
				{
					ZDOExtraData.s_byteArrays[uid].SetValue(byteArray.Key, byteArray.Value);
				}
			}
			HandleConnection(zdo);
			HandleHashConnection(zdo);
		}

		public string GetBase64(Dictionary<string, string> pars)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			Write(pars, val);
			return val.GetBase64();
		}

		public void Write(Dictionary<string, string> pars, ZPackage pkg)
		{
			//IL_0093: 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_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Expected I4, but got Unknown
			Dictionary<string, string> pars2 = pars;
			AddParameters(pars2, null);
			RollItems(pars2);
			int num = 0;
			if (Floats != null)
			{
				num |= 1;
			}
			if (Vecs != null)
			{
				num |= 2;
			}
			if (Quats != null)
			{
				num |= 4;
			}
			if (Ints != null || Hashes != null || Bools != null)
			{
				num |= 8;
			}
			if (Strings != null)
			{
				num |= 0x10;
			}
			if (Longs != null)
			{
				num |= 0x40;
			}
			if (ByteArrays != null)
			{
				num |= 0x80;
			}
			if ((int)ConnectionType != 0 && ConnectionHash != 0)
			{
				num |= 0x100;
			}
			pkg.Write(num);
			if (Floats != null)
			{
				KeyValuePair<int, float?>[] array = (from kvp in Floats
					select new KeyValuePair<int, float?>(kvp.Key, kvp.Value.Get(pars2)) into kvp
					where kvp.Value.HasValue
					select kvp).ToArray();
				pkg.Write((byte)array.Count());
				KeyValuePair<int, float?>[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					KeyValuePair<int, float?> keyValuePair = array2[i];
					pkg.Write(keyValuePair.Key);
					pkg.Write(keyValuePair.Value.Value);
				}
			}
			if (Vecs != null)
			{
				KeyValuePair<int, Vector3?>[] array3 = (from kvp in Vecs
					select new KeyValuePair<int, Vector3?>(kvp.Key, kvp.Value.Get(pars2)) into kvp
					where kvp.Value.HasValue
					select kvp).ToArray();
				pkg.Write((byte)array3.Count());
				KeyValuePair<int, Vector3?>[] array4 = array3;
				for (int i = 0; i < array4.Length; i++)
				{
					KeyValuePair<int, Vector3?> keyValuePair2 = array4[i];
					pkg.Write(keyValuePair2.Key);
					pkg.Write(keyValuePair2.Value.Value);
				}
			}
			if (Quats != null)
			{
				KeyValuePair<int, Quaternion?>[] array5 = (from kvp in Quats
					select new KeyValuePair<int, Quaternion?>(kvp.Key, kvp.Value.Get(pars2)) into kvp
					where kvp.Value.HasValue
					select kvp).ToArray();
				pkg.Write((byte)array5.Count());
				KeyValuePair<int, Quaternion?>[] array6 = array5;
				for (int i = 0; i < array6.Length; i++)
				{
					KeyValuePair<int, Quaternion?> keyValuePair3 = array6[i];
					pkg.Write(keyValuePair3.Key);
					pkg.Write(keyValuePair3.Value.Value);
				}
			}
			if (Ints != null || Hashes != null || Bools != null)
			{
				KeyValuePair<int, int?>[] obj = (from kvp in Ints?.Select((KeyValuePair<int, IIntValue> kvp) => new KeyValuePair<int, int?>(kvp.Key, kvp.Value.Get(pars2)))
					where kvp.Value.HasValue
					select kvp).ToArray() ?? Array.Empty<KeyValuePair<int, int?>>();
				KeyValuePair<int, int?>[] array7 = (from kvp in Hashes?.Select((KeyValuePair<int, IHashValue> kvp) => new KeyValuePair<int, int?>(kvp.Key, kvp.Value.Get(pars2)))
					where kvp.Value.HasValue
					select kvp).ToArray() ?? Array.Empty<KeyValuePair<int, int?>>();
				KeyValuePair<int, int?>[] array8 = (from kvp in Bools?.Select((KeyValuePair<int, IBoolValue> kvp) => new KeyValuePair<int, int?>(kvp.Key, kvp.Value.GetInt(pars2)))
					where kvp.Value.HasValue
					select kvp).ToArray() ?? Array.Empty<KeyValuePair<int, int?>>();
				int num2 = obj.Length + array7.Length + array8.Length;
				pkg.Write((byte)num2);
				KeyValuePair<int, int?>[] array9 = obj;
				for (int i = 0; i < array9.Length; i++)
				{
					KeyValuePair<int, int?> keyValuePair4 = array9[i];
					pkg.Write(keyValuePair4.Key);
					pkg.Write(keyValuePair4.Value.Value);
				}
				array9 = array7;
				for (int i = 0; i < array9.Length; i++)
				{
					KeyValuePair<int, int?> keyValuePair5 = array9[i];
					pkg.Write(keyValuePair5.Key);
					pkg.Write(keyValuePair5.Value.Value);
				}
				array9 = array8;
				for (int i = 0; i < array9.Length; i++)
				{
					KeyValuePair<int, int?> keyValuePair6 = array9[i];
					pkg.Write(keyValuePair6.Key);
					pkg.Write(keyValuePair6.Value.Value);
				}
			}
			if (Longs != null)
			{
				KeyValuePair<int, long?>[] array10 = (from kvp in Longs
					select new KeyValuePair<int, long?>(kvp.Key, kvp.Value.Get(pars2)) into kvp
					where kvp.Value.HasValue
					select kvp).ToArray();
				pkg.Write((byte)array10.Count());
				KeyValuePair<int, long?>[] array11 = array10;
				for (int i = 0; i < array11.Length; i++)
				{
					KeyValuePair<int, long?> keyValuePair7 = array11[i];
					pkg.Write(keyValuePair7.Key);
					pkg.Write(keyValuePair7.Value.Value);
				}
			}
			if (Strings != null)
			{
				KeyValuePair<int, string>[] array12 = (from kvp in Strings
					select new KeyValuePair<int, string>(kvp.Key, kvp.Value.Get(pars2)) into kvp
					where kvp.Value != null
					select kvp).ToArray();
				pkg.Write((byte)array12.Count());
				KeyValuePair<int, string>[] array13 = array12;
				for (int i = 0; i < array13.Length; i++)
				{
					KeyValuePair<int, string> keyValuePair8 = array13[i];
					pkg.Write(keyValuePair8.Key);
					pkg.Write(keyValuePair8.Value);
				}
			}
			if (ByteArrays != null)
			{
				pkg.Write((byte)ByteArrays.Count());
				foreach (KeyValuePair<int, byte[]> byteArray in ByteArrays)
				{
					pkg.Write(byteArray.Key);
					pkg.Write(byteArray.Value);
				}
			}
			if ((int)ConnectionType != 0 && ConnectionHash != 0)
			{
				pkg.Write((byte)(int)ConnectionType);
				pkg.Write(ConnectionHash);
			}
		}

		private void RollItems(Dictionary<string, string> pars)
		{
			List<ItemValue>? items = Items;
			if (items != null && items.Count > 0)
			{
				string value = ItemValue.LoadItems(pars, Items, ContainerSize, (ItemAmount?.Get(pars)).GetValueOrDefault());
				if (Strings == null)
				{
					Strings = new Dictionary<int, IStringValue>();
				}
				Strings[ZDOVars.s_items] = DataValue.Simple(value);
			}
		}

		private void HandleConnection(ZDO ownZdo)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (OriginalId == ZDOID.None)
			{
				return;
			}
			ZDOID uid = ownZdo.m_uid;
			if (TargetConnectionId != ZDOID.None)
			{
				ZDO zDO = ZDOMan.instance.GetZDO(TargetConnectionId);
				if (zDO != null)
				{
					ownZdo.SetConnection(ConnectionType, TargetConnectionId);
					if ((int)ConnectionType == 1)
					{
						zDO.SetConnection((ConnectionType)1, uid);
					}
				}
				return;
			}
			KeyValuePair<ZDOID, ZDOConnection> keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair<ZDOID, ZDOConnection> kvp) => kvp.Value.m_target == OriginalId);
			if (keyValuePair.Value != null)
			{
				ZDO zDO2 = ZDOMan.instance.GetZDO(keyValuePair.Key);
				if (zDO2 != null)
				{
					zDO2.SetConnection(keyValuePair.Value.m_type, uid);
				}
			}
		}

		private void HandleHashConnection(ZDO ownZdo)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Invalid comparison between Unknown and I4
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Invalid comparison between Unknown and I4
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Invalid comparison between Unknown and I4
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (ConnectionHash == 0 || (int)ConnectionType == 0)
			{
				return;
			}
			ZDOID uid = ownZdo.m_uid;
			ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash);
			? val = ConnectionType ^ 0x10;
			bool flag = (ConnectionType & 0x10) == 0;
			ZDOID val2 = ((IEnumerable<ZDOID>)ZDOExtraData.GetAllConnectionZDOIDs((ConnectionType)val)).FirstOrDefault((Func<ZDOID, bool>)((ZDOID z) => ZDOExtraData.GetConnectionHashData(z, ConnectionType)?.m_hash == ConnectionHash));
			if (val2 == ZDOID.None)
			{
				return;
			}
			ZDO zDO = ZDOMan.instance.GetZDO(val2);
			if (zDO != null)
			{
				if ((ConnectionType & 3) > 0)
				{
					ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO));
					ZDOID val4 = (flag ? val2 : uid);
					val3.SetConnection((ConnectionType)3, val4);
				}
				if ((ConnectionType & 2) > 0)
				{
					ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO));
					ZDOID val6 = (flag ? val2 : uid);
					val5.SetConnection((ConnectionType)2, val6);
				}
				if ((ConnectionType & 1) > 0)
				{
					zDO.SetConnection((ConnectionType)1, uid);
					ownZdo.SetConnection((ConnectionType)1, val2);
				}
			}
		}

		private static int Hash(string key)
		{
			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 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 readonly Dictionary<int, DataEntry> Data = new Dictionary<int, DataEntry>();

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

		public static readonly List<string> DataKeys = new 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 bool TryGetValueFromGroup(string group, out string value)
		{
			int stableHashCode = StringExtensionMethods.GetStableHashCode(group.ToLowerInvariant());
			if (!ValueGroups.ContainsKey(stableHashCode))
			{
				value = group;
				return false;
			}
			int index = Random.Range(0, ValueGroups[stableHashCode].Count);
			value = ValueGroups[stableHashCode][index];
			return true;
		}

		public static void LoadEntries()
		{
			if (!Object.op_Implicit((Object)(object)ZNet.instance))
			{
				return;
			}
			Data.Clear();
			DataKeys.Clear();
			ValueGroups.Clear();
			string[] array = Directory.GetFiles(GamePath, "*.yaml").Concat(Directory.GetFiles(ProfilePath, "*.yaml")).Select(Path.GetFullPath)
				.Distinct()
				.ToArray();
			foreach (string text in array)
			{
				foreach (DataData item2 in Yaml.LoadList<DataData>(text))
				{
					if (item2.value != null)
					{
						KeyValuePair<string, string> keyValuePair = Parse.Kvp(item2.value, ',');
						int stableHashCode = StringExtensionMethods.GetStableHashCode(keyValuePair.Key.ToLowerInvariant());
						if (ValueGroups.ContainsKey(stableHashCode))
						{
							ServerDevcommands.Log.LogWarning((object)("Duplicate value group entry: " + keyValuePair.Key + " at " + text));
						}
						if (!ValueGroups.ContainsKey(stableHashCode))
						{
							ValueGroups[stableHashCode] = new List<string>();
						}
						ValueGroups[stableHashCode].Add(keyValuePair.Value);
					}
					if (item2.valueGroup != null && item2.values != null)
					{
						int stableHashCode2 = StringExtensionMethods.GetStableHashCode(item2.valueGroup.ToLowerInvariant());
						if (ValueGroups.ContainsKey(stableHashCode2))
						{
							ServerDevcommands.Log.LogWarning((object)("Duplicate value group entry: " + item2.valueGroup + " at " + text));
						}
						if (!ValueGroups.ContainsKey(stableHashCode2))
						{
							ValueGroups[stableHashCode2] = new List<string>();
						}
						string[] values = item2.values;
						foreach (string item in values)
						{
							ValueGroups[stableHashCode2].Add(item);
						}
					}
					if (item2.name != null)
					{
						int stableHashCode3 = StringExtensionMethods.GetStableHashCode(item2.name);
						if (Data.ContainsKey(stableHashCode3))
						{
							ServerDevcommands.Log.LogWarning((object)("Duplicate data entry: " + item2.name + " at " + text));
						}
						DataKeys.Add(item2.name);
						Data[stableHashCode3] = new DataEntry(item2);
					}
				}
			}
			ServerDevcommands.Log.LogInfo((object)$"Loaded {Data.Count} data entries.");
			if (ValueGroups.Count > 0)
			{
				ServerDevcommands.Log.LogInfo((object)$"Loaded {ValueGroups.Count} value groups.");
			}
			LoadDefaultValueGroups();
		}

		public static void Save(PlainDataEntry data, string name, bool profile)
		{
			string path = Path.Combine(profile ? ProfilePath : GamePath, "data.yaml");
			if (!File.Exists(path))
			{
				Directory.CreateDirectory(Path.GetDirectoryName(path));
				File.Create(path).Close();
			}
			string text = File.ReadAllText(path);
			text = text + "\n" + Yaml.Serializer().Serialize((object)new DataData[1] { ToData(data, name) });
			File.WriteAllText(path, text);
		}

		public static DataData ToData(PlainDataEntry zdo, string name)
		{
			DataData dataData = new DataData
			{
				name = name
			};
			zdo.Write(dataData);
			return dataData;
		}

		private static void LoadDefaultValueGroups()
		{
			if (DefaultValueGroups.Count == 0)
			{
				Type[] types = ComponentInfo.Types;
				foreach (Type type in types)
				{
					int stableHashCode = StringExtensionMethods.GetStableHashCode(type.Name.ToLowerInvariant());
					Dictionary<int, List<string>> defaultValueGroups = DefaultValueGroups;
					string[] array = ComponentInfo.PrefabsByComponent(type.Name);
					List<string> list = new List<string>(array.Length);
					list.AddRange(array);
					defaultValueGroups[stableHashCode] = list;
				}
				if (DefaultValueGroups.ContainsKey(HumanoidHash))
				{
					DefaultValueGroups[CreatureHash] = DefaultValueGroups[HumanoidHash];
				}
				if (DefaultValueGroups.ContainsKey(WearNTearHash))
				{
					DefaultValueGroups[StructureHash] = DefaultValueGroups[WearNTearHash];
				}
			}
			foreach (KeyValuePair<int, List<string>> defaultValueGroup in DefaultValueGroups)
			{
				if (!ValueGroups.ContainsKey(defaultValueGroup.Key))
				{
					ValueGroups[defaultValueGroup.Key] = defaultValueGroup.Value;
				}
			}
		}

		public static void SetupWatcher()
		{
			if (!Directory.Exists(GamePath))
			{
				Directory.CreateDirectory(GamePath);
			}
			if (!Directory.Exists(ProfilePath))
			{
				Directory.CreateDirectory(ProfilePath);
			}
			Yaml.SetupWatcher(GamePath, "*", (Action)LoadEntries);
			if (GamePath != ProfilePath)
			{
				Yaml.SetupWatcher(ProfilePath, "*", (Action)LoadEntries);
			}
		}
	}
	public class DataValue
	{
		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(ZPackage pkg)
		{
			return new SimpleIntValue(pkg.ReadInt());
		}

		public static IIntValue Int(string values, HashSet<string> requiredParameters)
		{
			bool num = CheckParameters(values, requiredParameters);
			string[] array = Parse.SplitWithEmpty(values, ',');
			if (!num && array.Length == 1 && int.TryParse(array[0], out var result))
			{
				return new SimpleIntValue(result);
			}
			return new IntValue(array);
		}

		public static IFloatValue Float(ZPackage pkg)
		{
			return new SimpleFloatValue(pkg.ReadSingle());
		}

		public static IFloatValue Float(string values, HashSet<string> requiredParameters)
		{
			bool num = CheckParameters(values, requiredParameters);
			string[] array = Parse.SplitWithEmpty(values, ',');
			float value = default(float);
			if (!num && array.Length == 1 && Parse.TryFloat(array[0], ref value))
			{
				return new SimpleFloatValue(value);
			}
			return new FloatValue(array);
		}

		public static ILongValue Long(ZPackage pkg)
		{
			return new SimpleLongValue(pkg.ReadLong());
		}

		public static ILongValue Long(string values, HashSet<string> requiredParameters)
		{
			bool num = CheckParameters(values, requiredParameters);
			string[] array = Parse.SplitWithEmpty(values, ',');
			if (!num && array.Length == 1 && long.TryParse(array[0], out var result))
			{
				return new SimpleLongValue(result);
			}
			return new LongValue(array);
		}

		public static IStringValue String(ZPackage pkg)
		{
			return new SimpleStringValue(pkg.ReadString());
		}

		public static IStringValue String(string values, HashSet<string> requiredParameters)
		{
			bool num = CheckParameters(values, requiredParameters);
			string[] array = Parse.SplitWithEscape(values, ',');
			if (!num && array.Length == 1)
			{
				return new SimpleStringValue(array[0]);
			}
			return new StringValue(array);
		}

		public static IBoolValue Bool(bool value)
		{
			return new SimpleBoolValue(value);
		}

		public static IBoolValue Bool(string values, HashSet<string> requiredParameters)
		{
			bool num = CheckParameters(values, requiredParameters);
			string[] array = Parse.SplitWithEmpty(values, ',');
			if (!num && array.Length == 1 && bool.TryParse(array[0], out var result))
			{
				return new SimpleBoolValue(result);
			}
			return new BoolValue(array);
		}

		public static IHashValue Hash(string value)
		{
			return new SimpleHashValue(value);
		}

		public static IHashValue Hash(string values, HashSet<string> requiredParameters)
		{
			bool num = CheckParameters(values, requiredParameters);
			string[] array = Parse.SplitWithEmpty(values, ',');
			if (!num && array.Length == 1)
			{
				return new SimpleHashValue(array[0]);
			}
			return new HashValue(array);
		}

		public static IVector3Value Vector3(ZPackage pkg)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return new SimpleVector3Value(pkg.ReadVector3());
		}

		public static IVector3Value Vector3(string values, HashSet<string> requiredParameters)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			bool num = CheckParameters(values, requiredParameters);
			string[] values2 = Parse.SplitWithEscape(values, ',');
			Vector3? val = Parse.VectorXZYNull(values);
			if (!num && val.HasValue)
			{
				return new SimpleVector3Value(val.Value);
			}
			return new Vector3Value(values2);
		}

		public static IQuaternionValue Quaternion(ZPackage pkg)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return new SimpleQuaternionValue(pkg.ReadQuaternion());
		}

		public static IQuaternionValue Quaternion(string values, HashSet<string> requiredParameters)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			bool num = CheckParameters(values, requiredParameters);
			string[] values2 = Parse.SplitWithEscape(values, ',');
			Quaternion? val = Parse.AngleYXZNull(values);
			if (!num && val.HasValue)
			{
				return new SimpleQuaternionValue(val.Value);
			}
			return new QuaternionValue(values2);
		}

		private static bool CheckParameters(string value, HashSet<string> requiredParameters)
		{
			if (!value.Contains("<") || !value.Contains(">"))
			{
				return false;
			}
			string[] array = value.Split('<', '>');
			for (int i = 1; i < array.Length; i += 2)
			{
				requiredParameters.Add(array[i]);
			}
			return array.Length > 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(Dictionary<string, string> pars)
		{
			string text = RollValue();
			if (text == null || text == "<none>")
			{
				return null;
			}
			return ReplaceParameters(text, pars);
		}

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

		protected string[] GetAllValues(Dictionary<string, string> pars)
		{
			Dictionary<string, string> pars2 = pars;
			return (from v in Values
				select ReplaceParameters(v, pars2) into v
				where v != null && v != "<none"
				select v).ToArray();
		}

		protected string ReplaceParameters(string value, Dictionary<string, string> pars)
		{
			foreach (KeyValuePair<string, string> par in pars)
			{
				value = value.Replace(par.Key, par.Value);
			}
			return value;
		}
	}
	public class ItemValue
	{
		public IStringValue Prefab;

		public float Chance;

		public IIntValue Stack;

		public IFloatValue Durability;

		public string Position;

		private Vector2i RolledPosition;

		public IBoolValue Equipped;

		public IIntValue Quality;

		public IIntValue Variant;

		public ILongValue CrafterID;

		public IStringValue CrafterName;

		public Dictionary<string, IStringValue> CustomData;

		public IIntValue WorldLevel;

		public IBoolValue PickedUp;

		private string RolledPrefab;

		public ItemValue(ItemData data, HashSet<string> requiredParameters)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			HashSet<string> requiredParameters2 = requiredParameters;
			Prefab = DataValue.String(data.prefab, requiredParameters2);
			Chance = data.chance;
			Stack = DataValue.Int(data.stack, requiredParameters2);
			Durability = DataValue.Float(data.durability, requiredParameters2);
			Position = data.pos;
			RolledPosition = Parse.Vector2Int(data.pos);
			Equipped = DataValue.Bool(data.equipped, requiredParameters2);
			Quality = DataValue.Int(data.quality, requiredParameters2);
			Variant = DataValue.Int(data.variant, requiredParameters2);
			CrafterID = DataValue.Long(data.crafterID, requiredParameters2);
			CrafterName = DataValue.String(data.crafterName, requiredParameters2);
			CustomData = data.customData?.ToDictionary((KeyValuePair<string, string> kvp) => kvp.Key, (KeyValuePair<string, string> kvp) => DataValue.String(kvp.Value, requiredParameters2)) ?? new Dictionary<string, IStringValue>();
			WorldLevel = DataValue.Int(data.worldLevel, requiredParameters2);
			PickedUp = DataValue.Bool(data.pickedUp, requiredParameters2);
			RolledPrefab = "";
			base..ctor();
		}

		public static string LoadItems(Dictionary<string, string> 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_0026: 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)
			ZPackage val = new ZPackage();
			val.Write(106);
			items = Generate(pars, items, (Vector2i)(((??)size) ?? new Vector2i(0, 0)), amount);
			val.Write(items.Count);
			foreach (ItemValue item in items)
			{
				item.Write(pars, val);
			}
			return val.GetBase64();
		}

		private static List<ItemValue> Generate(Dictionary<string, string> 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 b