Decompiled source of REBUILT AMPED AutoMapPinsEnhanced v1.3.6

plugins/AMP_Configurable.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.SqlTypes;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Dynamic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using AMP_Configurable;
using AMP_Configurable.Patches;
using AMP_Configurable.PinConfig;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Bson;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Linq.JsonPath;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Serialization;
using Newtonsoft.Json.Utilities;
using TMPro;
using UnityEngine;
using Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyFileVersion("1.3.6")]
[assembly: AssemblyTitle("AMPED - Auto Map Pins Enhanced")]
[assembly: AssemblyDescription("Overhauled and improved version of AMP Configurable by Materous")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyProduct("AMP Configurable")]
[assembly: Guid("5c1a1606-c579-4934-bed8-641c16f4848a")]
[assembly: ComVisible(false)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyVersion("1.3.6.0")]
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;
}
namespace Utilities
{
	internal static class ResourceUtils
	{
		public enum Status
		{
			Initialized,
			Loading,
			Ready,
			Error,
			Unload
		}

		public static bool ConvertInternalWarningsErrors = false;

		public static BindingFlags BindFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static byte[] GetResource(string spriteName)
		{
			if (spriteName == "")
			{
				return null;
			}
			string[] files = Directory.GetFiles(Paths.PluginPath, spriteName, SearchOption.AllDirectories);
			if (files.Length == 0)
			{
				Mod.Log.LogWarning("[AMP] Could not find pin icon asset (" + spriteName + "), using generic circle icon");
				files = Directory.GetFiles(Paths.PluginPath, "mapicon_pin_iron.png", SearchOption.AllDirectories);
				if (files.Length == 0)
				{
					Mod.Log.LogError("[AMP] Could not find pin icon sprite. AMP Enhanced is likely installed incorrectly.");
					return null;
				}
			}
			string path = files[0];
			Mod.Log.LogDebug("Successfully loaded sprite: " + spriteName);
			return File.ReadAllBytes(path);
		}

		public static string GetDefaultPinConfig()
		{
			string[] array = null;
			array = Directory.GetFiles(Paths.PluginPath, "amp_pin_types.json", SearchOption.AllDirectories);
			if (array.Length == 0)
			{
				Mod.Log.LogWarning("Could not find the default AMP config file.");
				return "";
			}
			return array[0];
		}

		public static string[] GetPinConfigFiles()
		{
			string[] array = null;
			Mod.Log.LogInfo("Looking for pin configuration json files...");
			array = Directory.GetFiles(Paths.PluginPath, "amp_*.json", SearchOption.AllDirectories);
			if (array.Length == 0)
			{
				Mod.Log.LogWarning("Could not find any AMP config files. No automatic pins will be added...");
			}
			return array;
		}

		public static PinConfig LoadPinConfig(string filename)
		{
			string text = LoadJsonText(filename);
			if (text == null)
			{
				Mod.Log.LogError("[AMP] Could not find pin types config json. AMP Enhanced is likely installed incorrectly.");
				return null;
			}
			return JsonConvert.DeserializeObject<PinConfig>(text);
		}

		public static string LoadJsonText(string jsonFilePath)
		{
			if (string.IsNullOrEmpty(jsonFilePath))
			{
				return null;
			}
			return File.ReadAllText(jsonFilePath);
		}

		public static string GetAssetPath(string assetName)
		{
			string text = Path.Combine(Paths.PluginPath, "AMP_Enhanced", assetName);
			if (!File.Exists(text))
			{
				text = GenerateAssetPathAtAssembly(assetName);
				if (!File.Exists(text))
				{
					text = Path.Combine(Paths.PluginPath, "raziell74-AMPED_Auto_Map_Pins_Enhanced", assetName);
					if (!File.Exists(text))
					{
						text = GenerateAssetPathAtAssembly(assetName);
						if (!File.Exists(text))
						{
							Mod.Log.LogInfo("[AMP] Could not find asset (" + assetName + ")");
							return null;
						}
					}
				}
			}
			return text;
		}

		public static string GenerateAssetPathAtAssembly(string assetName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			return Path.Combine(Path.GetDirectoryName(executingAssembly.Location) ?? string.Empty, assetName);
		}

		public static void SetPrivateField(this object obj, string fieldName, object value)
		{
			obj.GetType().GetField(fieldName, BindFlags).SetValue(obj, value);
		}

		public static T GetPrivateField<T>(this object obj, string fieldName)
		{
			return (T)obj.GetType().GetField(fieldName, BindFlags).GetValue(obj);
		}

		public static void SetPrivateProperty(this object obj, string propertyName, object value)
		{
			obj.GetType().GetProperty(propertyName, BindFlags).SetValue(obj, value, null);
		}

		public static void InvokePrivateMethod(this object obj, string methodName, object[] methodParams)
		{
			obj.GetType().GetMethod(methodName, BindFlags).Invoke(obj, methodParams);
		}

		public static void Logz(string[] categories, string[] messages, LogType logType = 3)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Invalid comparison between Unknown and I4
			string text = string.Empty;
			if (categories != null)
			{
				foreach (string text2 in categories)
				{
					text = text + " (" + text2 + ") -> ";
				}
			}
			if (messages != null)
			{
				foreach (string text3 in messages)
				{
					text = ((text3 == null) ? (text + "NULL | ") : (text + text3 + " | "));
				}
				text = text.Remove(text.Length - 2, 1);
			}
			if (!ConvertInternalWarningsErrors)
			{
				if ((int)logType > 0)
				{
					if ((int)logType == 2)
					{
						Debug.LogWarning((object)("[AMP Commands]" + text));
					}
					else
					{
						Debug.Log((object)("[AMP Commands]" + text));
					}
				}
				else
				{
					Debug.LogError((object)("[AMP Commands]" + text));
				}
			}
			else
			{
				Debug.Log((object)("[AMP Commands]" + text));
			}
		}

		public static string Logr(string[] categories, string[] messages)
		{
			string text = string.Empty;
			if (categories != null)
			{
				foreach (string text2 in categories)
				{
					text = text + " (" + text2 + ")";
				}
			}
			if (messages != null)
			{
				foreach (string text3 in messages)
				{
					text = ((text3 == null) ? (text + "NULL | ") : (text + text3 + " | "));
				}
				text = text.Remove(text.Length - 2, 1);
			}
			return "[AMP Commands]" + text;
		}
	}
}
namespace AMP_Configurable
{
	[BepInPlugin("amped.mod.auto_map_pins", "AMPED - Auto Map Pins Enhanced", "1.3.6")]
	[BepInProcess("valheim.exe")]
	public class Mod : BaseUnityPlugin
	{
		public static class Log
		{
			public static ManualLogSource ModLogger;

			public static void LogInfo(string msg)
			{
				if (loggingEnabled.Value)
				{
					ModLogger.LogInfo((object)msg);
				}
			}

			public static void LogDebug(string msg)
			{
				if (loggingEnabled.Value || diagnosticsEnabled.Value)
				{
					ModLogger.LogDebug((object)msg);
				}
			}

			public static void LogWarning(string msg)
			{
				ModLogger.LogWarning((object)msg);
			}

			public static void LogError(string msg)
			{
				ModLogger.LogError((object)msg);
			}

			public static void LogObject(string type, string name, Vector3 pos)
			{
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				if (loggingEnabled.Value && objectLogging.Value && !filterObjectIds.Contains(name) && (logKnownPinObjects.Value || !objectPins.ContainsKey(name)))
				{
					if (onlyLogUnique.Value && !uniqueObjectIds.Contains(name))
					{
						LogInfo("[AMP - " + type + "] Found Object Id " + name);
						uniqueObjectIds.Add(name);
					}
					else if (!onlyLogUnique.Value)
					{
						LogInfo("[AMP - " + type + "] Found " + name + " at " + ((object)(Vector3)(ref pos)).ToString() + " distance from player[" + ((object)(Vector3)(ref Player_Patches.currPos)).ToString() + "] " + distanceFromPlayer(pos));
					}
				}
			}
		}

		public static ConfigEntry<int> nexusID;

		public static ConfigEntry<bool> modEnabled;

		public static ConfigEntry<bool> diagnosticsEnabled;

		public static ConfigEntry<float> pinOverlapDistance;

		public static ConfigEntry<float> pinRange;

		public static ConfigEntry<bool> pinRangeExpRadiusMatching;

		public static ConfigEntry<float> minimapSizeMult;

		public static ConfigEntry<bool> hideAllLabels;

		public static ConfigEntry<string> hidePinLabels;

		public static ConfigEntry<string> hidePinTypes;

		public static ConfigEntry<string> savePinTypes;

		public static ConfigEntry<string> customPinSizes;

		public static ConfigEntry<bool> loggingEnabled;

		public static ConfigEntry<bool> objectLogging;

		public static ConfigEntry<string> objectLogFilter;

		public static ConfigEntry<bool> onlyLogUnique;

		public static ConfigEntry<bool> logKnownPinObjects;

		public static ConfigEntry<bool> destructablesEnabled;

		public static ConfigEntry<bool> pickablesEnabled;

		public static ConfigEntry<bool> locsEnabled;

		public static ConfigEntry<bool> spwnsEnabled;

		public static ConfigEntry<bool> creaturesEnabled;

		public static bool hasMoved = false;

		public static bool checkingPins = false;

		public static string currEnv = "";

		public static string[] filterObjectIds;

		public static List<string> uniqueObjectIds = new List<string>();

		public static Dictionary<int, PinType> mtypePins = new Dictionary<int, PinType>();

		public static Dictionary<string, PinType> objectPins = new Dictionary<string, PinType>();

		public static Dictionary<Vector3, PinType> pinItems = new Dictionary<Vector3, PinType>();

		public static List<PinData> autoPins = new List<PinData>();

		public static Dictionary<Vector3, PinData> dupPinLocs = new Dictionary<Vector3, PinData>();

		private void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Expected O, but got Unknown
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Expected O, but got Unknown
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Expected O, but got Unknown
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Expected O, but got Unknown
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Expected O, but got Unknown
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Expected O, but got Unknown
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Expected O, but got Unknown
			//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Expected O, but got Unknown
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Expected O, but got Unknown
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Expected O, but got Unknown
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Expected O, but got Unknown
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Expected O, but got Unknown
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Expected O, but got Unknown
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			Log.ModLogger = ((BaseUnityPlugin)this).Logger;
			nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("_General_", "nexusID", 2199, new ConfigDescription("Nexus mod ID for updates", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1,
					DispName = "NexusID"
				}
			}));
			modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("_General_", "modEnabled", true, new ConfigDescription("Enable this mod", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2,
					DispName = "Enabled"
				}
			}));
			pinOverlapDistance = ((BaseUnityPlugin)this).Config.Bind<float>("1. Pins", "pinOverlapDistance", 10f, new ConfigDescription("Distance around pins to prevent overlapping of similar pins. \nRecommended values are 5-15", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 8,
					DispName = "Pin Overlap Distance"
				}
			}));
			pinRangeExpRadiusMatching = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Pins", "pinRangeExpRadiusMatching", true, new ConfigDescription("Match Pin Range to the Player's Map Discovery Radius.\nShould be compatible with mods that change explore radius.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 7,
					DispName = "Match Pin Range to Explore Radius"
				}
			}));
			pinRange = ((BaseUnityPlugin)this).Config.Bind<float>("1. Pins", "pinRange", 50f, new ConfigDescription("Sets the range that pins will appear on the mini-map. Lower value means you need to be closer to set pin.\nDISABLED if Matching Player Explore Radius is enabled.\nRecommended 50-75", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 150f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 6,
					DispName = "Pin Range"
				}
			}));
			hideAllLabels = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Pins", "hideAllLabels", false, new ConfigDescription("Hide all pin labels.\n*THIS WILL OVERRIDE THE INDIVIDUAL SETTINGS*", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 5,
					DispName = "Hide ALL Labels"
				}
			}));
			hidePinLabels = ((BaseUnityPlugin)this).Config.Bind<string>("1. Pins", "hidePinLabels", "", new ConfigDescription("Hide individual pin type labels.\nValue should be a comma seperated list of pin labels.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4,
					DispName = "Hide Individual Labels"
				}
			}));
			hidePinTypes = ((BaseUnityPlugin)this).Config.Bind<string>("1. Pins", "hidePinTypes", "", new ConfigDescription("Disable individual pin types.\nValue should be a comma seperated list of pin labels.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3,
					DispName = "Disable Pins"
				}
			}));
			savePinTypes = ((BaseUnityPlugin)this).Config.Bind<string>("1. Pins", "savePinTypes", "Crypt,Troll Cave,Sunken Crypt,Frost Cave,Infested Mine", new ConfigDescription("These Pin Types will persist on the map after the player as left the area.\nValue should be a comma seperated list of pin types.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2,
					DispName = "Save Pins"
				}
			}));
			minimapSizeMult = ((BaseUnityPlugin)this).Config.Bind<float>("1. Pins", "minimapSizeMult", 1.25f, new ConfigDescription("Pin sizes are multiplied by this number in the minimap.\nNote: Pins can also have a custom minimap size set in the pin packs .json config.\nThis multiplie will also be used on the custom minimap size of these pins.\nIf some pins seem to large please check any amp_*.json config files you have in your plugins folder and adjust the minimapSize acccordingly.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 5f), new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1,
					DispName = "Minimap Size Multiplier"
				}
			}));
			destructablesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Pins Enable/Disable", "destructablesEnabled", true, new ConfigDescription("Enable/Disable pins for\nOres, Trees, and other destructable resource nodes", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 5,
					DispName = "Resources"
				}
			}));
			pickablesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Pins Enable/Disable", "pickablesEnabled", true, new ConfigDescription("Enable/Disable pins for\nBerries, Mushrooms, and other pickable items", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4,
					DispName = "Pickables"
				}
			}));
			locsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Pins Enable/Disable", "locsEnabled", true, new ConfigDescription("Enable/Disable pins for\nCrypts, Troll Caves, and other discoverable locations", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3,
					DispName = "Locations"
				}
			}));
			spwnsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Pins Enable/Disable", "spwnsEnabled", true, new ConfigDescription("Enable/Disable pins for\nGreydwarf nests, Skeleton Bone Piles, and other creature spawners", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2,
					DispName = "Spawners"
				}
			}));
			creaturesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Pins Enable/Disable", "creaturesEnabled", true, new ConfigDescription("Enable/Disable pins for\nSerpents, and other creatures when they spawn with in range of the player", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1,
					DispName = "Creatures"
				}
			}));
			loggingEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Logging", "loggingEnabled", false, new ConfigDescription("Toggle all logs from AMPED on/off", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 6,
					DispName = "Enable Logging"
				}
			}));
			objectLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Logging", "objectLogging", false, new ConfigDescription("Writes object ids to log.\nThese can be used to create AMPED PinTypes in json config files", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 5,
					DispName = "Object Id Logging"
				}
			}));
			onlyLogUnique = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Logging", "onlyLogUnique", true, new ConfigDescription("Sets AMPED to only log out an objectId once, instead of every time an object spawns in.\nIt will logout a full list upon game exit.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 4,
					DispName = "Unique Objects Only"
				}
			}));
			logKnownPinObjects = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Logging", "logKnownPinObjects", false, new ConfigDescription("Allow logging of objects that currently have a configured Pin Type.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 3,
					DispName = "Log Known Pin Objects"
				}
			}));
			objectLogFilter = ((BaseUnityPlugin)this).Config.Bind<string>("3. Logging", "objectLogFilter", "", new ConfigDescription("Comma seperated list of object ids to filter out during logging process. Only applies when Object Logging is enabled", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 2,
					DispName = "Object Log Filter"
				}
			}));
			diagnosticsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Logging", "diagnosticsEnabled", false, new ConfigDescription("Enables log output with function timing diagnostics. Used for developer optimization purposes", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1,
					DispName = "Enable Debug Diagnostics"
				}
			}));
			filterObjectIds = objectLogFilter.Value.Split(new char[1] { ',' });
			string defaultPinConfig = ResourceUtils.GetDefaultPinConfig();
			string[] pinConfigFiles = ResourceUtils.GetPinConfigFiles();
			objectPins = new Dictionary<string, PinType>();
			mtypePins = new Dictionary<int, PinType>();
			autoPins = new List<PinData>();
			if (pinConfigFiles != null)
			{
				LoadPinsFromConfig(defaultPinConfig);
				string[] array = pinConfigFiles;
				foreach (string text in array)
				{
					if (!(Path.GetFileName(text) == "amp_pin_types.json"))
					{
						LoadPinsFromConfig(text);
					}
				}
			}
			if (!modEnabled.Value)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			new Harmony("amped.mod.auto_map_pins").PatchAll();
			Harmony.CreateAndPatchAll(typeof(Minimap_Patch), "amped.mod.auto_map_pins");
			Harmony.CreateAndPatchAll(typeof(Pin_Registration_Patches), "amped.mod.auto_map_pins");
			Harmony.CreateAndPatchAll(typeof(Player_Patches), "amped.mod.auto_map_pins");
			pinItems = new Dictionary<Vector3, PinType>();
			dupPinLocs = new Dictionary<Vector3, PinData>();
			autoPins = new List<PinData>();
			((BaseUnityPlugin)this).Config.SettingChanged += UpdatePinsFromSettings;
			Assets.Init();
		}

		private void OnDestroy()
		{
			if (!objectLogging.Value || uniqueObjectIds.Count <= 0)
			{
				return;
			}
			Log.LogInfo($"AMP Found {uniqueObjectIds.Count} Object Ids");
			foreach (string uniqueObjectId in uniqueObjectIds)
			{
				Log.LogInfo("[AMP object_id] " + uniqueObjectId);
			}
		}

		public static void UpdatePinsFromSettings(object sender, SettingChangedEventArgs arg)
		{
			Log.LogDebug("Setting change detected on " + arg.ChangedSetting.Definition.Key);
			if (pinRangeExpRadiusMatching.Value)
			{
				if ((Object)(object)Minimap.instance != (Object)null)
				{
					pinRange.Value = Minimap.instance.m_exploreRadius;
				}
				else
				{
					pinRange.Value = 50f;
				}
			}
			filterObjectIds = objectLogFilter.Value.Split(new char[1] { ',' });
			forcePinRefresh();
		}

		private static void LoadPinsFromConfig(string confFilePath)
		{
			Log.LogInfo("Loading pin config file: " + Path.GetFileName(confFilePath));
			AMP_Configurable.PinConfig.PinConfig pinConfig = null;
			pinConfig = ResourceUtils.LoadPinConfig(confFilePath);
			PinType[] pins = pinConfig.pins;
			foreach (PinType pinType in pins)
			{
				mtypePins[pinType.type] = pinType;
				string[] object_ids = pinType.object_ids;
				foreach (string text in object_ids)
				{
					Log.LogDebug("Adding " + text.ToLower().Trim() + " to pin type dictionary");
					objectPins[text.ToLower().Trim()] = pinType;
				}
			}
		}

		public static void pinObject(string objectType, string objectId, Vector3 position)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			string text = objectId.Replace("(Clone)", "").ToLower();
			Log.LogObject(objectType, text, position);
			if (objectPins.TryGetValue(text, out var value))
			{
				Log.LogDebug($"Mod.pinObject Adding {text} [{position}] to pinItems");
				value.isPinned = false;
				value.pinCat = objectType;
				pinItems[position] = value;
				mtypePins[value.type].pinCat = objectType;
				objectPins[text].pinCat = objectType;
			}
		}

		public static bool SimilarPinExists(Vector3 pos, PinType type, List<PinData> pins, string aName, Sprite aIcon, out PinData match)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			Log.LogDebug("Mod.SimilarPinExists");
			Stopwatch stopwatch = Stopwatch.StartNew();
			foreach (PinData pin in pins)
			{
				if (pos == pin.m_pos)
				{
					match = pin;
					stopwatch.Stop();
					Log.LogDebug($"Mod.SimilarPinExists: Found Similar Pin. took {stopwatch.ElapsedMilliseconds}ms");
					return true;
				}
				if ((double)Utils.DistanceXZ(pos, pin.m_pos) < (double)pinOverlapDistance.Value && type == pin.m_type && (aName == pin.m_name || (Object)(object)aIcon == (Object)(object)pin.m_icon))
				{
					match = pin;
					stopwatch.Stop();
					Log.LogDebug($"Mod.SimilarPinExists: Found Similar Pin. took {stopwatch.ElapsedMilliseconds}ms");
					return true;
				}
			}
			match = null;
			stopwatch.Stop();
			Log.LogDebug($"Mod.SimilarPinExists took {stopwatch.ElapsedMilliseconds}ms");
			return false;
		}

		public static void forcePinRefresh()
		{
			Log.LogDebug("Mod.forcePinRefresh settings changed, refreshing pins");
			dupPinLocs.Clear();
			List<PinData> list = new List<PinData>(autoPins);
			foreach (PinData item in list)
			{
				PinnedObject.updatePin(item);
			}
			checkPins();
		}

		public static float distanceFromPlayer(Vector3 pos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Vector3.Distance(Player_Patches.currPos, pos);
		}

		public static void checkPins(bool firstLoad = false)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			if (checkingPins)
			{
				return;
			}
			checkingPins = true;
			Log.LogDebug($"Mod.checkPins Looking for items to pin. Checking {pinItems.Count()} pinnable items");
			Stopwatch stopwatch = Stopwatch.StartNew();
			if (pinRangeExpRadiusMatching.Value)
			{
				if ((Object)(object)Minimap.instance != (Object)null)
				{
					pinRange.Value = Minimap.instance.m_exploreRadius;
				}
				else
				{
					pinRange.Value = 50f;
				}
			}
			Dictionary<Vector3, PinType> dictionary = new Dictionary<Vector3, PinType>(pinItems);
			foreach (KeyValuePair<Vector3, PinType> item in dictionary)
			{
				if (!dupPinLocs.TryGetValue(item.Key, out var _))
				{
					float num = distanceFromPlayer(item.Key);
					if (num <= pinRange.Value)
					{
						Log.LogDebug("Mod.checkPins found pinnable item in range. Pinning " + item.Value.label);
						PinnedObject.pinOb(item.Value, item.Key);
					}
					if (!firstLoad && num >= 300f)
					{
						string[] obj = new string[7]
						{
							"Mod.checkPins Distance is more than 300 for ",
							item.Value.label,
							" [",
							null,
							null,
							null,
							null
						};
						Vector3 key = item.Key;
						obj[3] = ((object)(Vector3)(ref key)).ToString();
						obj[4] = "]. Distance: ";
						obj[5] = num.ToString();
						obj[6] = ". Removing from pinItems";
						Log.LogDebug(string.Concat(obj));
						pinItems.Remove(item.Key);
					}
				}
			}
			Log.LogDebug($"Mod.checkPins checking for out of range items on {autoPins.Count()} registered auto pins");
			List<PinData> list = new List<PinData>(autoPins);
			foreach (PinData item2 in list)
			{
				if (!item2.m_save && distanceFromPlayer(item2.m_pos) > pinRange.Value)
				{
					Log.LogDebug($"Mod.checkPins {item2.m_name}[{item2.m_type}] is out of range, removing pin.");
					Minimap.instance.RemovePin(item2);
				}
			}
			stopwatch.Stop();
			Log.LogDebug($"Mod.checkPins took {stopwatch.ElapsedMilliseconds}ms");
			checkingPins = false;
		}

		public static PinData GetNearestPin(Vector3 pos, float radius, List<PinData> pins)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			PinData val = null;
			float num = 999999f;
			foreach (PinData pin in pins)
			{
				float num2 = Utils.DistanceXZ(pos, pin.m_pos);
				if (num2 < radius && (num2 < num || val == null))
				{
					val = pin;
					num = num2;
				}
			}
			return val;
		}
	}
	internal class PinnedObject : MonoBehaviour
	{
		public static PinData pin;

		public static PinType pinType;

		public static bool aSave = false;

		public static bool showName = false;

		public static float pinSize = 20f;

		public static Sprite aIcon;

		public static string aName = "";

		public static int pType;

		public static bool hidePin = false;

		public static PinData updatePin(PinData pin)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected I4, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			Mod.Log.LogDebug("PinnedObject.updatePin start");
			Stopwatch stopwatch = Stopwatch.StartNew();
			loadData(null, (int)pin.m_type);
			if (hidePin)
			{
				Minimap.instance.RemovePin(pin);
				return null;
			}
			string name = ((!Mod.hideAllLabels.Value && showName) ? aName : string.Empty);
			pin.m_name = name;
			pin.m_worldSize = pinSize;
			pin.m_save = aSave;
			if (Object.op_Implicit((Object)(object)aIcon))
			{
				pin.m_icon = aIcon;
			}
			if (!pin.m_save && Mod.distanceFromPlayer(pin.m_pos) > Mod.pinRange.Value)
			{
				Minimap.instance.RemovePin(pin);
			}
			stopwatch.Stop();
			Mod.Log.LogDebug($"PinnedObject.updatePin took {stopwatch.ElapsedMilliseconds}ms");
			return pin;
		}

		public static PinData pinOb(PinType pinItem, Vector3 aPos)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			if (pinItem == null || Mod.currEnv == "Crypt" || Mod.currEnv == "SunkenCrypt" || Mod.currEnv == "FrostCaves" || Mod.currEnv == "InfectedMine")
			{
				return null;
			}
			Mod.Log.LogDebug("PinnedObject.pinOb start");
			Stopwatch stopwatch = Stopwatch.StartNew();
			loadData(pinItem);
			if (hidePin)
			{
				return null;
			}
			if (Mod.SimilarPinExists(aPos, (PinType)pType, Mod.autoPins, aName, aIcon, out var match))
			{
				Mod.dupPinLocs[aPos] = match;
				stopwatch.Stop();
				Mod.Log.LogDebug($"PinnedObject.pinOb took {stopwatch.ElapsedMilliseconds}ms. Similar pin exists.");
				return match;
			}
			string text = ((!Mod.hideAllLabels.Value && showName) ? aName : string.Empty);
			pin = Minimap.instance.AddPin(aPos, (PinType)pType, text, aSave, false, 0L, "");
			if (Object.op_Implicit((Object)(object)aIcon))
			{
				pin.m_icon = aIcon;
			}
			pin.m_worldSize = pinSize;
			pin.m_save = aSave;
			stopwatch.Stop();
			Mod.Log.LogDebug($"PinnedObject.pinOb took {stopwatch.ElapsedMilliseconds}ms. Added Pin");
			return pin;
		}

		private void Update()
		{
		}

		private void OnDestroy()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected I4, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (pin != null && !((Object)(object)Minimap.instance == (Object)null))
			{
				Mod.Log.LogDebug("PinnedObject.OnDestroy on type " + ((object)(PinType)(ref pin.m_type)).ToString());
				Stopwatch stopwatch = Stopwatch.StartNew();
				loadData(null, (int)pin.m_type);
				if (!aSave && !pin.m_save && !(Mod.distanceFromPlayer(pin.m_pos) < Mod.pinRange.Value))
				{
					stopwatch.Stop();
					long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
					Mod.Log.LogDebug($"PinnedObject.OnDestroy took {elapsedMilliseconds}ms");
				}
			}
		}

		public static void loadData(PinType pin = null, int m_type = 0)
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Invalid comparison between Unknown and I4
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Invalid comparison between Unknown and I4
			string text = ((pin == null) ? m_type.ToString() : pin.label);
			Mod.Log.LogDebug("PinnedObject.loadData on type/label " + text);
			Stopwatch stopwatch = Stopwatch.StartNew();
			if (pin == null && m_type > 0)
			{
				if (!Mod.mtypePins.ContainsKey(m_type))
				{
					Mod.Log.LogInfo($"[AMP] Failed to load pin data from minimap pin type {m_type}");
					aName = "";
					return;
				}
				pin = Mod.mtypePins[m_type];
				Mod.Log.LogDebug($"[AMP] Loading pin {pin.label} from minimap type {m_type}");
			}
			pinType = pin;
			aName = pin.label;
			pType = pin.type;
			aSave = Mod.savePinTypes.Value.Split(new char[1] { ',' }).Contains(pin.label);
			aIcon = pin.sprite;
			showName = !Mod.hidePinLabels.Value.Split(new char[1] { ',' }).Contains(pin.label);
			MapMode mapMode = Minimap_Patch.mapMode;
			MapMode val = mapMode;
			if ((int)val != 1)
			{
				if ((int)val == 2)
				{
					pinSize = pin.size;
				}
				else
				{
					pinSize = pin.size;
				}
			}
			else
			{
				pinSize = (float)((pinType.minimapSize != 0) ? pinType.minimapSize : pinType.size) * Mod.minimapSizeMult.Value;
			}
			hidePin = Mod.hidePinTypes.Value != "" && Mod.hidePinTypes.Value.Split(new char[1] { ',' }).Contains(pin.label);
			if (!Mod.destructablesEnabled.Value && pin.pinCat == "Destructable Resource")
			{
				hidePin = true;
			}
			if (!Mod.pickablesEnabled.Value && pin.pinCat == "Pickable")
			{
				hidePin = true;
			}
			if (!Mod.locsEnabled.Value && pin.pinCat == "Location")
			{
				hidePin = true;
			}
			if (!Mod.spwnsEnabled.Value && pin.pinCat == "Spawner")
			{
				hidePin = true;
			}
			if (!Mod.creaturesEnabled.Value && pin.pinCat == "Creature")
			{
				hidePin = true;
			}
			stopwatch.Stop();
			long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
			Mod.Log.LogDebug($"PinnedObject.loadData took {elapsedMilliseconds}ms");
		}
	}
	public class Assets
	{
		public static void Init()
		{
			foreach (KeyValuePair<int, PinType> mtypePin in Mod.mtypePins)
			{
				mtypePin.Value.sprite = LoadSprite(mtypePin.Value.icon);
			}
		}

		internal static Texture2D LoadTexture(byte[] file)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (file.Count() > 0)
			{
				Texture2D val = new Texture2D(2, 2);
				if (ImageConversion.LoadImage(val, file))
				{
					return val;
				}
			}
			return null;
		}

		public static Sprite LoadSprite(string iconPath, float PixelsPerUnit = 50f)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = LoadTexture(ResourceUtils.GetResource(iconPath));
			return Object.op_Implicit((Object)(object)val) ? Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f), PixelsPerUnit) : null;
		}
	}
}
namespace AMP_Configurable.PinConfig
{
	[Serializable]
	public class PinType
	{
		public int type = 0;

		public string label;

		public string icon;

		public Sprite sprite = null;

		public int size = 20;

		public int minimapSize = 0;

		public string[] object_ids;

		public PinData minimapPin = null;

		public bool isPinned = false;

		public string pinCat = "";
	}
	[Serializable]
	public class PinConfig
	{
		public PinType[] pins;
	}
}
namespace AMP_Configurable.Modules
{
	internal class ModConsoleOpt : AMPBaseModule
	{
		private class History
		{
			private List<string> history = new List<string>();

			private int index;

			private string current;

			public void Add(string item)
			{
				history.Add(item);
				index = 0;
			}

			public string Fetch(string current, bool next)
			{
				if (index == 0)
				{
					this.current = current;
				}
				if (history.Count == 0)
				{
					return current;
				}
				index += ((!next) ? 1 : (-1));
				if (history.Count + index >= 0 && history.Count + index <= history.Count - 1)
				{
					return history[history.Count + index];
				}
				index = 0;
				return this.current;
			}
		}

		private string consoleLastMessage = string.Empty;

		private History consoleHistory = new History();

		public ModConsoleOpt()
		{
			ModuleName = "CC Controller";
			Loading();
		}

		public void Start()
		{
			Ready();
		}

		public void HandleConsole()
		{
			if (!((Object)(object)Console.instance != (Object)null))
			{
				return;
			}
			if (((Component)((Terminal)Console.instance).m_chatWindow).gameObject.activeInHierarchy)
			{
				string text = ((TMP_InputField)((Terminal)Console.instance).m_input).text;
				if (Input.GetKeyDown((KeyCode)127) || Input.GetKeyDown((KeyCode)8) || Input.GetKeyDown((KeyCode)27))
				{
					consoleLastMessage = string.Empty;
				}
				if (!text.Equals(string.Empty) && !text.Equals(consoleLastMessage))
				{
					consoleLastMessage = text;
				}
				if (Input.GetKeyDown((KeyCode)13) && text.Equals(string.Empty) && !consoleLastMessage.Equals(string.Empty))
				{
					consoleHistory.Add(consoleLastMessage);
					consoleLastMessage = string.Empty;
				}
				if (Input.GetKeyDown((KeyCode)273))
				{
					((TMP_InputField)((Terminal)Console.instance).m_input).text = consoleHistory.Fetch(text, next: true);
					((TMP_InputField)((Terminal)Console.instance).m_input).caretPosition = ((TMP_InputField)((Terminal)Console.instance).m_input).text.Length;
				}
				if (Input.GetKeyDown((KeyCode)274))
				{
					((TMP_InputField)((Terminal)Console.instance).m_input).text = consoleHistory.Fetch(text, next: false);
				}
			}
			if (Input.GetKeyDown((KeyCode)47) && !Console.IsVisible() && !Chat.instance.IsChatDialogWindowVisible() && !TextInput.IsVisible())
			{
				((Component)((Terminal)Console.instance).m_chatWindow).gameObject.SetActive(true);
				((TMP_InputField)((Terminal)Console.instance).m_input).caretPosition = ((TMP_InputField)((Terminal)Console.instance).m_input).text.Length;
			}
		}

		private void Update()
		{
			HandleConsole();
		}

		private void OnDestroy()
		{
		}
	}
	internal class AMPBaseModule : MonoBehaviour
	{
		internal string ModuleName = "UNNAMED";

		internal ResourceUtils.Status ModuleStatus { get; set; }

		public void RemoveModule()
		{
			Object.Destroy((Object)(object)this);
		}

		internal void Ready()
		{
			ModuleStatus = ResourceUtils.Status.Ready;
		}

		internal void Loading()
		{
			ModuleStatus = ResourceUtils.Status.Loading;
		}

		internal void Error()
		{
			ModuleStatus = ResourceUtils.Status.Error;
		}

		internal void Unload()
		{
			ModuleStatus = ResourceUtils.Status.Unload;
		}
	}
	internal interface IModule
	{
		void BeginMenu();

		void Start();
	}
}
namespace AMP_Configurable.Patches
{
	internal class Minimap_Patch : MonoBehaviour
	{
		public static int count = 0;

		public static bool checkedSavedPins = false;

		public static MapMode mapMode = (MapMode)1;

		[HarmonyPatch(typeof(Minimap), "ScreenToWorldPoint", new Type[] { typeof(Vector3) })]
		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		public static Vector3 ScreenToWorldPoint(object instance, Vector3 screenPos)
		{
			throw new NotImplementedException();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Minimap), "Awake")]
		private static void Minimap_Awake()
		{
			checkedSavedPins = false;
			Mod.dupPinLocs.Clear();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Minimap), "Start")]
		private static void Minimap_Start(Minimap __instance, ref bool[] ___m_visibleIconTypes)
		{
			___m_visibleIconTypes = new bool[150];
			for (int i = 0; i < ___m_visibleIconTypes.Length; i++)
			{
				___m_visibleIconTypes[i] = true;
			}
		}

		[HarmonyPatch(typeof(Minimap), "AddPin")]
		[HarmonyPostfix]
		private static PinData Minimap_AddPin_PostFix(PinData pin)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.pinItems.TryGetValue(pin.m_pos, out var _))
			{
				Mod.pinItems[pin.m_pos].isPinned = true;
				Mod.pinItems[pin.m_pos].minimapPin = pin;
				Mod.autoPins.Add(pin);
			}
			return pin;
		}

		[HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(PinData) })]
		[HarmonyPrefix]
		private static void Minimap_RemovePin(ref Minimap __instance, PinData pin)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.pinItems.ContainsKey(pin.m_pos))
			{
				Mod.pinItems[pin.m_pos].minimapPin = null;
				Mod.pinItems[pin.m_pos].isPinned = false;
			}
			if (Mod.dupPinLocs.ContainsKey(pin.m_pos))
			{
				Mod.dupPinLocs.Remove(pin.m_pos);
			}
			if (Mod.autoPins.Contains(pin))
			{
				Mod.autoPins.Remove(pin);
			}
		}

		[HarmonyPatch(typeof(Minimap), "UpdateProfilePins")]
		[HarmonyPrefix]
		private static void Minimap_UpdateProfilePins(ref List<PinData> ___m_pins)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected I4, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Invalid comparison between Unknown and I4
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected I4, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if (checkedSavedPins)
			{
				return;
			}
			Mod.Log.LogDebug("Minimap.UpdateProfilePins checking saved pins");
			Stopwatch stopwatch = Stopwatch.StartNew();
			foreach (PinData ___m_pin in ___m_pins)
			{
				if ((int)___m_pin.m_type < 100)
				{
					continue;
				}
				PinnedObject.loadData(null, (int)___m_pin.m_type);
				if (PinnedObject.hidePin)
				{
					Minimap.instance.RemovePin(___m_pin);
					continue;
				}
				if ((int)___m_pin.m_type == PinnedObject.pType)
				{
					___m_pin.m_icon = PinnedObject.aIcon;
					___m_pin.m_worldSize = PinnedObject.pinSize;
					if (!PinnedObject.showName)
					{
						___m_pin.m_name = string.Empty;
					}
				}
				if (Mod.mtypePins.TryGetValue((int)___m_pin.m_type, out var value))
				{
					Mod.pinItems[___m_pin.m_pos] = value;
					Mod.pinItems[___m_pin.m_pos].minimapPin = ___m_pin;
				}
				Mod.autoPins.Add(___m_pin);
			}
			checkedSavedPins = true;
			Mod.checkPins(firstLoad: true);
			stopwatch.Stop();
			long elapsedMilliseconds = stopwatch.ElapsedMilliseconds;
			Mod.Log.LogDebug($"Minimap.UpdateProfilePins checking saved pins took {elapsedMilliseconds}ms");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Minimap), "SetMapMode")]
		private static void Minimap_ChangeMapMode(Minimap __instance, ref MapMode ___m_mode)
		{
			//IL_0020: 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_004e: Expected I4, but got Unknown
			Mod.Log.LogDebug($"Minimap.SetMapMode - Mode changed to {___m_mode}");
			Stopwatch stopwatch = Stopwatch.StartNew();
			mapMode = ___m_mode;
			foreach (PinData autoPin in Mod.autoPins)
			{
				if (Mod.mtypePins.TryGetValue((int)autoPin.m_type, out var value))
				{
					float worldSize = value.size;
					if ((int)___m_mode == 1)
					{
						worldSize = (float)((value.minimapSize != 0) ? value.minimapSize : value.size) * Mod.minimapSizeMult.Value;
					}
					autoPin.m_worldSize = worldSize;
				}
			}
			stopwatch.Stop();
			Mod.Log.LogDebug($"Minimap.SetMapMode timing {stopwatch.ElapsedMilliseconds}ms");
		}

		[HarmonyPatch(typeof(Minimap), "OnMapRightClick")]
		[HarmonyPrefix]
		private static bool Minimap_OMRC(Minimap __instance, ref List<PinData> ___m_pins)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			Mod.Log.LogDebug("Minimap.OnMapRightClick");
			ZLog.Log((object)"[AMP] Right click");
			Vector3 pos = ScreenToWorldPoint(__instance, Input.mousePosition);
			PinData nearestPin = Mod.GetNearestPin(pos, 10f, ___m_pins);
			if (nearestPin == null || ((Object)nearestPin.m_icon).name == "mapicon_start" || (int)nearestPin.m_type == 4)
			{
				return true;
			}
			__instance.RemovePin(nearestPin);
			return false;
		}

		[HarmonyPatch(typeof(Minimap), "OnMapLeftClick")]
		[HarmonyPrefix]
		private static bool Minimap_OMLC(Minimap __instance, ref List<PinData> ___m_pins)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Mod.Log.LogDebug("Minimap.OnMapLeftClick");
			ZLog.Log((object)"[AMP] Left click");
			Vector3 pos = ScreenToWorldPoint(__instance, Input.mousePosition);
			PinData nearestPin = Mod.GetNearestPin(pos, 10f, ___m_pins);
			if (nearestPin == null)
			{
				return true;
			}
			nearestPin.m_checked = !nearestPin.m_checked;
			return false;
		}
	}
	internal class Pin_Registration_Patches : MonoBehaviour
	{
		[HarmonyPatch(typeof(Destructible), "Start")]
		[HarmonyPostfix]
		private static void DestructibleSpawnPatch(ref Destructible __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.destructablesEnabled.Value)
			{
				HoverText component = ((Component)__instance).GetComponent<HoverText>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string text = component.m_text;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Destructable Resource", text, position);
				}
			}
		}

		[HarmonyPatch(typeof(Pickable), "Awake")]
		[HarmonyPostfix]
		private static void PickableSpawnPatch(ref Pickable __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.pickablesEnabled.Value)
			{
				Pickable component = ((Component)__instance).GetComponent<Pickable>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string name = ((Object)component).name;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Pickable", name, position);
				}
			}
		}

		[HarmonyPatch(typeof(Location), "Awake")]
		[HarmonyPostfix]
		private static void LocationSpawnPatch(ref Location __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.locsEnabled.Value)
			{
				Location component = ((Component)__instance).GetComponent<Location>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string name = ((Object)component).name;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Location", name, position);
				}
			}
		}

		[HarmonyPatch(typeof(SpawnArea), "Awake")]
		[HarmonyPostfix]
		private static void SpawnAreaSpawnPatch(ref Location __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.spwnsEnabled.Value)
			{
				HoverText component = ((Component)__instance).GetComponent<HoverText>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string text = component.m_text;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Spawner", text, position);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "Awake")]
		private static void CharacterSpawnPatch(ref CreatureSpawner __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.creaturesEnabled.Value)
			{
				Character component = ((Component)__instance).GetComponent<Character>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string name = ((Object)component).name;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Creature", name, position);
				}
			}
		}

		[HarmonyPatch(typeof(MineRock), "Start")]
		[HarmonyPostfix]
		private static void MineRockSpawnPatch(ref MineRock __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.destructablesEnabled.Value)
			{
				MineRock component = ((Component)__instance).GetComponent<MineRock>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string name = ((Object)component).name;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Destructable Resource", name, position);
				}
			}
		}

		[HarmonyPatch(typeof(Leviathan), "Awake")]
		[HarmonyPostfix]
		private static void LeviathanSpawnPatch(ref Leviathan __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.creaturesEnabled.Value)
			{
				Leviathan component = ((Component)__instance).GetComponent<Leviathan>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string name = ((Object)component).name;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Destructable Resource", name, position);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TreeBase), "Awake")]
		private static void TreeBaseSpawnPatch(ref TreeBase __instance)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Mod.destructablesEnabled.Value)
			{
				TreeBase component = ((Component)__instance).GetComponent<TreeBase>();
				if (Object.op_Implicit((Object)(object)component))
				{
					string name = ((Object)component).name;
					Vector3 position = ((Component)component).transform.position;
					Mod.pinObject("Destructable Resource", name, position);
				}
			}
		}
	}
	internal class Player_Patches
	{
		[HarmonyPatch(typeof(Player), "Awake")]
		internal class PlayerAwakePatch
		{
			private static void Postfix(ref Player __instance)
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && ((Character)__instance).IsOwner() && !Game.IsPaused() && !Mod.checkingPins)
				{
					currPos = ((Component)__instance).transform.position;
					prevPos = ((Component)__instance).transform.position;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		internal class PlayerUpdatePatch
		{
			private static void Postfix(ref Player __instance)
			{
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && ((Character)__instance).IsOwner() && !Game.IsPaused() && !Mod.checkingPins && !Mod.hasMoved)
				{
					Mod.currEnv = EnvMan.instance.GetCurrentEnvironment().m_name;
					if (Time.frameCount % 120 == 0)
					{
						currPos = ((Component)__instance).transform.position;
						Mod.hasMoved = Vector3.Distance(currPos, prevPos) > 5f;
					}
					if (Mod.hasMoved)
					{
						Mod.hasMoved = false;
						prevPos = currPos;
						Mod.Log.LogDebug("Patches.PlayerUpdatePatch player movement detected. Check Pins");
						Mod.checkPins();
					}
				}
			}
		}

		public static Vector3 currPos;

		public static Vector3 prevPos;

		public const int interval = 120;
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class IsReadOnlyAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace System.Diagnostics.CodeAnalysis
{
	[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)]
	internal sealed class NotNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)]
	internal sealed class NotNullWhenAttribute : Attribute
	{
		public bool ReturnValue { get; }

		public NotNullWhenAttribute(bool returnValue)
		{
			ReturnValue = returnValue;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)]
	internal sealed class MaybeNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)]
	internal sealed class AllowNullAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
	internal class DoesNotReturnIfAttribute : Attribute
	{
		public bool ParameterValue { get; }

		public DoesNotReturnIfAttribute(bool parameterValue)
		{
			ParameterValue = parameterValue;
		}
	}
}
namespace Newtonsoft.Json
{
	internal enum ConstructorHandling
	{
		Default,
		AllowNonPublicDefaultConstructor
	}
	internal enum DateFormatHandling
	{
		IsoDateFormat,
		MicrosoftDateFormat
	}
	internal enum DateParseHandling
	{
		None,
		DateTime,
		DateTimeOffset
	}
	internal enum DateTimeZoneHandling
	{
		Local,
		Utc,
		Unspecified,
		RoundtripKind
	}
	internal class DefaultJsonNameTable : JsonNameTable
	{
		private class Entry
		{
			internal readonly string Value;

			internal readonly int HashCode;

			internal Entry Next;

			internal Entry(string value, int hashCode, Entry next)
			{
				Value = value;
				HashCode = hashCode;
				Next = next;
			}
		}

		private static readonly int HashCodeRandomizer;

		private int _count;

		private Entry[] _entries;

		private int _mask = 31;

		static DefaultJsonNameTable()
		{
			HashCodeRandomizer = Environment.TickCount;
		}

		public DefaultJsonNameTable()
		{
			_entries = new Entry[_mask + 1];
		}

		public override string? Get(char[] key, int start, int length)
		{
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			num += (num << 7) ^ key[start];
			int num2 = start + length;
			for (int i = start + 1; i < num2; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			int num3 = Volatile.Read(ref _mask);
			int num4 = num & num3;
			for (Entry entry = _entries[num4]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && TextEquals(entry.Value, key, start, length))
				{
					return entry.Value;
				}
			}
			return null;
		}

		public string Add(string key)
		{
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			int length = key.Length;
			if (length == 0)
			{
				return string.Empty;
			}
			int num = length + HashCodeRandomizer;
			for (int i = 0; i < key.Length; i++)
			{
				num += (num << 7) ^ key[i];
			}
			num -= num >> 17;
			num -= num >> 11;
			num -= num >> 5;
			for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next)
			{
				if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal))
				{
					return entry.Value;
				}
			}
			return AddEntry(key, num);
		}

		private string AddEntry(string str, int hashCode)
		{
			int num = hashCode & _mask;
			Entry entry = new Entry(str, hashCode, _entries[num]);
			_entries[num] = entry;
			if (_count++ == _mask)
			{
				Grow();
			}
			return entry.Value;
		}

		private void Grow()
		{
			Entry[] entries = _entries;
			int num = _mask * 2 + 1;
			Entry[] array = new Entry[num + 1];
			for (int i = 0; i < entries.Length; i++)
			{
				Entry entry = entries[i];
				while (entry != null)
				{
					int num2 = entry.HashCode & num;
					Entry next = entry.Next;
					entry.Next = array[num2];
					array[num2] = entry;
					entry = next;
				}
			}
			_entries = array;
			Volatile.Write(ref _mask, num);
		}

		private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length)
		{
			if (str1.Length != str2Length)
			{
				return false;
			}
			for (int i = 0; i < str1.Length; i++)
			{
				if (str1[i] != str2[str2Start + i])
				{
					return false;
				}
			}
			return true;
		}
	}
	[Flags]
	internal enum DefaultValueHandling
	{
		Include = 0,
		Ignore = 1,
		Populate = 2,
		IgnoreAndPopulate = 3
	}
	internal enum FloatFormatHandling
	{
		String,
		Symbol,
		DefaultValue
	}
	internal enum FloatParseHandling
	{
		Double,
		Decimal
	}
	internal enum Formatting
	{
		None,
		Indented
	}
	internal interface IArrayPool<T>
	{
		T[] Rent(int minimumLength);

		void Return(T[]? array);
	}
	internal interface IJsonLineInfo
	{
		int LineNumber { get; }

		int LinePosition { get; }

		bool HasLineInfo();
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	internal sealed class JsonArrayAttribute : JsonContainerAttribute
	{
		private bool _allowNullItems;

		public bool AllowNullItems
		{
			get
			{
				return _allowNullItems;
			}
			set
			{
				_allowNullItems = value;
			}
		}

		public JsonArrayAttribute()
		{
		}

		public JsonArrayAttribute(bool allowNullItems)
		{
			_allowNullItems = allowNullItems;
		}

		public JsonArrayAttribute(string id)
			: base(id)
		{
		}
	}
	[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)]
	internal sealed class JsonConstructorAttribute : Attribute
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	internal abstract class JsonContainerAttribute : Attribute
	{
		internal bool? _isReference;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		private Type? _namingStrategyType;

		private object[]? _namingStrategyParameters;

		public string? Id { get; set; }

		public string? Title { get; set; }

		public string? Description { get; set; }

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType
		{
			get
			{
				return _namingStrategyType;
			}
			set
			{
				_namingStrategyType = value;
				NamingStrategyInstance = null;
			}
		}

		public object[]? NamingStrategyParameters
		{
			get
			{
				return _namingStrategyParameters;
			}
			set
			{
				_namingStrategyParameters = value;
				NamingStrategyInstance = null;
			}
		}

		internal NamingStrategy? NamingStrategyInstance { get; set; }

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		protected JsonContainerAttribute()
		{
		}

		protected JsonContainerAttribute(string id)
		{
			Id = id;
		}
	}
	internal static class JsonConvert
	{
		public static readonly string True = "true";

		public static readonly string False = "false";

		public static readonly string Null = "null";

		public static readonly string Undefined = "undefined";

		public static readonly string PositiveInfinity = "Infinity";

		public static readonly string NegativeInfinity = "-Infinity";

		public static readonly string NaN = "NaN";

		public static Func<JsonSerializerSettings>? DefaultSettings { get; set; }

		public static string ToString(DateTime value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind);
		}

		public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling)
		{
			DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling);
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(DateTimeOffset value)
		{
			return ToString(value, DateFormatHandling.IsoDateFormat);
		}

		public static string ToString(DateTimeOffset value, DateFormatHandling format)
		{
			using StringWriter stringWriter = StringUtils.CreateStringWriter(64);
			stringWriter.Write('"');
			DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture);
			stringWriter.Write('"');
			return stringWriter.ToString();
		}

		public static string ToString(bool value)
		{
			if (!value)
			{
				return False;
			}
			return True;
		}

		public static string ToString(char value)
		{
			return ToString(char.ToString(value));
		}

		public static string ToString(Enum value)
		{
			return value.ToString("D");
		}

		public static string ToString(int value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(short value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ushort value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(uint value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(long value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		private static string ToStringInternal(BigInteger value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(ulong value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(float value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value)))
			{
				return text;
			}
			if (floatFormatHandling == FloatFormatHandling.DefaultValue)
			{
				if (nullable)
				{
					return Null;
				}
				return "0.0";
			}
			return quoteChar + text + quoteChar;
		}

		public static string ToString(double value)
		{
			return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable)
		{
			return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable);
		}

		private static string EnsureDecimalPlace(double value, string text)
		{
			if (double.IsNaN(value) || double.IsInfinity(value) || StringUtils.IndexOf(text, '.') != -1 || StringUtils.IndexOf(text, 'E') != -1 || StringUtils.IndexOf(text, 'e') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		private static string EnsureDecimalPlace(string text)
		{
			if (StringUtils.IndexOf(text, '.') != -1)
			{
				return text;
			}
			return text + ".0";
		}

		public static string ToString(byte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		[CLSCompliant(false)]
		public static string ToString(sbyte value)
		{
			return value.ToString(null, CultureInfo.InvariantCulture);
		}

		public static string ToString(decimal value)
		{
			return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture));
		}

		public static string ToString(Guid value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(Guid value, char quoteChar)
		{
			string text = value.ToString("D", CultureInfo.InvariantCulture);
			string text2 = quoteChar.ToString(CultureInfo.InvariantCulture);
			return text2 + text + text2;
		}

		public static string ToString(TimeSpan value)
		{
			return ToString(value, '"');
		}

		internal static string ToString(TimeSpan value, char quoteChar)
		{
			return ToString(value.ToString(), quoteChar);
		}

		public static string ToString(Uri? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ToString(value, '"');
		}

		internal static string ToString(Uri value, char quoteChar)
		{
			return ToString(value.OriginalString, quoteChar);
		}

		public static string ToString(string? value)
		{
			return ToString(value, '"');
		}

		public static string ToString(string? value, char delimiter)
		{
			return ToString(value, delimiter, StringEscapeHandling.Default);
		}

		public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling)
		{
			if (delimiter != '"' && delimiter != '\'')
			{
				throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter");
			}
			return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling);
		}

		public static string ToString(object? value)
		{
			if (value == null)
			{
				return Null;
			}
			return ConvertUtils.GetTypeCode(value.GetType()) switch
			{
				PrimitiveTypeCode.String => ToString((string)value), 
				PrimitiveTypeCode.Char => ToString((char)value), 
				PrimitiveTypeCode.Boolean => ToString((bool)value), 
				PrimitiveTypeCode.SByte => ToString((sbyte)value), 
				PrimitiveTypeCode.Int16 => ToString((short)value), 
				PrimitiveTypeCode.UInt16 => ToString((ushort)value), 
				PrimitiveTypeCode.Int32 => ToString((int)value), 
				PrimitiveTypeCode.Byte => ToString((byte)value), 
				PrimitiveTypeCode.UInt32 => ToString((uint)value), 
				PrimitiveTypeCode.Int64 => ToString((long)value), 
				PrimitiveTypeCode.UInt64 => ToString((ulong)value), 
				PrimitiveTypeCode.Single => ToString((float)value), 
				PrimitiveTypeCode.Double => ToString((double)value), 
				PrimitiveTypeCode.DateTime => ToString((DateTime)value), 
				PrimitiveTypeCode.Decimal => ToString((decimal)value), 
				PrimitiveTypeCode.DBNull => Null, 
				PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), 
				PrimitiveTypeCode.Guid => ToString((Guid)value), 
				PrimitiveTypeCode.Uri => ToString((Uri)value), 
				PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), 
				PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), 
				_ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), 
			};
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value)
		{
			return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting)
		{
			return SerializeObject(value, formatting, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings)
		{
			return SerializeObject(value, null, formatting, settings);
		}

		[DebuggerStepThrough]
		public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			jsonSerializer.Formatting = formatting;
			return SerializeObjectInternal(value, type, jsonSerializer);
		}

		private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer)
		{
			StringWriter stringWriter = new StringWriter(new StringBuilder(256), CultureInfo.InvariantCulture);
			using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter))
			{
				jsonTextWriter.Formatting = jsonSerializer.Formatting;
				jsonSerializer.Serialize(jsonTextWriter, value, type);
			}
			return stringWriter.ToString();
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value)
		{
			return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, JsonSerializerSettings settings)
		{
			return DeserializeObject(value, null, settings);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, Type type)
		{
			return DeserializeObject(value, type, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static T? DeserializeObject<T>(string value)
		{
			return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null);
		}

		[DebuggerStepThrough]
		public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject)
		{
			return DeserializeObject<T>(value);
		}

		[DebuggerStepThrough]
		public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings)
		{
			return DeserializeObject<T>(value, settings);
		}

		[DebuggerStepThrough]
		public static T? DeserializeObject<T>(string value, params JsonConverter[] converters)
		{
			return (T)DeserializeObject(value, typeof(T), converters);
		}

		[DebuggerStepThrough]
		public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings)
		{
			return (T)DeserializeObject(value, typeof(T), settings);
		}

		[DebuggerStepThrough]
		public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters)
		{
			JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings
			{
				Converters = converters
			} : null);
			return DeserializeObject(value, type, settings);
		}

		public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings)
		{
			ValidationUtils.ArgumentNotNull(value, "value");
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			if (!jsonSerializer.IsCheckAdditionalContentSet())
			{
				jsonSerializer.CheckAdditionalContent = true;
			}
			using JsonTextReader reader = new JsonTextReader(new StringReader(value));
			return jsonSerializer.Deserialize(reader, type);
		}

		[DebuggerStepThrough]
		public static void PopulateObject(string value, object target)
		{
			PopulateObject(value, target, null);
		}

		public static void PopulateObject(string value, object target, JsonSerializerSettings? settings)
		{
			JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings);
			using JsonReader jsonReader = new JsonTextReader(new StringReader(value));
			jsonSerializer.Populate(jsonReader, target);
			if (settings == null || !settings.CheckAdditionalContent)
			{
				return;
			}
			while (jsonReader.Read())
			{
				if (jsonReader.TokenType != JsonToken.Comment)
				{
					throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object.");
				}
			}
		}

		public static string SerializeXmlNode(XmlNode? node)
		{
			return SerializeXmlNode(node, Formatting.None);
		}

		public static string SerializeXmlNode(XmlNode? node, Formatting formatting)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static XmlDocument? DeserializeXmlNode(string value)
		{
			return DeserializeXmlNode(value, null);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter);
		}

		public static string SerializeXNode(XObject? node)
		{
			return SerializeXNode(node, Formatting.None);
		}

		public static string SerializeXNode(XObject? node, Formatting formatting)
		{
			return SerializeXNode(node, formatting, omitRootObject: false);
		}

		public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject)
		{
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter
			{
				OmitRootObject = omitRootObject
			};
			return SerializeObject(node, formatting, xmlNodeConverter);
		}

		public static XDocument? DeserializeXNode(string value)
		{
			return DeserializeXNode(value, null);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute)
		{
			return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false);
		}

		public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			XmlNodeConverter xmlNodeConverter = new XmlNodeConverter();
			xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName;
			xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute;
			xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters;
			return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter);
		}
	}
	internal abstract class JsonConverter
	{
		public virtual bool CanRead => true;

		public virtual bool CanWrite => true;

		public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer);

		public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer);

		public abstract bool CanConvert(Type objectType);
	}
	internal abstract class JsonConverter<T> : JsonConverter
	{
		public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
		{
			if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T))))
			{
				throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			WriteJson(writer, (T)value, serializer);
		}

		public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer);

		public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
		{
			bool flag = existingValue == null;
			if (!flag && !(existingValue is T))
			{
				throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T)));
			}
			return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer);
		}

		public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer);

		public sealed override bool CanConvert(Type objectType)
		{
			return typeof(T).IsAssignableFrom(objectType);
		}
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)]
	internal sealed class JsonConverterAttribute : Attribute
	{
		private readonly Type _converterType;

		public Type ConverterType => _converterType;

		public object[]? ConverterParameters { get; }

		public JsonConverterAttribute(Type converterType)
		{
			if (converterType == null)
			{
				throw new ArgumentNullException("converterType");
			}
			_converterType = converterType;
		}

		public JsonConverterAttribute(Type converterType, params object[] converterParameters)
			: this(converterType)
		{
			ConverterParameters = converterParameters;
		}
	}
	internal class JsonConverterCollection : Collection<JsonConverter>
	{
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)]
	internal sealed class JsonDictionaryAttribute : JsonContainerAttribute
	{
		public JsonDictionaryAttribute()
		{
		}

		public JsonDictionaryAttribute(string id)
			: base(id)
		{
		}
	}
	[Serializable]
	internal class JsonException : Exception
	{
		public JsonException()
		{
		}

		public JsonException(string message)
			: base(message)
		{
		}

		public JsonException(string message, Exception? innerException)
			: base(message, innerException)
		{
		}

		public JsonException(SerializationInfo info, StreamingContext context)
			: base(info, context)
		{
		}

		internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message)
		{
			message = JsonPosition.FormatMessage(lineInfo, path, message);
			return new JsonException(message);
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	internal class JsonExtensionDataAttribute : Attribute
	{
		public bool WriteData { get; set; }

		public bool ReadData { get; set; }

		public JsonExtensionDataAttribute()
		{
			WriteData = true;
			ReadData = true;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
	internal sealed class JsonIgnoreAttribute : Attribute
	{
	}
	internal abstract class JsonNameTable
	{
		public abstract string? Get(char[] key, int start, int length);
	}
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)]
	internal sealed class JsonObjectAttribute : JsonContainerAttribute
	{
		private MemberSerialization _memberSerialization;

		internal MissingMemberHandling? _missingMemberHandling;

		internal Required? _itemRequired;

		internal NullValueHandling? _itemNullValueHandling;

		public MemberSerialization MemberSerialization
		{
			get
			{
				return _memberSerialization;
			}
			set
			{
				_memberSerialization = value;
			}
		}

		public MissingMemberHandling MissingMemberHandling
		{
			get
			{
				return _missingMemberHandling.GetValueOrDefault();
			}
			set
			{
				_missingMemberHandling = value;
			}
		}

		public NullValueHandling ItemNullValueHandling
		{
			get
			{
				return _itemNullValueHandling.GetValueOrDefault();
			}
			set
			{
				_itemNullValueHandling = value;
			}
		}

		public Required ItemRequired
		{
			get
			{
				return _itemRequired.GetValueOrDefault();
			}
			set
			{
				_itemRequired = value;
			}
		}

		public JsonObjectAttribute()
		{
		}

		public JsonObjectAttribute(MemberSerialization memberSerialization)
		{
			MemberSerialization = memberSerialization;
		}

		public JsonObjectAttribute(string id)
			: base(id)
		{
		}
	}
	internal enum JsonContainerType
	{
		None,
		Object,
		Array,
		Constructor
	}
	internal struct JsonPosition
	{
		private static readonly char[] SpecialCharacters = new char[18]
		{
			'.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t',
			'\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029'
		};

		internal JsonContainerType Type;

		internal int Position;

		internal string? PropertyName;

		internal bool HasIndex;

		public JsonPosition(JsonContainerType type)
		{
			Type = type;
			HasIndex = TypeHasIndex(type);
			Position = -1;
			PropertyName = null;
		}

		internal int CalculateLength()
		{
			switch (Type)
			{
			case JsonContainerType.Object:
				return PropertyName.Length + 5;
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				return MathUtils.IntLength((ulong)Position) + 2;
			default:
				throw new ArgumentOutOfRangeException("Type");
			}
		}

		internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer)
		{
			switch (Type)
			{
			case JsonContainerType.Object:
			{
				string propertyName = PropertyName;
				if (propertyName.IndexOfAny(SpecialCharacters) != -1)
				{
					sb.Append("['");
					if (writer == null)
					{
						writer = new StringWriter(sb);
					}
					JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer);
					sb.Append("']");
				}
				else
				{
					if (sb.Length > 0)
					{
						sb.Append('.');
					}
					sb.Append(propertyName);
				}
				break;
			}
			case JsonContainerType.Array:
			case JsonContainerType.Constructor:
				sb.Append('[');
				sb.Append(Position);
				sb.Append(']');
				break;
			}
		}

		internal static bool TypeHasIndex(JsonContainerType type)
		{
			if (type != JsonContainerType.Array)
			{
				return type == JsonContainerType.Constructor;
			}
			return true;
		}

		internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition)
		{
			int num = 0;
			if (positions != null)
			{
				for (int i = 0; i < positions.Count; i++)
				{
					num += positions[i].CalculateLength();
				}
			}
			if (currentPosition.HasValue)
			{
				num += currentPosition.GetValueOrDefault().CalculateLength();
			}
			StringBuilder stringBuilder = new StringBuilder(num);
			StringWriter writer = null;
			char[] buffer = null;
			if (positions != null)
			{
				foreach (JsonPosition position in positions)
				{
					position.WriteTo(stringBuilder, ref writer, ref buffer);
				}
			}
			currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer);
			return stringBuilder.ToString();
		}

		internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message)
		{
			if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal))
			{
				message = message.Trim();
				if (!StringUtils.EndsWith(message, '.'))
				{
					message += ".";
				}
				message += " ";
			}
			message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path);
			if (lineInfo != null && lineInfo.HasLineInfo())
			{
				message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition);
			}
			message += ".";
			return message;
		}
	}
	[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
	internal sealed class JsonPropertyAttribute : Attribute
	{
		internal NullValueHandling? _nullValueHandling;

		internal DefaultValueHandling? _defaultValueHandling;

		internal ReferenceLoopHandling? _referenceLoopHandling;

		internal ObjectCreationHandling? _objectCreationHandling;

		internal TypeNameHandling? _typeNameHandling;

		internal bool? _isReference;

		internal int? _order;

		internal Required? _required;

		internal bool? _itemIsReference;

		internal ReferenceLoopHandling? _itemReferenceLoopHandling;

		internal TypeNameHandling? _itemTypeNameHandling;

		public Type? ItemConverterType { get; set; }

		public object[]? ItemConverterParameters { get; set; }

		public Type? NamingStrategyType { get; set; }

		public object[]? NamingStrategyParameters { get; set; }

		public NullValueHandling NullValueHandling
		{
			get
			{
				return _nullValueHandling.GetValueOrDefault();
			}
			set
			{
				_nullValueHandling = value;
			}
		}

		public DefaultValueHandling DefaultValueHandling
		{
			get
			{
				return _defaultValueHandling.GetValueOrDefault();
			}
			set
			{
				_defaultValueHandling = value;
			}
		}

		public ReferenceLoopHandling ReferenceLoopHandling
		{
			get
			{
				return _referenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_referenceLoopHandling = value;
			}
		}

		public ObjectCreationHandling ObjectCreationHandling
		{
			get
			{
				return _objectCreationHandling.GetValueOrDefault();
			}
			set
			{
				_objectCreationHandling = value;
			}
		}

		public TypeNameHandling TypeNameHandling
		{
			get
			{
				return _typeNameHandling.GetValueOrDefault();
			}
			set
			{
				_typeNameHandling = value;
			}
		}

		public bool IsReference
		{
			get
			{
				return _isReference.GetValueOrDefault();
			}
			set
			{
				_isReference = value;
			}
		}

		public int Order
		{
			get
			{
				return _order.GetValueOrDefault();
			}
			set
			{
				_order = value;
			}
		}

		public Required Required
		{
			get
			{
				return _required.GetValueOrDefault();
			}
			set
			{
				_required = value;
			}
		}

		public string? PropertyName { get; set; }

		public ReferenceLoopHandling ItemReferenceLoopHandling
		{
			get
			{
				return _itemReferenceLoopHandling.GetValueOrDefault();
			}
			set
			{
				_itemReferenceLoopHandling = value;
			}
		}

		public TypeNameHandling ItemTypeNameHandling
		{
			get
			{
				return _itemTypeNameHandling.GetValueOrDefault();
			}
			set
			{
				_itemTypeNameHandling = value;
			}
		}

		public bool ItemIsReference
		{
			get
			{
				return _itemIsReference.GetValueOrDefault();
			}
			set
			{
				_itemIsReference = value;
			}
		}

		public JsonPropertyAttribute()
		{
		}

		public JsonPropertyAttribute(string propertyName)
		{
			PropertyName = propertyName;
		}
	}
	internal abstract class JsonReader : IDisposable
	{
		protected internal enum State
		{
			Start,
			Complete,
			Property,
			ObjectStart,
			Object,
			ArrayStart,
			Array,
			Closed,
			PostValue,
			ConstructorStart,
			Constructor,
			Error,
			Finished
		}

		private JsonToken _tokenType;

		private object? _value;

		internal char _quoteChar;

		internal State _currentState;

		private JsonPosition _currentPosition;

		private CultureInfo? _culture;

		private DateTimeZoneHandling _dateTimeZoneHandling;

		private int? _maxDepth;

		private bool _hasExceededMaxDepth;

		internal DateParseHandling _dateParseHandling;

		internal FloatParseHandling _floatParseHandling;

		private string? _dateFormatString;

		private List<JsonPosition>? _stack;

		protected State CurrentState => _currentState;

		public bool CloseInput { get; set; }

		public bool SupportMultipleContent { get; set; }

		public virtual char QuoteChar
		{
			get
			{
				return _quoteChar;
			}
			protected internal set
			{
				_quoteChar = value;
			}
		}

		public DateTimeZoneHandling DateTimeZoneHandling
		{
			get
			{
				return _dateTimeZoneHandling;
			}
			set
			{
				if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateTimeZoneHandling = value;
			}
		}

		public DateParseHandling DateParseHandling
		{
			get
			{
				return _dateParseHandling;
			}
			set
			{
				if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_dateParseHandling = value;
			}
		}

		public FloatParseHandling FloatParseHandling
		{
			get
			{
				return _floatParseHandling;
			}
			set
			{
				if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal)
				{
					throw new ArgumentOutOfRangeException("value");
				}
				_floatParseHandling = value;
			}
		}

		public string? DateFormatString
		{
			get
			{
				return _dateFormatString;
			}
			set
			{
				_dateFormatString = value;
			}
		}

		public int? MaxDepth
		{
			get
			{
				return _maxDepth;
			}
			set
			{
				if (value <= 0)
				{
					throw new ArgumentException("Value must be positive.", "value");
				}
				_maxDepth = value;
			}
		}

		public virtual JsonToken TokenType => _tokenType;

		public virtual object? Value => _value;

		public virtual Type? ValueType => _value?.GetType();

		public virtual int Depth
		{
			get
			{
				int num = _stack?.Count ?? 0;
				if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None)
				{
					return num;
				}
				return num + 1;
			}
		}

		public virtual string Path
		{
			get
			{
				if (_currentPosition.Type == JsonContainerType.None)
				{
					return string.Empty;
				}
				JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null);
				return JsonPosition.BuildPath(_stack, currentPosition);
			}
		}

		public CultureInfo Culture
		{
			get
			{
				return _culture ?? CultureInfo.InvariantCulture;
			}
			set
			{
				_culture = value;
			}
		}

		public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync();
		}

		public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			if (TokenType == JsonToken.PropertyName)
			{
				await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			if (JsonTokenUtils.IsStartToken(TokenType))
			{
				int depth = Depth;
				while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth)
				{
				}
			}
		}

		internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken)
		{
			if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
			{
				throw CreateUnexpectedEndException();
			}
		}

		public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean());
		}

		public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes());
		}

		internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken)
		{
			List<byte> buffer = new List<byte>();
			do
			{
				if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false)))
				{
					SetToken(JsonToken.None);
				}
			}
			while (!ReadArrayElementIntoByteArrayReportDone(buffer));
			byte[] array = buffer.ToArray();
			SetToken(JsonToken.Bytes, array, updateIndex: false);
			return array;
		}

		public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime());
		}

		public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset());
		}

		public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal());
		}

		public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return Task.FromResult(ReadAsDouble());
		}

		public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32());
		}

		public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken))
		{
			return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString());
		}

		internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken)
		{
			bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			if (flag)
			{
				flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false);
			}
			return flag;
		}

		internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tokenType = TokenType;
			if (tokenType == JsonToken.None || tokenType == JsonToken.Comment)
			{
				return MoveToContentFromNonContentAsync(cancellationToken);
			}
			return AsyncUtils.True;
		}

		private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken)
		{
			JsonToken tok