Decompiled source of Smart Wishbone v1.0.2

SmartWishbone.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using SmartWishbone.ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: Guid("90f14423-a2aa-4f92-86ea-ed4772443835")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyTitle("SmartWishbone")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SmartWishbone")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
namespace SmartWishbone
{
	internal class Target
	{
		public string targetName;

		public SharedData optionalItem;

		public string displayName;

		public Sprite displaySprite;

		public Dictionary<string, Trackable> possibleTargets;

		public Target(string targetName, Dictionary<string, Trackable> possibleTargets)
		{
			this.targetName = targetName;
			this.possibleTargets = possibleTargets;
		}
	}
	internal static class TrackableData
	{
		internal static Target[] targets;

		private static Dictionary<string, Trackable> personalData = new Dictionary<string, Trackable>();

		private static Dictionary<string, Trackable> syncedData = new Dictionary<string, Trackable>();

		internal static Dictionary<string, Trackable> Data
		{
			get
			{
				if (Object.op_Implicit((Object)(object)ZNet.instance) && !ZNet.instance.IsServer())
				{
					return syncedData;
				}
				return personalData;
			}
		}

		internal static void ToggleTarget(string prefabName)
		{
			if (!Object.op_Implicit((Object)(object)ZNet.instance))
			{
				return;
			}
			if (!ZNet.instance.IsServer())
			{
				RPCHandler.SendTrackableToggleRPC(prefabName);
				return;
			}
			if (personalData.ContainsKey(prefabName))
			{
				Helper.Log("Removed trackable " + prefabName);
				personalData.Remove(prefabName);
			}
			else
			{
				Helper.Log("Added trackable " + prefabName);
				personalData.Add(prefabName, new Trackable(prefabName, "Auto"));
				TryAddBeacons(new List<string> { prefabName });
			}
			TrackableDataLoader.SaveTrackableData(personalData);
			WishboneConfig.CurrentDataCache.Value = TrackableDataLoader.ParseCustomDictToString(personalData);
			UpdateTargets();
		}

		internal static void SetPersonalData(Dictionary<string, Trackable> newData)
		{
			personalData = newData;
		}

		internal static void ClearSyncedData()
		{
			syncedData.Clear();
		}

		internal static void ReceiveNewDataFromServer(Dictionary<string, Trackable> newData)
		{
			List<string> list = newData.Keys.Except(syncedData.Keys).ToList();
			Helper.Log($"Previous data count: {syncedData.Count}, new data count: {newData.Count}, difference count {list.Count}");
			TryAddBeacons(list);
			syncedData = newData;
			UpdateTargets();
		}

		internal static void TryAddBeacons(List<string> newNames)
		{
			if (newNames == null || newNames.Count == 0)
			{
				return;
			}
			Destructible[] array = Object.FindObjectsOfType<Destructible>(true);
			Destructible[] array2 = array;
			foreach (Destructible val in array2)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).gameObject) && newNames.Contains(Utils.GetPrefabName(((Component)val).gameObject)))
				{
					BeaconAddPatches.TryAddBeacon(val);
				}
			}
		}

		internal static void UpdateTargets()
		{
			Dictionary<string, Dictionary<string, Trackable>> dictionary = new Dictionary<string, Dictionary<string, Trackable>>();
			foreach (KeyValuePair<string, Trackable> datum in Data)
			{
				string[] array = datum.Value.displayItem.Split(new char[1] { '|' });
				string[] array2 = array;
				foreach (string key in array2)
				{
					if (dictionary.TryGetValue(key, out var value))
					{
						value[datum.Key] = datum.Value;
						continue;
					}
					dictionary[key] = new Dictionary<string, Trackable> { [datum.Key] = datum.Value };
				}
			}
			List<Target> list = new List<Target>();
			foreach (KeyValuePair<string, Dictionary<string, Trackable>> item in dictionary)
			{
				Target target = new Target(item.Key, item.Value);
				SharedData possibleItem = GetPossibleItem(target.targetName);
				if (possibleItem != null)
				{
					target.optionalItem = possibleItem;
					target.displaySprite = possibleItem.m_icons[0];
					target.displayName = Localization.instance.Localize(possibleItem.m_name);
				}
				else if (target.targetName.IndexOf('$') == 0)
				{
					target.displayName = Localization.instance.Localize(target.targetName);
				}
				else
				{
					target.displayName = target.targetName;
				}
				list.Add(target);
			}
			targets = (from a in list
				orderby a.optionalItem == null, a.displayName
				select a).ToArray();
		}

		private static SharedData GetPossibleItem(string itemName)
		{
			if ((Object)(object)ObjectDB.instance == (Object)null)
			{
				return null;
			}
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(StringExtensionMethods.GetStableHashCode(itemName));
			ItemDrop val = default(ItemDrop);
			if ((Object)(object)itemPrefab != (Object)null && itemPrefab.TryGetComponent<ItemDrop>(ref val))
			{
				return val.m_itemData.m_shared;
			}
			return null;
		}
	}
	internal static class BeaconHelper
	{
		public static Beacon FindClosestBeaconInRange(Vector3 point, Target target)
		{
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			Beacon val = null;
			float num = 999999f;
			Dictionary<string, Trackable> dictionary = ((target != null) ? target.possibleTargets : TrackableData.Data);
			foreach (Beacon instance in Beacon.m_instances)
			{
				if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)((Component)instance).gameObject))
				{
					continue;
				}
				double num2 = 20.0;
				if (dictionary.TryGetValue(Utils.GetPrefabName(((Component)instance).gameObject), out var value) && value.FulFillsCondition())
				{
					num2 = value.range;
					if (WishboneConfig.SearchDistanceOverride.Value != 0f)
					{
						num2 = ((WishboneConfig.SearchDistanceOverrideStyle.Value != 0) ? (num2 + (double)WishboneConfig.SearchDistanceOverride.Value) : ((double)WishboneConfig.SearchDistanceOverride.Value));
					}
					float num3 = Vector3.Distance(point, ((Component)instance).transform.position);
					if ((double)num3 < num2 && ((Object)(object)val == (Object)null || num3 < num))
					{
						val = instance;
						num = num3;
					}
				}
			}
			return val;
		}
	}
	internal class Interactions
	{
		internal static void TrackObject(Player player)
		{
			GameObject hoverObject = ((Humanoid)player).GetHoverObject();
			if (!Object.op_Implicit((Object)(object)hoverObject))
			{
				return;
			}
			GameObject gameObject = ((Component)hoverObject.transform.root).gameObject;
			if (Object.op_Implicit((Object)(object)gameObject))
			{
				Destructible component = gameObject.GetComponent<Destructible>();
				if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)((Component)component).gameObject))
				{
					Helper.LogWarning("Invalid hover object: not destructible");
					return;
				}
				Beacon componentInChildren = gameObject.GetComponentInChildren<Beacon>();
				string text = ((!Object.op_Implicit((Object)(object)componentInChildren)) ? Utils.GetPrefabName(gameObject.gameObject) : Utils.GetPrefabName(((Component)componentInChildren).gameObject));
				Helper.Log("Valid hover object: " + text);
				TrackableData.ToggleTarget(text);
			}
		}
	}
	[HarmonyPatch]
	internal static class KeybindChecker
	{
		[HarmonyPatch(typeof(Player), "Update")]
		public static class Player_Update_Patch
		{
			internal static void Prefix(Player __instance)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)Player.m_localPlayer != (Object)(object)__instance) && !IgnoreKeyPresses())
				{
					if (WishboneConfig.NextTargetKey.Value.IsKeyDown())
					{
						TrackableSwitcher.SwitchTarget(forward: true);
					}
					else if (WishboneConfig.PreviousTargetKey.Value.IsKeyDown())
					{
						TrackableSwitcher.SwitchTarget(forward: false);
					}
					else if (WishboneConfig.ToggleTrackingObjectKey.Value.IsKeyDown())
					{
						Interactions.TrackObject(__instance);
					}
				}
			}
		}

		public static bool IgnoreKeyPresses()
		{
			return IgnoreKeyPressesDueToPlayer(Player.m_localPlayer) || !Object.op_Implicit((Object)(object)ZNetScene.instance) || Minimap.IsOpen() || Menu.IsVisible() || Console.IsVisible() || StoreGui.IsVisible() || TextInput.IsVisible() || InventoryGui.IsVisible() || (Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus()) || (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.InPasswordDialog()) || (Object.op_Implicit((Object)(object)TextViewer.instance) && TextViewer.instance.IsVisible());
		}

		private static bool IgnoreKeyPressesDueToPlayer(Player player)
		{
			return !Object.op_Implicit((Object)(object)player) || ((Character)player).InCutscene() || ((Character)player).IsTeleporting() || ((Character)player).IsDead() || ((Character)player).InPlaceMode();
		}

		public static bool IsKeyDown(this KeyboardShortcut shortcut)
		{
			//IL_0003: 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)
			return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
		}

		public static bool IsKeyHeld(this KeyboardShortcut shortcut)
		{
			//IL_0003: 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)
			return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
		}
	}
	internal static class LocalizationLoader
	{
		private const string keyPrefix = "smartwishbone_";

		public static string[] supportedEmbeddedLanguages = new string[1] { "English" };

		private const string embeddedLanguagePathFormat = "SmartWishbone.Translations.SmartWishbone.{0}.json";

		private const string loadingLog = "Loading {0} translation file for language: {1}";

		private const string failedLoadLog = "Failed loading {0} translation file for language: {1}";

		private const string external = "external";

		private const string embedded = "embedded";

		internal static string GetWishboneTranslation(this Localization localization, string key)
		{
			return localization.Localize("$smartwishbone_" + key.ToLower());
		}

		internal static void SetupTranslations()
		{
			string selectedLanguage = Localization.instance.GetSelectedLanguage();
			string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), "SmartWishbone.*.json", SearchOption.AllDirectories);
			bool flag = false;
			string[] array = files;
			foreach (string path in array)
			{
				string text = Path.GetFileNameWithoutExtension(path).Split(new char[1] { '.' })[1];
				if (text == selectedLanguage)
				{
					Helper.Log(string.Format("Loading {0} translation file for language: {1}", "external", selectedLanguage));
					if (!LoadExternalLanguageFile(selectedLanguage, path))
					{
						Helper.LogWarning(string.Format("Failed loading {0} translation file for language: {1}", "external", selectedLanguage));
					}
					else
					{
						flag = true;
					}
					break;
				}
			}
			if (!flag && selectedLanguage != "English" && supportedEmbeddedLanguages.Contains(selectedLanguage))
			{
				Helper.Log(string.Format("Loading {0} translation file for language: {1}", "embedded", selectedLanguage));
				if (!LoadEmbeddedLanguageFile(selectedLanguage))
				{
					Helper.LogWarning(string.Format("Failed loading {0} translation file for language: {1}", "embedded", selectedLanguage));
				}
			}
			Helper.Log(string.Format("Loading {0} translation file for language: {1}", "embedded", "English"));
			if (!LoadEmbeddedLanguageFile("English"))
			{
				Helper.LogWarning(string.Format("Failed loading {0} translation file for language: {1}", "embedded", "English"));
			}
		}

		internal static bool LoadExternalLanguageFile(string language, string path)
		{
			string text = File.ReadAllText(path);
			if (text == null)
			{
				return false;
			}
			return ParseStringToLanguage(language, text);
		}

		internal static bool LoadEmbeddedLanguageFile(string language)
		{
			string text = ReadEmbeddedTextFile($"SmartWishbone.Translations.SmartWishbone.{language}.json");
			if (text == null)
			{
				return false;
			}
			return ParseStringToLanguage(language, text);
		}

		internal static bool ParseStringToLanguage(string language, string translationAsString)
		{
			Dictionary<string, string> dictionary = new DeserializerBuilder().IgnoreFields().Build().Deserialize<Dictionary<string, string>>(translationAsString);
			if (dictionary == null || dictionary.Count == 0)
			{
				return false;
			}
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				AddForLanguage(language, item.Key, item.Value);
			}
			return true;
		}

		internal static void AddForLanguage(string language, string key, string value)
		{
			string text = "smartwishbone_" + key.ToLower();
			bool flag = Localization.instance.GetSelectedLanguage() == language;
			bool flag2 = language == "English" && !Localization.instance.m_translations.ContainsKey(text);
			if (flag || flag2)
			{
				Localization.instance.AddWord(text, value);
			}
		}

		public static string ReadEmbeddedTextFile(string path)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(path);
			if (manifestResourceStream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			manifestResourceStream.CopyTo(memoryStream);
			byte[] array = ((memoryStream.Length > 0) ? memoryStream.ToArray() : null);
			return (array != null) ? Encoding.UTF8.GetString(array) : null;
		}
	}
	public static class Helper
	{
		internal static void Log(object s)
		{
			if (WishboneConfig.EnableDebugLogs.Value)
			{
				string text = "Smart Wishbone 1.0.2: " + ((s != null) ? s.ToString() : "null");
				Debug.Log((object)text);
			}
		}

		internal static void LogWarning(object s)
		{
			string text = "Smart Wishbone 1.0.2: " + ((s != null) ? s.ToString() : "null");
			Debug.LogWarning((object)text);
		}

		internal static void LogError(Exception e)
		{
			string text = "Smart Wishbone 1.0.2: " + ((e != null) ? (e.Message + "\n" + e.StackTrace) : "null");
			Debug.LogError((object)text);
		}
	}
	internal class Trackable
	{
		public string prefabName;

		public string displayItem;

		public string condition;

		public double range = 20.0;

		public Trackable()
		{
		}

		public Trackable(string prefabName, string displayItem)
			: this()
		{
			this.prefabName = prefabName;
			this.displayItem = displayItem;
		}

		public Trackable(string prefabName, string displayItem, string condition, double range)
			: this(prefabName, displayItem)
		{
			this.condition = condition;
			this.range = range;
		}
	}
	internal static class TrackableExtension
	{
		internal static bool FulFillsCondition(this Trackable trackable)
		{
			if (!WishboneConfig.EnforceWorldConditions.Value)
			{
				return true;
			}
			return Utility.IsNullOrWhiteSpace(trackable.condition) || ZoneSystem.instance.GetGlobalKey(trackable.condition);
		}
	}
	internal class TrackableDataLoader
	{
		private const string embeddedPathFormat = "SmartWishbone.Data.{0}.yaml";

		private const string dataFileInfix = "SmartWishbone.Data";

		private const string loadingLog = "Loading {0} data file '{1}'";

		private const string failedLoadLog = "Failed loading {0} data file '{1}'";

		private const string savingLog = "Saving {0} data file '{1}'";

		private const string failedSaveLog = "Failed saving {0} data file '{1}'";

		private const string external = "external";

		private const string embedded = "embedded";

		internal static Dictionary<string, Trackable> LoadTrackableData()
		{
			List<Trackable> trackables = LoadDataFiles();
			Dictionary<string, Trackable> dictionary = ValidateData(trackables);
			Helper.Log($"trackable count after validation: {dictionary.Count}");
			return dictionary;
		}

		internal static void SaveTrackableData(Dictionary<string, Trackable> data)
		{
			List<string> list = Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), "SmartWishbone.Data.yaml", SearchOption.AllDirectories).ToList();
			if (list.Count > 0)
			{
				list.Sort();
				string text = list[0];
				Helper.Log(string.Format("Saving {0} data file '{1}'", "external", text));
				SaveToTextFile(data, text);
			}
			else
			{
				Helper.LogWarning("No data file to save to found, aborting saving.");
			}
		}

		internal static void SaveToTextFile(Dictionary<string, Trackable> data, string path)
		{
			string text = ParseCustomDictToString(data);
			if (text == null || !File.Exists(path))
			{
				Helper.LogWarning(string.Format("Failed saving {0} data file '{1}'", "external", path));
			}
			else
			{
				File.WriteAllText(path, text);
			}
		}

		internal static List<Trackable> LoadDataFiles()
		{
			List<string> list = Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), "SmartWishbone.Data.yaml", SearchOption.AllDirectories).ToList();
			List<Trackable> list2 = new List<Trackable>();
			if (list.Count > 0)
			{
				list.Sort();
				string text = list[0];
				if (list.Count > 1)
				{
					Helper.LogWarning($"Found {list.Count} data files instead of only 1. Please remove the duplicate entries. Only reading entry: '{text}'");
				}
				Helper.Log(string.Format("Loading {0} data file '{1}'", "external", text));
				List<Trackable> list3 = LoadExternalDataFile(text);
				if (list3 != null && list3.Count > 0)
				{
					list2 = list3;
				}
				else
				{
					Helper.LogWarning(string.Format("Failed loading {0} data file '{1}'", "external", text));
				}
			}
			if (list2 == null || list2.Count == 0)
			{
				Helper.Log(string.Format("Loading {0} data file '{1}'", "embedded", "SmartWishbone.Data"));
				List<Trackable> list4 = LoadEmbeddedDataFile("SmartWishbone.Data");
				if (list4 != null && list4.Count > 0)
				{
					list2 = list4;
				}
				else
				{
					Helper.LogWarning(string.Format("Failed loading {0} data file '{1}'", "embedded", "SmartWishbone.Data"));
				}
			}
			if (list2 == null || list2.Count == 0)
			{
				return new List<Trackable>();
			}
			return list2;
		}

		internal static Dictionary<string, Trackable> ValidateData(List<Trackable> trackables)
		{
			Dictionary<string, Trackable> dictionary = new Dictionary<string, Trackable>();
			if (trackables == null)
			{
				return dictionary;
			}
			foreach (Trackable trackable in trackables)
			{
				if (dictionary.ContainsKey(trackable.prefabName))
				{
					Helper.LogWarning("There were multiple definitions for the same prefab name: " + trackable.prefabName + "; only picking the first one.");
				}
				else
				{
					dictionary[trackable.prefabName] = trackable;
				}
			}
			foreach (KeyValuePair<string, Trackable> item in dictionary.ToList())
			{
				if (item.Key == null || item.Key != item.Value.prefabName)
				{
					Helper.LogWarning("invalid trackable");
					dictionary.Remove(item.Key);
					continue;
				}
				Trackable value = item.Value;
				if (Utility.IsNullOrWhiteSpace(value.prefabName))
				{
					Helper.LogWarning("PrefabName is not a valid");
					dictionary.Remove(item.Key);
					continue;
				}
				if (Utility.IsNullOrWhiteSpace(value.displayItem))
				{
					Helper.LogWarning("DisplayItem is not a valid");
					dictionary.Remove(item.Key);
					continue;
				}
				if (Utility.IsNullOrWhiteSpace(value.condition))
				{
					value.condition = null;
				}
				if (value.range <= 0.0)
				{
					Helper.LogWarning("Trackable range is not positive, resetting to default of 20");
					value.range = 20.0;
				}
			}
			return dictionary;
		}

		internal static List<Trackable> LoadExternalDataFile(string path)
		{
			string text = File.ReadAllText(path);
			if (text == null)
			{
				return null;
			}
			return ParseStringToCustomList(text);
		}

		internal static List<Trackable> LoadEmbeddedDataFile(string infix)
		{
			string path = $"SmartWishbone.Data.{infix}.yaml";
			string text = ReadEmbeddedTextFile(path);
			if (text == null || text.IndexOf('-') == -1)
			{
				return null;
			}
			text = text.Substring(text.IndexOf('-'));
			return ParseStringToCustomList(text);
		}

		internal static List<Trackable> ParseStringToCustomList(string translationAsString)
		{
			IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
			List<Trackable> list = deserializer.Deserialize<List<Trackable>>(translationAsString);
			if (list == null || list.Count == 0)
			{
				return null;
			}
			return list;
		}

		internal static string ParseCustomDictToString(Dictionary<string, Trackable> data)
		{
			ISerializer serializer = new SerializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
			string text = serializer.Serialize(data.Values.ToList());
			if (text == null)
			{
				return null;
			}
			return text;
		}

		public static string ReadEmbeddedTextFile(string path)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Stream manifestResourceStream = executingAssembly.GetManifestResourceStream(path);
			if (manifestResourceStream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			manifestResourceStream.CopyTo(memoryStream);
			byte[] array = ((memoryStream.Length > 0) ? memoryStream.ToArray() : null);
			return (array != null) ? Encoding.UTF8.GetString(array) : null;
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal class PlayerPatch
	{
		[HarmonyPatch("SetLocalPlayer")]
		[HarmonyPostfix]
		public static void SetLocalPlayer_Postfix(Player __instance)
		{
			if (!((Object)(object)Player.m_localPlayer != (Object)(object)__instance))
			{
				TrackableSwitcher.UpdateTarget();
			}
		}
	}
	internal class TrackableSwitcher
	{
		internal static Target currentTarget;

		private const string playerPrefsCurrentTargetKey = "goldenrevolver.smartWishbone.currentTarget";

		internal static string GetCurrentTarget()
		{
			return PlayerPrefs.GetString("goldenrevolver.smartWishbone.currentTarget", (string)null);
		}

		internal static void RemoveCurrentTarget()
		{
			currentTarget = null;
			PlayerPrefs.DeleteKey("goldenrevolver.smartWishbone.currentTarget");
		}

		internal static void SetCurrentTarget(Target target)
		{
			currentTarget = target;
			PlayerPrefs.SetString("goldenrevolver.smartWishbone.currentTarget", target.targetName);
		}

		internal static void UpdateTarget()
		{
			InternalSwitchTarget(0);
		}

		internal static void SwitchTarget(bool forward)
		{
			InternalSwitchTarget(forward ? 1 : (-1));
		}

		private static void InternalSwitchTarget(int positionChange)
		{
			TrySwitchToNextTarget(positionChange);
			if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || ((Character)Player.m_localPlayer).m_seman == null)
			{
				return;
			}
			for (int num = ((Character)Player.m_localPlayer).m_seman.m_statusEffects.Count - 1; num >= 0; num--)
			{
				StatusEffect val = ((Character)Player.m_localPlayer).m_seman.m_statusEffects[num];
				if (val is SE_CustomFinder)
				{
					((Character)Player.m_localPlayer).m_seman.RemoveStatusEffect(val, true);
					((Character)Player.m_localPlayer).m_seman.AddStatusEffect(val, false, 0, 0f);
				}
			}
		}

		internal static void TrySwitchToNextTarget(int positionChange)
		{
			if (!InternalTrySwitchToNextTarget(positionChange))
			{
				RemoveCurrentTarget();
			}
		}

		internal static bool InternalTrySwitchToNextTarget(int positionChange)
		{
			string text = GetCurrentTarget();
			if (Utility.IsNullOrWhiteSpace(text))
			{
				if (positionChange == 0)
				{
					return false;
				}
				if (positionChange > 0)
				{
					return SearchForNextUsefulIndex(-1, forward: true);
				}
				return SearchForNextUsefulIndex(TrackableData.targets.Length, forward: false);
			}
			for (int i = 0; i < TrackableData.targets.Length; i++)
			{
				Target target = TrackableData.targets[i];
				if (text != target.targetName)
				{
					continue;
				}
				if (positionChange == 0)
				{
					if (target.possibleTargets.Values.Any(TrackableExtension.FulFillsCondition))
					{
						SetCurrentTarget(target);
						return true;
					}
					return false;
				}
				return SearchForNextUsefulIndex(i, positionChange > 0);
			}
			return false;
		}

		internal static bool SearchForNextUsefulIndex(int index, bool forward)
		{
			int num = index;
			bool flag = forward && num == TrackableData.targets.Length - 1;
			bool flag2 = !forward && num == 0;
			while (!flag && !flag2)
			{
				num = ((!forward) ? (num - 1) : (num + 1));
				Target target = TrackableData.targets[num];
				if (target.possibleTargets.Values.Any(TrackableExtension.FulFillsCondition))
				{
					SetCurrentTarget(target);
					return true;
				}
				flag = forward && num == TrackableData.targets.Length - 1;
				flag2 = !forward && num == 0;
			}
			return false;
		}
	}
	public class WishboneConfig
	{
		public enum RangeStyle
		{
			SetTo,
			AddTo
		}

		public enum UserLevel
		{
			Noone,
			OnlyAdmins,
			Everyone
		}

		public enum Target
		{
			Always,
			OnlyInUniversalMode,
			Never
		}

		internal static ConfigEntry<KeyboardShortcut> ToggleTrackingObjectKey;

		internal static ConfigEntry<KeyboardShortcut> NextTargetKey;

		internal static ConfigEntry<KeyboardShortcut> PreviousTargetKey;

		internal static ConfigEntry<bool> EnableDebugLogs;

		internal static ConfigEntry<ServerSyncWrapper.Toggle> UseServerSync;

		internal static ConfigEntry<float> SearchDistanceOverride;

		internal static ConfigEntry<RangeStyle> SearchDistanceOverrideStyle;

		internal static ConfigEntry<bool> EnforceWorldConditions;

		internal static ConfigEntry<UserLevel> UsersAllowedToAddTrackables;

		internal static ConfigEntry<string> CurrentDataCache;

		internal static ConfigFile config;

		private static BaseUnityPlugin plugin;

		internal static ConfigSync serverSyncInstance;

		public static void LoadConfig(BaseUnityPlugin plugin)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			config = plugin.Config;
			WishboneConfig.plugin = plugin;
			serverSyncInstance = ServerSyncWrapper.CreateRequiredConfigSync("goldenrevolver.SmartWishbone", "Smart Wishbone", "1.0.2");
			string text = "0 - Client Settings";
			NextTargetKey = config.Bind<KeyboardShortcut>(text, "NextTargetKey", new KeyboardShortcut((KeyCode)110, Array.Empty<KeyCode>()), (ConfigDescription)null);
			PreviousTargetKey = config.Bind<KeyboardShortcut>(text, "PreviousTargetKey", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), (ConfigDescription)null);
			ToggleTrackingObjectKey = config.Bind<KeyboardShortcut>(text, "ToggleTrackingObjectKey", new KeyboardShortcut((KeyCode)106, Array.Empty<KeyCode>()), (ConfigDescription)null);
			text = "1 - Host/ Server Settings";
			UseServerSync = config.BindForceEnabledSyncLocker(serverSyncInstance, text, "UseServerSync");
			SearchDistanceOverride = config.BindSynced(serverSyncInstance, text, "SearchDistanceOverride", 0f, "Only does something while it's not equal to zero, affected by SearchDistanceOverrideStyle.");
			SearchDistanceOverrideStyle = config.BindSynced(serverSyncInstance, text, "SearchDistanceOverrideStyle", RangeStyle.AddTo);
			EnforceWorldConditions = config.BindSynced(serverSyncInstance, text, "EnforceWorldConditions", value: true);
			EnforceWorldConditions.SettingChanged += EnforceWorldConditions_SettingChanged;
			UsersAllowedToAddTrackables = config.BindSynced(serverSyncInstance, text, "UsersAllowedToAddTrackables", UserLevel.OnlyAdmins);
			text = "9 - Other Settings";
			CurrentDataCache = config.BindSynced(serverSyncInstance, text, "CurrentDataCache", string.Empty, ServerSyncWrapper.HiddenDisplay("You can ignore this. This is just for runtime synchronization."));
			CurrentDataCache.SettingChanged += CurrentDataCache_SettingChanged;
			EnableDebugLogs = config.Bind<bool>(text, "EnableDebugLogs", true, (ConfigDescription)null);
		}

		private static void EnforceWorldConditions_SettingChanged(object sender, EventArgs e)
		{
			((MonoBehaviour)plugin).StartCoroutine(WaitForUpdate());
		}

		internal static void CurrentDataCache_SettingChanged(object sender, EventArgs e)
		{
			Helper.Log("Received settíng changed event");
			if (Object.op_Implicit((Object)(object)ZNet.instance) && !ZNet.instance.IsServer())
			{
				Helper.Log("Received new trackable data from server");
				List<Trackable> trackables = TrackableDataLoader.ParseStringToCustomList(CurrentDataCache.Value);
				Dictionary<string, Trackable> newData = TrackableDataLoader.ValidateData(trackables);
				TrackableData.ReceiveNewDataFromServer(newData);
			}
		}

		internal static void SetConfigDataWithoutEvent(string newValue)
		{
			CurrentDataCache.SettingChanged -= CurrentDataCache_SettingChanged;
			CurrentDataCache.Value = newValue;
			CurrentDataCache.SettingChanged += CurrentDataCache_SettingChanged;
		}

		private static IEnumerator WaitForUpdate()
		{
			yield return (object)new WaitForSeconds(0.1f);
			TrackableSwitcher.UpdateTarget();
		}
	}
	[HarmonyPatch]
	internal class BeaconAddPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Destructible), "Awake")]
		public static void Awake_Postfix(Destructible __instance)
		{
			if (TrackableData.Data.Keys.Contains(Utils.GetPrefabName(((Component)__instance).gameObject)))
			{
				TryAddBeacon(__instance);
			}
		}

		public static void TryAddBeacon(Destructible destructible)
		{
			Beacon componentInChildren = ((Component)destructible).gameObject.GetComponentInChildren<Beacon>();
			Beacon componentInParent = ((Component)destructible).gameObject.GetComponentInParent<Beacon>();
			if (!Object.op_Implicit((Object)(object)componentInChildren) && !Object.op_Implicit((Object)(object)componentInParent))
			{
				((Component)destructible).gameObject.AddComponent<Beacon>();
			}
		}
	}
	[HarmonyPatch(typeof(ObjectDB))]
	internal class ObjectDBPatch
	{
		internal const string wishboneEffectName = "Wishbone";

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void Awake_Postfix(ObjectDB __instance)
		{
			//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)
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != "main")
			{
				return;
			}
			SE_Finder val = null;
			SE_Finder val2 = null;
			for (int i = 0; i < __instance.m_StatusEffects.Count; i++)
			{
				StatusEffect val3 = __instance.m_StatusEffects[i];
				SE_Finder val4 = (SE_Finder)(object)((val3 is SE_Finder) ? val3 : null);
				if (val4 == null || ((Object)val3).name != "Wishbone")
				{
					continue;
				}
				val = val4;
				val2 = (SE_Finder)(object)ScriptableObject.CreateInstance<SE_CustomFinder>();
				SE_CustomFinder.originalWishboneSprite = ((StatusEffect)val).m_icon;
				try
				{
					FieldInfo[] fields = typeof(SE_Finder).GetFields();
					foreach (FieldInfo fieldInfo in fields)
					{
						fieldInfo.SetValue(val2, fieldInfo.GetValue(val4));
					}
					FieldInfo[] fields2 = typeof(StatusEffect).GetFields();
					foreach (FieldInfo fieldInfo2 in fields2)
					{
						fieldInfo2.SetValue(val2, fieldInfo2.GetValue(val4));
					}
					((Object)val2).name = ((Object)val4).name;
					__instance.m_StatusEffects[i] = (StatusEffect)(object)val2;
				}
				catch (Exception)
				{
					Debug.LogError((object)"Copying wishbone buff failed, aborting.");
					__instance.m_StatusEffects[i] = val3;
				}
				break;
			}
			if ((Object)(object)val2 == (Object)null || (Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"Couldn't find vanilla wishbone buff. Something is wrong.");
				return;
			}
			foreach (GameObject item in __instance.m_items)
			{
				SharedData shared = item.GetComponent<ItemDrop>().m_itemData.m_shared;
				if ((Object)(object)shared.m_equipStatusEffect == (Object)(object)val)
				{
					shared.m_equipStatusEffect = (StatusEffect)(object)val2;
					Helper.Log("Replaced equip effect of " + shared.m_name);
				}
				if ((Object)(object)shared.m_setStatusEffect == (Object)(object)val)
				{
					shared.m_setStatusEffect = (StatusEffect)(object)val2;
					Helper.Log("Replaced equip effect of " + shared.m_name);
				}
			}
			TrackableData.UpdateTargets();
		}
	}
	internal sealed class ConfigurationManagerAttributes
	{
		public bool? ShowRangeAsPercent;

		public Action<ConfigEntryBase> CustomDrawer;

		public bool? Browsable;

		public string Category;

		public object DefaultValue;

		public bool? HideDefaultButton;

		public bool? HideSettingName;

		public string Description;

		public string DispName;

		public int? Order;

		public bool? ReadOnly;

		public bool? IsAdvanced;

		public Func<object, string> ObjToStr;

		public Func<string, object> StrToObj;
	}
	internal static class ServerSyncWrapper
	{
		public enum Toggle
		{
			On = 1
		}

		internal static ConfigSync CreateOptionalConfigSync(string guid, string displayName, string version)
		{
			return new ConfigSync(guid)
			{
				DisplayName = displayName,
				CurrentVersion = version,
				MinimumRequiredVersion = version,
				ModRequired = false
			};
		}

		internal static ConfigSync CreateRequiredConfigSync(string guid, string displayName, string version)
		{
			return new ConfigSync(guid)
			{
				DisplayName = displayName,
				CurrentVersion = version,
				MinimumRequiredVersion = version,
				ModRequired = true
			};
		}

		internal static ConfigEntry<Toggle> BindForceEnabledSyncLocker(this ConfigFile configFile, ConfigSync serverSyncInstance, string group, string name)
		{
			ConfigEntry<Toggle> val = configFile.Bind<Toggle>(group, name, Toggle.On, ForceEnabledDisplay("It's required that the mod is installed on the server and all clients. Changing this setting does nothing, ServerSync is always enabled."));
			val.Value = Toggle.On;
			serverSyncInstance.AddLockingConfigEntry<Toggle>(val);
			return val;
		}

		internal static ConfigEntry<bool> BindHiddenForceEnabledSyncLocker(this ConfigFile configFile, ConfigSync serverSyncInstance, string group, string name)
		{
			ConfigEntry<bool> val = configFile.Bind<bool>(group, name, true, HiddenDisplay("It's required that the mod is installed on the server and all clients. Changing this setting does nothing, ServerSync is always enabled."));
			val.Value = true;
			serverSyncInstance.AddLockingConfigEntry<bool>(val);
			return val;
		}

		internal static ConfigDescription ForceEnabledDisplay(string description, AcceptableValueBase acceptableValues = null)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			return new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					ReadOnly = true,
					CustomDrawer = delegate
					{
						CustomLabelDrawer("Enabled");
					}
				}
			});
		}

		internal static ConfigDescription ForceDisabledDisplay(string description, AcceptableValueBase acceptableValues = null)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			return new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					ReadOnly = true,
					CustomDrawer = delegate
					{
						CustomLabelDrawer("Disabled");
					}
				}
			});
		}

		internal static ConfigDescription HiddenDisplay(string description, AcceptableValueBase acceptableValues = null)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			return new ConfigDescription(description, acceptableValues, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					ReadOnly = true,
					Browsable = false
				}
			});
		}

		private static void CustomLabelDrawer(string labelText)
		{
			GUILayout.Label(labelText, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		}

		internal static ConfigEntry<T> BindSyncLocker<T>(this ConfigFile configFile, ConfigSync serverSyncInstance, string group, string name, T value, ConfigDescription description) where T : IConvertible
		{
			ConfigEntry<T> val = configFile.Bind<T>(group, name, value, description);
			serverSyncInstance.AddLockingConfigEntry<T>(val);
			return val;
		}

		internal static ConfigEntry<T> BindSyncLocker<T>(this ConfigFile configFile, ConfigSync serverSyncInstance, string group, string name, T value, string description) where T : IConvertible
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			return configFile.BindSyncLocker(serverSyncInstance, group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}

		internal static ConfigEntry<T> BindSynced<T>(this ConfigFile configFile, ConfigSync serverSyncInstance, string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = configFile.Bind<T>(group, name, value, description);
			SyncedConfigEntry<T> syncedConfigEntry = serverSyncInstance.AddConfigEntry<T>(val);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val;
		}

		internal static ConfigEntry<T> BindSynced<T>(this ConfigFile configFile, ConfigSync serverSyncInstance, string group, string name, T value, string description = "", bool synchronizedSetting = true)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return configFile.BindSynced(serverSyncInstance, group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}
	}
	internal class SE_CustomFinder : SE_Finder
	{
		private float m_customUpdateBeaconTimer = 0f;

		internal static Sprite originalWishboneSprite;

		public static string GetDefaultMessageForTarget()
		{
			return GetMessageForTarget(Localization.instance.GetWishboneTranslation("WishboneStartMessageDefault"));
		}

		public static string GetMessageForTarget(string target)
		{
			return string.Format(Localization.instance.GetWishboneTranslation("WishboneStartMessage"), target);
		}

		public override void Setup(Character character)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			((StatusEffect)this).m_startMessageType = (MessageType)1;
			if (TrackableSwitcher.currentTarget != null)
			{
				((StatusEffect)this).m_startMessage = GetMessageForTarget(TrackableSwitcher.currentTarget.displayName);
				if ((Object)(object)TrackableSwitcher.currentTarget.displaySprite != (Object)null)
				{
					((StatusEffect)this).m_icon = TrackableSwitcher.currentTarget.displaySprite;
					flag = true;
				}
			}
			else
			{
				((StatusEffect)this).m_startMessage = GetDefaultMessageForTarget();
			}
			if (!flag)
			{
				((StatusEffect)this).m_icon = originalWishboneSprite;
			}
			((StatusEffect)this).Setup(character);
		}

		public override void UpdateStatusEffect(float dt)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			m_customUpdateBeaconTimer += dt;
			if (m_customUpdateBeaconTimer > 1f)
			{
				m_customUpdateBeaconTimer = 0f;
				Beacon val = BeaconHelper.FindClosestBeaconInRange(((Component)((StatusEffect)this).m_character).transform.position, TrackableSwitcher.currentTarget);
				if ((Object)(object)val != (Object)(object)base.m_beacon)
				{
					base.m_beacon = val;
					if (Object.op_Implicit((Object)(object)base.m_beacon))
					{
						base.m_lastDistance = Utils.DistanceXZ(((Component)((StatusEffect)this).m_character).transform.position, ((Component)base.m_beacon).transform.position);
						base.m_pingTimer = 0f;
					}
				}
			}
			base.m_updateBeaconTimer = 0f - dt;
			((SE_Finder)this).UpdateStatusEffect(dt);
		}
	}
	[BepInPlugin("goldenrevolver.SmartWishbone", "Smart Wishbone", "1.0.2")]
	public class SmartWishbonePlugin : BaseUnityPlugin
	{
		public const string GUID = "goldenrevolver.SmartWishbone";

		public const string NAME = "Smart Wishbone";

		public const string VERSION = "1.0.2";

		protected void Awake()
		{
			WishboneConfig.LoadConfig((BaseUnityPlugin)(object)this);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}
	[HarmonyPatch(typeof(Game))]
	internal static class PatchGame
	{
		[HarmonyPrefix]
		[HarmonyPatch("OnApplicationQuit")]
		internal static void OnApplicationQuitPatch()
		{
			WishboneConfig.CurrentDataCache.SettingChanged -= WishboneConfig.CurrentDataCache_SettingChanged;
			WishboneConfig.config.Remove(((ConfigEntryBase)WishboneConfig.CurrentDataCache).Definition);
		}

		[HarmonyPrefix]
		[HarmonyPatch("Logout")]
		internal static void ResetOnLogout()
		{
			TrackableData.ClearSyncedData();
			WishboneConfig.SetConfigDataWithoutEvent(string.Empty);
		}
	}
	[HarmonyPatch(typeof(FejdStartup))]
	internal class FejdStartupPatch
	{
		private static bool isFirstStartup = true;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void FejdStartupAwakePatch()
		{
			WishboneConfig.SetConfigDataWithoutEvent(string.Empty);
			if (!isFirstStartup)
			{
				return;
			}
			isFirstStartup = false;
			try
			{
				LocalizationLoader.SetupTranslations();
				TrackableData.SetPersonalData(TrackableDataLoader.LoadTrackableData());
			}
			catch (Exception e)
			{
				Helper.LogError(e);
			}
		}
	}
}
namespace SmartWishbone.ServerSync
{
	[HarmonyPatch(typeof(ZNet))]
	internal class RPCHandler
	{
		private const string rpc_server_toggle = "goldenrevolver.SmartWishboneServerToggleRPC";

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void AwakePostfix(ZNet __instance)
		{
			if (__instance.IsServer())
			{
				WishboneConfig.SetConfigDataWithoutEvent(TrackableDataLoader.ParseCustomDictToString(TrackableData.Data));
				ZRoutedRpc.instance.Register<string>("goldenrevolver.SmartWishboneServerToggleRPC", (Action<long, string>)ReceiveTrackableToggleRPC);
			}
		}

		internal static void SendTrackableToggleRPC(string trackableName)
		{
			if (Object.op_Implicit((Object)(object)ZNet.instance) && !ZNet.instance.IsServer())
			{
				Helper.Log("Send new trackable toggle request for: " + trackableName);
				ZRoutedRpc.instance.InvokeRoutedRPC("goldenrevolver.SmartWishboneServerToggleRPC", new object[1] { trackableName });
			}
		}

		private static void ReceiveTrackableToggleRPC(long sender, string trackableName)
		{
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer())
			{
				return;
			}
			switch (WishboneConfig.UsersAllowedToAddTrackables.Value)
			{
			case WishboneConfig.UserLevel.Noone:
				return;
			case WishboneConfig.UserLevel.OnlyAdmins:
			{
				ZNetPeer peer = ZNet.instance.GetPeer(sender);
				if (peer == null || !ZNet.instance.ListContainsId(ZNet.instance.m_adminList, peer.m_socket.GetHostName()))
				{
					Helper.Log("Received trackable request for '" + trackableName + "' but sender is not an admin");
					return;
				}
				break;
			}
			}
			Helper.Log("Received valid trackable request for '" + trackableName + "'");
			TrackableData.ToggleTarget(trackableName);
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[<52978732-87c4-4cdc-882b-2d647c2a58c5>Embedded]
	[CompilerGenerated]
	internal sealed class <52978732-87c4-4cdc-882b-2d647c2a58c5>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<52978732-87c4-4cdc-882b-2d647c2a58c5>Embedded]
	[CompilerGenerated]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[<52978732-87c4-4cdc-882b-2d647c2a58c5>Embedded]
	internal sealed class <18b9b80d-abfb-4f7c-ad7c-660319960abc>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <18b9b80d-abfb-4f7c-ad7c-660319960abc>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <18b9b80d-abfb-4f7c-ad7c-660319960abc>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<52978732-87c4-4cdc-882b-2d647c2a58c5>Embedded]
	[CompilerGenerated]
	internal sealed class <3f6e1be7-b418-43f2-8525-e44c33622247>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <3f6e1be7-b418-43f2-8525-e44c33622247>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace YamlDotNet
{
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal sealed class CultureInfoAdapter : CultureInfo
	{
		private readonly IFormatProvider provider;

		public CultureInfoAdapter(CultureInfo baseCulture, IFormatProvider provider)
			: base(baseCulture.LCID)
		{
			this.provider = provider;
		}

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
		public override object GetFormat(Type formatType)
		{
			return provider.GetFormat(formatType);
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal static class ReflectionExtensions
	{
		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		private static readonly FieldInfo RemoteStackTraceField = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public static Type BaseType(this Type type)
		{
			return type.BaseType;
		}

		public static bool IsValueType(this Type type)
		{
			return type.IsValueType;
		}

		public static bool IsGenericType(this Type type)
		{
			return type.IsGenericType;
		}

		public static bool IsGenericTypeDefinition(this Type type)
		{
			return type.IsGenericTypeDefinition;
		}

		public static bool IsInterface(this Type type)
		{
			return type.IsInterface;
		}

		public static bool IsEnum(this Type type)
		{
			return type.IsEnum;
		}

		public static bool IsDbNull(this object value)
		{
			return value is DBNull;
		}

		public static bool HasDefaultConstructor(this Type type, bool allowPrivateConstructors)
		{
			BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
			if (allowPrivateConstructors)
			{
				bindingFlags |= BindingFlags.NonPublic;
			}
			if (!type.IsValueType)
			{
				return type.GetConstructor(bindingFlags, null, Type.EmptyTypes, null) != null;
			}
			return true;
		}

		public static TypeCode GetTypeCode(this Type type)
		{
			return Type.GetTypeCode(type);
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public static PropertyInfo GetPublicProperty(this Type type, string name)
		{
			return type.GetProperty(name);
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public static FieldInfo GetPublicStaticField(this Type type, string name)
		{
			return type.GetField(name, BindingFlags.Static | BindingFlags.Public);
		}

		public static IEnumerable<PropertyInfo> GetProperties(this Type type, bool includeNonPublic)
		{
			BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.Public;
			if (includeNonPublic)
			{
				bindingFlags |= BindingFlags.NonPublic;
			}
			if (!type.IsInterface)
			{
				return type.GetProperties(bindingFlags);
			}
			return new Type[1] { type }.Concat(type.GetInterfaces()).SelectMany([<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)] (Type i) => i.GetProperties(bindingFlags));
		}

		public static IEnumerable<PropertyInfo> GetPublicProperties(this Type type)
		{
			return type.GetProperties(includeNonPublic: false);
		}

		public static IEnumerable<FieldInfo> GetPublicFields(this Type type)
		{
			return type.GetFields(BindingFlags.Instance | BindingFlags.Public);
		}

		public static IEnumerable<MethodInfo> GetPublicStaticMethods(this Type type)
		{
			return type.GetMethods(BindingFlags.Static | BindingFlags.Public);
		}

		public static MethodInfo GetPrivateStaticMethod(this Type type, string name)
		{
			return type.GetMethod(name, BindingFlags.Static | BindingFlags.NonPublic) ?? throw new MissingMethodException("Expected to find a method named '" + name + "' in '" + type.FullName + "'.");
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public static MethodInfo GetPublicStaticMethod(this Type type, string name, params Type[] parameterTypes)
		{
			return type.GetMethod(name, BindingFlags.Static | BindingFlags.Public, null, parameterTypes, null);
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public static MethodInfo GetPublicInstanceMethod(this Type type, string name)
		{
			return type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public);
		}

		public static Exception Unwrap(this TargetInvocationException ex)
		{
			Exception innerException = ex.InnerException;
			if (innerException == null)
			{
				return ex;
			}
			if (RemoteStackTraceField != null)
			{
				RemoteStackTraceField.SetValue(innerException, innerException.StackTrace + "\r\n");
			}
			return innerException;
		}

		public static bool IsInstanceOf(this Type type, object o)
		{
			return type.IsInstanceOfType(o);
		}

		public static Attribute[] GetAllCustomAttributes<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TAttribute>(this PropertyInfo property)
		{
			return Attribute.GetCustomAttributes(property, typeof(TAttribute), inherit: true);
		}
	}
	internal static class PropertyInfoExtensions
	{
		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public static object ReadValue(this PropertyInfo property, object target)
		{
			return property.GetValue(target, null);
		}
	}
	internal static class StandardRegexOptions
	{
		public const RegexOptions Compiled = RegexOptions.Compiled;
	}
}
namespace YamlDotNet.Serialization
{
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal abstract class BuilderSkeleton<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TBuilder> where TBuilder : BuilderSkeleton<TBuilder>
	{
		internal INamingConvention namingConvention = NullNamingConvention.Instance;

		internal ITypeResolver typeResolver;

		internal readonly YamlAttributeOverrides overrides;

		internal readonly LazyComponentRegistrationList<Nothing, IYamlTypeConverter> typeConverterFactories;

		internal readonly LazyComponentRegistrationList<ITypeInspector, ITypeInspector> typeInspectorFactories;

		internal bool ignoreFields;

		internal bool includeNonPublicProperties;

		internal Settings settings;

		protected abstract TBuilder Self { get; }

		internal BuilderSkeleton(ITypeResolver typeResolver)
		{
			overrides = new YamlAttributeOverrides();
			typeConverterFactories = new LazyComponentRegistrationList<Nothing, IYamlTypeConverter>
			{
				{
					typeof(YamlDotNet.Serialization.Converters.GuidConverter),
					(Nothing _) => new YamlDotNet.Serialization.Converters.GuidConverter(jsonCompatible: false)
				},
				{
					typeof(SystemTypeConverter),
					(Nothing _) => new SystemTypeConverter()
				}
			};
			typeInspectorFactories = new LazyComponentRegistrationList<ITypeInspector, ITypeInspector>();
			this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver");
			settings = new Settings();
		}

		public TBuilder IgnoreFields()
		{
			ignoreFields = true;
			return Self;
		}

		public TBuilder IncludeNonPublicProperties()
		{
			includeNonPublicProperties = true;
			return Self;
		}

		public TBuilder EnablePrivateConstructors()
		{
			settings.AllowPrivateConstructors = true;
			return Self;
		}

		public TBuilder WithNamingConvention(INamingConvention namingConvention)
		{
			this.namingConvention = namingConvention ?? throw new ArgumentNullException("namingConvention");
			return Self;
		}

		public TBuilder WithTypeResolver(ITypeResolver typeResolver)
		{
			this.typeResolver = typeResolver ?? throw new ArgumentNullException("typeResolver");
			return Self;
		}

		public abstract TBuilder WithTagMapping(TagName tag, Type type);

		public TBuilder WithAttributeOverride<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TClass>(Expression<Func<TClass, object>> propertyAccessor, Attribute attribute)
		{
			overrides.Add(propertyAccessor, attribute);
			return Self;
		}

		public TBuilder WithAttributeOverride(Type type, string member, Attribute attribute)
		{
			overrides.Add(type, member, attribute);
			return Self;
		}

		public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter)
		{
			return WithTypeConverter(typeConverter, delegate(IRegistrationLocationSelectionSyntax<IYamlTypeConverter> w)
			{
				w.OnTop();
			});
		}

		public TBuilder WithTypeConverter(IYamlTypeConverter typeConverter, Action<IRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where)
		{
			if (typeConverter == null)
			{
				throw new ArgumentNullException("typeConverter");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeConverterFactories.CreateRegistrationLocationSelector(typeConverter.GetType(), (Nothing _) => typeConverter));
			return Self;
		}

		public TBuilder WithTypeConverter<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TYamlTypeConverter>(WrapperFactory<IYamlTypeConverter, IYamlTypeConverter> typeConverterFactory, Action<ITrackingRegistrationLocationSelectionSyntax<IYamlTypeConverter>> where) where TYamlTypeConverter : IYamlTypeConverter
		{
			if (typeConverterFactory == null)
			{
				throw new ArgumentNullException("typeConverterFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeConverterFactories.CreateTrackingRegistrationLocationSelector(typeof(TYamlTypeConverter), (IYamlTypeConverter wrapped, Nothing _) => typeConverterFactory(wrapped)));
			return Self;
		}

		public TBuilder WithoutTypeConverter<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TYamlTypeConverter>() where TYamlTypeConverter : IYamlTypeConverter
		{
			return WithoutTypeConverter(typeof(TYamlTypeConverter));
		}

		public TBuilder WithoutTypeConverter(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			typeConverterFactories.Remove(converterType);
			return Self;
		}

		public TBuilder WithTypeInspector<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory) where TTypeInspector : ITypeInspector
		{
			return WithTypeInspector(typeInspectorFactory, delegate(IRegistrationLocationSelectionSyntax<ITypeInspector> w)
			{
				w.OnTop();
			});
		}

		public TBuilder WithTypeInspector<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TTypeInspector>(Func<ITypeInspector, TTypeInspector> typeInspectorFactory, Action<IRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector
		{
			if (typeInspectorFactory == null)
			{
				throw new ArgumentNullException("typeInspectorFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeInspectorFactories.CreateRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector inner) => typeInspectorFactory(inner)));
			return Self;
		}

		public TBuilder WithTypeInspector<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TTypeInspector>(WrapperFactory<ITypeInspector, ITypeInspector, TTypeInspector> typeInspectorFactory, Action<ITrackingRegistrationLocationSelectionSyntax<ITypeInspector>> where) where TTypeInspector : ITypeInspector
		{
			if (typeInspectorFactory == null)
			{
				throw new ArgumentNullException("typeInspectorFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(typeInspectorFactories.CreateTrackingRegistrationLocationSelector(typeof(TTypeInspector), (ITypeInspector wrapped, ITypeInspector inner) => typeInspectorFactory(wrapped, inner)));
			return Self;
		}

		public TBuilder WithoutTypeInspector<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TTypeInspector>() where TTypeInspector : ITypeInspector
		{
			return WithoutTypeInspector(typeof(TTypeInspector));
		}

		public TBuilder WithoutTypeInspector(Type inspectorType)
		{
			if (inspectorType == null)
			{
				throw new ArgumentNullException("inspectorType");
			}
			typeInspectorFactories.Remove(inspectorType);
			return Self;
		}

		protected IEnumerable<IYamlTypeConverter> BuildTypeConverters()
		{
			return typeConverterFactories.BuildComponentList();
		}
	}
	internal delegate TComponent WrapperFactory<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped) where TComponent : TComponentBase;
	internal delegate TComponent WrapperFactory<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TArgument, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponentBase, TComponent>(TComponentBase wrapped, TArgument argument) where TComponent : TComponentBase;
	[Flags]
	internal enum DefaultValuesHandling
	{
		Preserve = 0,
		OmitNull = 1,
		OmitDefaults = 2,
		OmitEmptyCollections = 4
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal sealed class Deserializer : IDeserializer
	{
		private readonly IValueDeserializer valueDeserializer;

		public Deserializer()
			: this(new DeserializerBuilder().BuildValueDeserializer())
		{
		}

		private Deserializer(IValueDeserializer valueDeserializer)
		{
			this.valueDeserializer = valueDeserializer ?? throw new ArgumentNullException("valueDeserializer");
		}

		public static Deserializer FromValueDeserializer(IValueDeserializer valueDeserializer)
		{
			return new Deserializer(valueDeserializer);
		}

		public T Deserialize<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] T>(string input)
		{
			using StringReader input2 = new StringReader(input);
			return Deserialize<T>(input2);
		}

		public T Deserialize<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] T>(TextReader input)
		{
			return Deserialize<T>(new Parser(input));
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public object Deserialize(TextReader input)
		{
			return Deserialize(input, typeof(object));
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public object Deserialize(string input, Type type)
		{
			using StringReader input2 = new StringReader(input);
			return Deserialize(input2, type);
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public object Deserialize(TextReader input, Type type)
		{
			return Deserialize(new Parser(input), type);
		}

		public T Deserialize<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] T>(IParser parser)
		{
			return (T)Deserialize(parser, typeof(T));
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public object Deserialize(IParser parser)
		{
			return Deserialize(parser, typeof(object));
		}

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public object Deserialize(IParser parser, Type type)
		{
			if (parser == null)
			{
				throw new ArgumentNullException("parser");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			YamlDotNet.Core.Events.StreamStart @event;
			bool flag = parser.TryConsume<YamlDotNet.Core.Events.StreamStart>(out @event);
			YamlDotNet.Core.Events.DocumentStart event2;
			bool flag2 = parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out event2);
			object result = null;
			if (!parser.Accept<YamlDotNet.Core.Events.DocumentEnd>(out var _) && !parser.Accept<YamlDotNet.Core.Events.StreamEnd>(out var _))
			{
				using SerializerState serializerState = new SerializerState();
				result = valueDeserializer.DeserializeValue(parser, type, serializerState, valueDeserializer);
				serializerState.OnDeserialization();
			}
			if (flag2)
			{
				parser.Consume<YamlDotNet.Core.Events.DocumentEnd>();
			}
			if (flag)
			{
				parser.Consume<YamlDotNet.Core.Events.StreamEnd>();
			}
			return result;
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 0, 1 })]
	internal sealed class DeserializerBuilder : BuilderSkeleton<DeserializerBuilder>
	{
		private Lazy<IObjectFactory> objectFactory;

		private readonly LazyComponentRegistrationList<Nothing, INodeDeserializer> nodeDeserializerFactories;

		private readonly LazyComponentRegistrationList<Nothing, INodeTypeResolver> nodeTypeResolverFactories;

		private readonly Dictionary<TagName, Type> tagMappings;

		private readonly Dictionary<Type, Type> typeMappings;

		private bool ignoreUnmatched;

		private bool duplicateKeyChecking;

		private bool attemptUnknownTypeDeserialization;

		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		private ITypeInspector _baseTypeInspector;

		protected override DeserializerBuilder Self => this;

		public DeserializerBuilder()
			: base((ITypeResolver)new StaticTypeResolver())
		{
			typeMappings = new Dictionary<Type, Type>();
			objectFactory = new Lazy<IObjectFactory>(() => new DefaultObjectFactory(typeMappings, settings), isThreadSafe: true);
			tagMappings = new Dictionary<TagName, Type>
			{
				{
					FailsafeSchema.Tags.Map,
					typeof(Dictionary<object, object>)
				},
				{
					FailsafeSchema.Tags.Str,
					typeof(string)
				},
				{
					JsonSchema.Tags.Bool,
					typeof(bool)
				},
				{
					JsonSchema.Tags.Float,
					typeof(double)
				},
				{
					JsonSchema.Tags.Int,
					typeof(int)
				},
				{
					DefaultSchema.Tags.Timestamp,
					typeof(DateTime)
				}
			};
			typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner));
			typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner);
			typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner));
			typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone()));
			typeInspectorFactories.Add(typeof(ReadableAndWritablePropertiesTypeInspector), (ITypeInspector inner) => new ReadableAndWritablePropertiesTypeInspector(inner));
			nodeDeserializerFactories = new LazyComponentRegistrationList<Nothing, INodeDeserializer>
			{
				{
					typeof(YamlConvertibleNodeDeserializer),
					(Nothing _) => new YamlConvertibleNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(YamlSerializableNodeDeserializer),
					(Nothing _) => new YamlSerializableNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(TypeConverterNodeDeserializer),
					(Nothing _) => new TypeConverterNodeDeserializer(BuildTypeConverters())
				},
				{
					typeof(NullNodeDeserializer),
					(Nothing _) => new NullNodeDeserializer()
				},
				{
					typeof(ScalarNodeDeserializer),
					(Nothing _) => new ScalarNodeDeserializer(attemptUnknownTypeDeserialization)
				},
				{
					typeof(ArrayNodeDeserializer),
					(Nothing _) => new ArrayNodeDeserializer()
				},
				{
					typeof(DictionaryNodeDeserializer),
					(Nothing _) => new DictionaryNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(CollectionNodeDeserializer),
					(Nothing _) => new CollectionNodeDeserializer(objectFactory.Value)
				},
				{
					typeof(EnumerableNodeDeserializer),
					(Nothing _) => new EnumerableNodeDeserializer()
				},
				{
					typeof(ObjectNodeDeserializer),
					(Nothing _) => new ObjectNodeDeserializer(objectFactory.Value, BuildTypeInspector(), ignoreUnmatched, duplicateKeyChecking)
				}
			};
			nodeTypeResolverFactories = new LazyComponentRegistrationList<Nothing, INodeTypeResolver>
			{
				{
					typeof(MappingNodeTypeResolver),
					(Nothing _) => new MappingNodeTypeResolver(typeMappings)
				},
				{
					typeof(YamlConvertibleTypeResolver),
					(Nothing _) => new YamlConvertibleTypeResolver()
				},
				{
					typeof(YamlSerializableTypeResolver),
					(Nothing _) => new YamlSerializableTypeResolver()
				},
				{
					typeof(TagNodeTypeResolver),
					(Nothing _) => new TagNodeTypeResolver(tagMappings)
				},
				{
					typeof(PreventUnknownTagsNodeTypeResolver),
					(Nothing _) => new PreventUnknownTagsNodeTypeResolver()
				},
				{
					typeof(DefaultContainersNodeTypeResolver),
					(Nothing _) => new DefaultContainersNodeTypeResolver()
				}
			};
		}

		internal ITypeInspector BuildTypeInspector()
		{
			ITypeInspector typeInspector;
			if (_baseTypeInspector != null)
			{
				typeInspector = _baseTypeInspector;
			}
			else
			{
				typeInspector = new WritablePropertiesTypeInspector(typeResolver, includeNonPublicProperties);
				if (!ignoreFields)
				{
					typeInspector = new CompositeTypeInspector(new ReadableFieldsTypeInspector(typeResolver), typeInspector);
				}
			}
			return typeInspectorFactories.BuildComponentChain(typeInspector);
		}

		public DeserializerBuilder WithStaticContext(StaticContext context)
		{
			WithObjectFactory(context.GetFactory());
			typeInspectorFactories.Clear();
			typeInspectorFactories.Add(typeof(CachedTypeInspector), (ITypeInspector inner) => new CachedTypeInspector(inner));
			typeInspectorFactories.Add(typeof(NamingConventionTypeInspector), (ITypeInspector inner) => (!(namingConvention is NullNamingConvention)) ? new NamingConventionTypeInspector(inner, namingConvention) : inner);
			typeInspectorFactories.Add(typeof(YamlAttributesTypeInspector), (ITypeInspector inner) => new YamlAttributesTypeInspector(inner));
			typeInspectorFactories.Add(typeof(YamlAttributeOverridesInspector), (ITypeInspector inner) => (overrides == null) ? inner : new YamlAttributeOverridesInspector(inner, overrides.Clone()));
			_baseTypeInspector = context.GetTypeInspector();
			WithoutNodeDeserializer<DictionaryNodeDeserializer>();
			WithNodeDeserializer(new StaticDictionaryNodeDeserializer(context.GetFactory()));
			return Self;
		}

		public DeserializerBuilder WithAttemptingUnquotedStringTypeDeserialization()
		{
			attemptUnknownTypeDeserialization = true;
			return this;
		}

		public DeserializerBuilder WithObjectFactory(IObjectFactory objectFactory)
		{
			if (objectFactory == null)
			{
				throw new ArgumentNullException("objectFactory");
			}
			this.objectFactory = new Lazy<IObjectFactory>(() => objectFactory, isThreadSafe: true);
			return this;
		}

		public DeserializerBuilder WithObjectFactory(Func<Type, object> objectFactory)
		{
			if (objectFactory == null)
			{
				throw new ArgumentNullException("objectFactory");
			}
			return WithObjectFactory(new LambdaObjectFactory(objectFactory));
		}

		public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer)
		{
			return WithNodeDeserializer(nodeDeserializer, delegate(IRegistrationLocationSelectionSyntax<INodeDeserializer> w)
			{
				w.OnTop();
			});
		}

		public DeserializerBuilder WithNodeDeserializer(INodeDeserializer nodeDeserializer, Action<IRegistrationLocationSelectionSyntax<INodeDeserializer>> where)
		{
			if (nodeDeserializer == null)
			{
				throw new ArgumentNullException("nodeDeserializer");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeDeserializerFactories.CreateRegistrationLocationSelector(nodeDeserializer.GetType(), (Nothing _) => nodeDeserializer));
			return this;
		}

		public DeserializerBuilder WithNodeDeserializer<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TNodeDeserializer>(WrapperFactory<INodeDeserializer, TNodeDeserializer> nodeDeserializerFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeDeserializer>> where) where TNodeDeserializer : INodeDeserializer
		{
			if (nodeDeserializerFactory == null)
			{
				throw new ArgumentNullException("nodeDeserializerFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeDeserializerFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeDeserializer), (INodeDeserializer wrapped, Nothing _) => nodeDeserializerFactory(wrapped)));
			return this;
		}

		public DeserializerBuilder WithoutNodeDeserializer<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TNodeDeserializer>() where TNodeDeserializer : INodeDeserializer
		{
			return WithoutNodeDeserializer(typeof(TNodeDeserializer));
		}

		public DeserializerBuilder WithoutNodeDeserializer(Type nodeDeserializerType)
		{
			if (nodeDeserializerType == null)
			{
				throw new ArgumentNullException("nodeDeserializerType");
			}
			nodeDeserializerFactories.Remove(nodeDeserializerType);
			return this;
		}

		public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver)
		{
			return WithNodeTypeResolver(nodeTypeResolver, delegate(IRegistrationLocationSelectionSyntax<INodeTypeResolver> w)
			{
				w.OnTop();
			});
		}

		public DeserializerBuilder WithNodeTypeResolver(INodeTypeResolver nodeTypeResolver, Action<IRegistrationLocationSelectionSyntax<INodeTypeResolver>> where)
		{
			if (nodeTypeResolver == null)
			{
				throw new ArgumentNullException("nodeTypeResolver");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeTypeResolverFactories.CreateRegistrationLocationSelector(nodeTypeResolver.GetType(), (Nothing _) => nodeTypeResolver));
			return this;
		}

		public DeserializerBuilder WithNodeTypeResolver<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TNodeTypeResolver>(WrapperFactory<INodeTypeResolver, TNodeTypeResolver> nodeTypeResolverFactory, Action<ITrackingRegistrationLocationSelectionSyntax<INodeTypeResolver>> where) where TNodeTypeResolver : INodeTypeResolver
		{
			if (nodeTypeResolverFactory == null)
			{
				throw new ArgumentNullException("nodeTypeResolverFactory");
			}
			if (where == null)
			{
				throw new ArgumentNullException("where");
			}
			where(nodeTypeResolverFactories.CreateTrackingRegistrationLocationSelector(typeof(TNodeTypeResolver), (INodeTypeResolver wrapped, Nothing _) => nodeTypeResolverFactory(wrapped)));
			return this;
		}

		public DeserializerBuilder WithoutNodeTypeResolver<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TNodeTypeResolver>() where TNodeTypeResolver : INodeTypeResolver
		{
			return WithoutNodeTypeResolver(typeof(TNodeTypeResolver));
		}

		public DeserializerBuilder WithoutNodeTypeResolver(Type nodeTypeResolverType)
		{
			if (nodeTypeResolverType == null)
			{
				throw new ArgumentNullException("nodeTypeResolverType");
			}
			nodeTypeResolverFactories.Remove(nodeTypeResolverType);
			return this;
		}

		public override DeserializerBuilder WithTagMapping(TagName tag, Type type)
		{
			if (tag.IsEmpty)
			{
				throw new ArgumentException("Non-specific tags cannot be maped");
			}
			if (type == null)
			{
				throw new ArgumentNullException("type");
			}
			if (tagMappings.TryGetValue(tag, out var value))
			{
				throw new ArgumentException($"Type already has a registered type '{value.FullName}' for tag '{tag}'", "tag");
			}
			tagMappings.Add(tag, type);
			return this;
		}

		public DeserializerBuilder WithTypeMapping<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TInterface, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] TConcrete>() where TConcrete : TInterface
		{
			Type typeFromHandle = typeof(TInterface);
			Type typeFromHandle2 = typeof(TConcrete);
			if (!typeFromHandle.IsAssignableFrom(typeFromHandle2))
			{
				throw new InvalidOperationException("The type '" + typeFromHandle2.Name + "' does not implement interface '" + typeFromHandle.Name + "'.");
			}
			if (typeMappings.ContainsKey(typeFromHandle))
			{
				typeMappings[typeFromHandle] = typeFromHandle2;
			}
			else
			{
				typeMappings.Add(typeFromHandle, typeFromHandle2);
			}
			return this;
		}

		public DeserializerBuilder WithoutTagMapping(TagName tag)
		{
			if (tag.IsEmpty)
			{
				throw new ArgumentException("Non-specific tags cannot be maped");
			}
			if (!tagMappings.Remove(tag))
			{
				throw new KeyNotFoundException($"Tag '{tag}' is not registered");
			}
			return this;
		}

		public DeserializerBuilder IgnoreUnmatchedProperties()
		{
			ignoreUnmatched = true;
			return this;
		}

		public DeserializerBuilder WithDuplicateKeyChecking()
		{
			duplicateKeyChecking = true;
			return this;
		}

		public IDeserializer Build()
		{
			return Deserializer.FromValueDeserializer(BuildValueDeserializer());
		}

		public IValueDeserializer BuildValueDeserializer()
		{
			return new AliasValueDeserializer(new NodeValueDeserializer(nodeDeserializerFactories.BuildComponentList(), nodeTypeResolverFactories.BuildComponentList()));
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal sealed class EmissionPhaseObjectGraphVisitorArgs
	{
		private readonly IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors;

		public IObjectGraphVisitor<IEmitter> InnerVisitor { get; private set; }

		public IEventEmitter EventEmitter { get; private set; }

		public ObjectSerializer NestedObjectSerializer { get; private set; }

		public IEnumerable<IYamlTypeConverter> TypeConverters { get; private set; }

		public EmissionPhaseObjectGraphVisitorArgs(IObjectGraphVisitor<IEmitter> innerVisitor, IEventEmitter eventEmitter, IEnumerable<IObjectGraphVisitor<Nothing>> preProcessingPhaseVisitors, IEnumerable<IYamlTypeConverter> typeConverters, ObjectSerializer nestedObjectSerializer)
		{
			InnerVisitor = innerVisitor ?? throw new ArgumentNullException("innerVisitor");
			EventEmitter = eventEmitter ?? throw new ArgumentNullException("eventEmitter");
			this.preProcessingPhaseVisitors = preProcessingPhaseVisitors ?? throw new ArgumentNullException("preProcessingPhaseVisitors");
			TypeConverters = typeConverters ?? throw new ArgumentNullException("typeConverters");
			NestedObjectSerializer = nestedObjectSerializer ?? throw new ArgumentNullException("nestedObjectSerializer");
		}

		public T GetPreProcessingPhaseObjectGraphVisitor<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] T>() where T : IObjectGraphVisitor<Nothing>
		{
			return preProcessingPhaseVisitors.OfType<T>().Single();
		}
	}
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal abstract class EventInfo
	{
		public IObjectDescriptor Source { get; }

		protected EventInfo(IObjectDescriptor source)
		{
			Source = source ?? throw new ArgumentNullException("source");
		}
	}
	internal class AliasEventInfo : EventInfo
	{
		public AnchorName Alias { get; }

		public bool NeedsExpansion { get; set; }

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		public AliasEventInfo(IObjectDescriptor source, AnchorName alias)
			: base(source)
		{
			if (alias.IsEmpty)
			{
				throw new ArgumentNullException("alias");
			}
			Alias = alias;
		}
	}
	internal class ObjectEventInfo : EventInfo
	{
		public AnchorName Anchor { get; set; }

		public TagName Tag { get; set; }

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		protected ObjectEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal sealed class ScalarEventInfo : ObjectEventInfo
	{
		public string RenderedValue { get; set; }

		public ScalarStyle Style { get; set; }

		public bool IsPlainImplicit { get; set; }

		public bool IsQuotedImplicit { get; set; }

		public ScalarEventInfo(IObjectDescriptor source)
			: base(source)
		{
			Style = source.ScalarStyle;
			RenderedValue = string.Empty;
		}
	}
	internal sealed class MappingStartEventInfo : ObjectEventInfo
	{
		public bool IsImplicit { get; set; }

		public MappingStyle Style { get; set; }

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		public MappingStartEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class MappingEndEventInfo : EventInfo
	{
		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		public MappingEndEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class SequenceStartEventInfo : ObjectEventInfo
	{
		public bool IsImplicit { get; set; }

		public SequenceStyle Style { get; set; }

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		public SequenceStartEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	internal sealed class SequenceEndEventInfo : EventInfo
	{
		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		public SequenceEndEventInfo(IObjectDescriptor source)
			: base(source)
		{
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IAliasProvider
	{
		AnchorName GetAlias(object target);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IDeserializer
	{
		T Deserialize<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] T>(string input);

		T Deserialize<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] T>(TextReader input);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Deserialize(TextReader input);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Deserialize(string input, Type type);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Deserialize(TextReader input, Type type);

		T Deserialize<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] T>(IParser parser);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Deserialize(IParser parser);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Deserialize(IParser parser, Type type);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IEventEmitter
	{
		void Emit(AliasEventInfo eventInfo, IEmitter emitter);

		void Emit(ScalarEventInfo eventInfo, IEmitter emitter);

		void Emit(MappingStartEventInfo eventInfo, IEmitter emitter);

		void Emit(MappingEndEventInfo eventInfo, IEmitter emitter);

		void Emit(SequenceStartEventInfo eventInfo, IEmitter emitter);

		void Emit(SequenceEndEventInfo eventInfo, IEmitter emitter);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface INamingConvention
	{
		string Apply(string value);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface INodeDeserializer
	{
		bool Deserialize(IParser reader, Type expectedType, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 1, 1, 2 })] Func<IParser, Type, object> nestedObjectDeserializer, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] out object value);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface INodeTypeResolver
	{
		bool Resolve([<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] NodeEvent nodeEvent, ref Type currentType);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IObjectAccessor
	{
		void Set(string name, object target, object value);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Read(string name, object target);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IObjectDescriptor
	{
		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object Value
		{
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			get;
		}

		Type Type { get; }

		Type StaticType { get; }

		ScalarStyle ScalarStyle { get; }
	}
	internal static class ObjectDescriptorExtensions
	{
		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
		public static object NonNullValue(this IObjectDescriptor objectDescriptor)
		{
			return objectDescriptor.Value ?? throw new InvalidOperationException("Attempted to use a IObjectDescriptor of type '" + objectDescriptor.Type.FullName + "' whose Value is null at a point whete it is invalid to do so. This may indicate a bug in YamlDotNet.");
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IObjectFactory
	{
		object Create(Type type);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IObjectGraphTraversalStrategy
	{
		void Traverse<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TContext>(IObjectDescriptor graph, IObjectGraphVisitor<TContext> visitor, TContext context);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IObjectGraphVisitor<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TContext>
	{
		bool Enter(IObjectDescriptor value, TContext context);

		bool EnterMapping(IObjectDescriptor key, IObjectDescriptor value, TContext context);

		bool EnterMapping(IPropertyDescriptor key, IObjectDescriptor value, TContext context);

		void VisitScalar(IObjectDescriptor scalar, TContext context);

		void VisitMappingStart(IObjectDescriptor mapping, Type keyType, Type valueType, TContext context);

		void VisitMappingEnd(IObjectDescriptor mapping, TContext context);

		void VisitSequenceStart(IObjectDescriptor sequence, Type elementType, TContext context);

		void VisitSequenceEnd(IObjectDescriptor sequence, TContext context);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IPropertyDescriptor
	{
		string Name { get; }

		bool CanWrite { get; }

		Type Type { get; }

		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		Type TypeOverride
		{
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			get;
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			set;
		}

		int Order { get; set; }

		ScalarStyle ScalarStyle { get; set; }

		T GetCustomAttribute<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] T>() where T : Attribute;

		IObjectDescriptor Read(object target);

		void Write(object target, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object value);
	}
	internal interface IRegistrationLocationSelectionSyntax<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TBaseRegistrationType>
	{
		void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;

		void Before<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;

		void After<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;

		void OnTop();

		void OnBottom();
	}
	internal interface ITrackingRegistrationLocationSelectionSyntax<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TBaseRegistrationType>
	{
		void InsteadOf<TRegistrationType>() where TRegistrationType : TBaseRegistrationType;
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface ISerializer
	{
		void Serialize(TextWriter writer, object graph);

		string Serialize(object graph);

		void Serialize(TextWriter writer, object graph, Type type);

		void Serialize(IEmitter emitter, object graph);

		void Serialize(IEmitter emitter, object graph, Type type);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface ITypeInspector
	{
		IEnumerable<IPropertyDescriptor> GetProperties(Type type, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object container);

		IPropertyDescriptor GetProperty(Type type, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object container, string name, [MaybeNullWhen(true)] bool ignoreUnmatched);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface ITypeResolver
	{
		Type Resolve(Type staticType, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object actualValue);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IValueDeserializer
	{
		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object DeserializeValue(IParser parser, Type expectedType, SerializerState state, IValueDeserializer nestedObjectDeserializer);
	}
	internal interface IValuePromise
	{
		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 2 })]
		event Action<object> ValueAvailable;
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
	internal interface IValueSerializer
	{
		void SerializeValue([<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(1)] IEmitter emitter, object value, Type type);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IYamlConvertible
	{
		void Read(IParser parser, Type expectedType, ObjectDeserializer nestedObjectDeserializer);

		void Write(IEmitter emitter, ObjectSerializer nestedObjectSerializer);
	}
	[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
	internal delegate object ObjectDeserializer(Type type);
	internal delegate void ObjectSerializer(object value, Type type = null);
	[Obsolete("Please use IYamlConvertible instead")]
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IYamlSerializable
	{
		void ReadYaml(IParser parser);

		void WriteYaml(IEmitter emitter);
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal interface IYamlTypeConverter
	{
		bool Accepts(Type type);

		[return: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		object ReadYaml(IParser parser, Type type);

		void WriteYaml(IEmitter emitter, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object value, Type type);
	}
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal sealed class LazyComponentRegistrationList<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TArgument, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponent> : IEnumerable<Func<TArgument, TComponent>>, IEnumerable
	{
		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
		public sealed class LazyComponentRegistration
		{
			public readonly Type ComponentType;

			public readonly Func<TArgument, TComponent> Factory;

			public LazyComponentRegistration(Type componentType, Func<TArgument, TComponent> factory)
			{
				ComponentType = componentType;
				Factory = factory;
			}
		}

		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
		public sealed class TrackingLazyComponentRegistration
		{
			public readonly Type ComponentType;

			public readonly Func<TComponent, TArgument, TComponent> Factory;

			public TrackingLazyComponentRegistration(Type componentType, Func<TComponent, TArgument, TComponent> factory)
			{
				ComponentType = componentType;
				Factory = factory;
			}
		}

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)]
		private class RegistrationLocationSelector : IRegistrationLocationSelectionSyntax<TComponent>
		{
			[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(1)]
			private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations;

			[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 0, 0 })]
			private readonly LazyComponentRegistration newRegistration;

			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
			public RegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 0, 0 })] LazyComponentRegistration newRegistration)
			{
				this.registrations = registrations;
				this.newRegistration = newRegistration;
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.InsteadOf<TRegistrationType>()
			{
				if (newRegistration.ComponentType != typeof(TRegistrationType))
				{
					registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				}
				int index = registrations.EnsureRegistrationExists<TRegistrationType>();
				registrations.entries[index] = newRegistration;
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.After<TRegistrationType>()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				int num = registrations.EnsureRegistrationExists<TRegistrationType>();
				registrations.entries.Insert(num + 1, newRegistration);
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.Before<TRegistrationType>()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				int index = registrations.EnsureRegistrationExists<TRegistrationType>();
				registrations.entries.Insert(index, newRegistration);
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.OnBottom()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				registrations.entries.Add(newRegistration);
			}

			void IRegistrationLocationSelectionSyntax<TComponent>.OnTop()
			{
				registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				registrations.entries.Insert(0, newRegistration);
			}
		}

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)]
		private class TrackingRegistrationLocationSelector : ITrackingRegistrationLocationSelectionSyntax<TComponent>
		{
			[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(1)]
			private readonly LazyComponentRegistrationList<TArgument, TComponent> registrations;

			[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 0, 0 })]
			private readonly TrackingLazyComponentRegistration newRegistration;

			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
			public TrackingRegistrationLocationSelector(LazyComponentRegistrationList<TArgument, TComponent> registrations, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 0, 0 })] TrackingLazyComponentRegistration newRegistration)
			{
				this.registrations = registrations;
				this.newRegistration = newRegistration;
			}

			void ITrackingRegistrationLocationSelectionSyntax<TComponent>.InsteadOf<TRegistrationType>()
			{
				if (newRegistration.ComponentType != typeof(TRegistrationType))
				{
					registrations.EnsureNoDuplicateRegistrationType(newRegistration.ComponentType);
				}
				int index = registrations.EnsureRegistrationExists<TRegistrationType>();
				Func<TArgument, TComponent> innerComponentFactory = registrations.entries[index].Factory;
				registrations.entries[index] = new LazyComponentRegistration(newRegistration.ComponentType, [<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)] (TArgument arg) => newRegistration.Factory(innerComponentFactory(arg), arg));
			}
		}

		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(new byte[] { 1, 1, 0, 0 })]
		private readonly List<LazyComponentRegistration> entries = new List<LazyComponentRegistration>();

		public int Count => entries.Count;

		public IEnumerable<Func<TArgument, TComponent>> InReverseOrder
		{
			get
			{
				int i = entries.Count - 1;
				while (i >= 0)
				{
					yield return entries[i].Factory;
					int num = i - 1;
					i = num;
				}
			}
		}

		public LazyComponentRegistrationList<TArgument, TComponent> Clone()
		{
			LazyComponentRegistrationList<TArgument, TComponent> lazyComponentRegistrationList = new LazyComponentRegistrationList<TArgument, TComponent>();
			foreach (LazyComponentRegistration entry in entries)
			{
				lazyComponentRegistrationList.entries.Add(entry);
			}
			return lazyComponentRegistrationList;
		}

		public void Clear()
		{
			entries.Clear();
		}

		public void Add(Type componentType, Func<TArgument, TComponent> factory)
		{
			entries.Add(new LazyComponentRegistration(componentType, factory));
		}

		public void Remove(Type componentType)
		{
			for (int i = 0; i < entries.Count; i++)
			{
				if (entries[i].ComponentType == componentType)
				{
					entries.RemoveAt(i);
					return;
				}
			}
			throw new KeyNotFoundException("A component registration of type '" + componentType.FullName + "' was not found.");
		}

		public IRegistrationLocationSelectionSyntax<TComponent> CreateRegistrationLocationSelector(Type componentType, Func<TArgument, TComponent> factory)
		{
			return new RegistrationLocationSelector(this, new LazyComponentRegistration(componentType, factory));
		}

		public ITrackingRegistrationLocationSelectionSyntax<TComponent> CreateTrackingRegistrationLocationSelector(Type componentType, Func<TComponent, TArgument, TComponent> factory)
		{
			return new TrackingRegistrationLocationSelector(this, new TrackingLazyComponentRegistration(componentType, factory));
		}

		public IEnumerator<Func<TArgument, TComponent>> GetEnumerator()
		{
			return entries.Select([<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)] (LazyComponentRegistration e) => e.Factory).GetEnumerator();
		}

		IEnumerator IEnumerable.GetEnumerator()
		{
			return GetEnumerator();
		}

		private int IndexOfRegistration(Type registrationType)
		{
			for (int i = 0; i < entries.Count; i++)
			{
				if (registrationType == entries[i].ComponentType)
				{
					return i;
				}
			}
			return -1;
		}

		private void EnsureNoDuplicateRegistrationType(Type componentType)
		{
			if (IndexOfRegistration(componentType) != -1)
			{
				throw new InvalidOperationException("A component of type '" + componentType.FullName + "' has already been registered.");
			}
		}

		[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
		private int EnsureRegistrationExists<TRegistrationType>()
		{
			int num = IndexOfRegistration(typeof(TRegistrationType));
			if (num == -1)
			{
				throw new InvalidOperationException("A component of type '" + typeof(TRegistrationType).FullName + "' has not been registered.");
			}
			return num;
		}
	}
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal static class LazyComponentRegistrationListExtensions
	{
		public static TComponent BuildComponentChain<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponent>(this LazyComponentRegistrationList<TComponent, TComponent> registrations, TComponent innerComponent)
		{
			return registrations.InReverseOrder.Aggregate(innerComponent, [<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)] (TComponent inner, Func<TComponent, TComponent> factory) => factory(inner));
		}

		public static TComponent BuildComponentChain<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TArgument, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TComponent innerComponent, Func<TComponent, TArgument> argumentBuilder)
		{
			return registrations.InReverseOrder.Aggregate(innerComponent, [<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)] (TComponent inner, Func<TArgument, TComponent> factory) => factory(argumentBuilder(inner)));
		}

		public static List<TComponent> BuildComponentList<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponent>(this LazyComponentRegistrationList<Nothing, TComponent> registrations)
		{
			return registrations.Select([<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)] (Func<Nothing, TComponent> factory) => factory(default(Nothing))).ToList();
		}

		public static List<TComponent> BuildComponentList<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TArgument, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] TComponent>(this LazyComponentRegistrationList<TArgument, TComponent> registrations, TArgument argument)
		{
			return registrations.Select([<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(0)] (Func<TArgument, TComponent> factory) => factory(argument)).ToList();
		}
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	internal struct Nothing
	{
	}
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal sealed class ObjectDescriptor : IObjectDescriptor
	{
		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		[field: <18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public object Value
		{
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			get;
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			private set;
		}

		public Type Type { get; private set; }

		public Type StaticType { get; private set; }

		public ScalarStyle ScalarStyle { get; private set; }

		public ObjectDescriptor([<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object value, Type type, Type staticType)
			: this(value, type, staticType, ScalarStyle.Any)
		{
		}

		public ObjectDescriptor([<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object value, Type type, Type staticType, ScalarStyle scalarStyle)
		{
			Value = value;
			Type = type ?? throw new ArgumentNullException("type");
			StaticType = staticType ?? throw new ArgumentNullException("staticType");
			ScalarStyle = scalarStyle;
		}
	}
	internal delegate IObjectGraphTraversalStrategy ObjectGraphTraversalStrategyFactory(ITypeInspector typeInspector, ITypeResolver typeResolver, IEnumerable<IYamlTypeConverter> typeConverters, int maximumRecursion);
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	internal sealed class PropertyDescriptor : IPropertyDescriptor
	{
		private readonly IPropertyDescriptor baseDescriptor;

		public string Name { get; set; }

		public Type Type => baseDescriptor.Type;

		[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)]
		public Type TypeOverride
		{
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			get
			{
				return baseDescriptor.TypeOverride;
			}
			[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(2)]
			set
			{
				baseDescriptor.TypeOverride = value;
			}
		}

		public int Order { get; set; }

		public ScalarStyle ScalarStyle
		{
			get
			{
				return baseDescriptor.ScalarStyle;
			}
			set
			{
				baseDescriptor.ScalarStyle = value;
			}
		}

		public bool CanWrite => baseDescriptor.CanWrite;

		public PropertyDescriptor(IPropertyDescriptor baseDescriptor)
		{
			this.baseDescriptor = baseDescriptor;
			Name = baseDescriptor.Name;
		}

		public void Write(object target, [<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(2)] object value)
		{
			baseDescriptor.Write(target, value);
		}

		public T GetCustomAttribute<[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)] T>() where T : Attribute
		{
			return baseDescriptor.GetCustomAttribute<T>();
		}

		public IObjectDescriptor Read(object target)
		{
			return baseDescriptor.Read(target);
		}
	}
	[<18b9b80d-abfb-4f7c-ad7c-660319960abc>Nullable(0)]
	[<3f6e1be7-b418-43f2-8525-e44c33622247>NullableContext(1)]
	internal sealed class Serializer : ISerializer
	{
		private readonly IValueSerializer valueSerializer;

		private readonly Emitt