Decompiled source of PinAssistant v1.7.0

plugins\WxAxW.PinAssistant.dll

Decompiled 11 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.GUI;
using Jotunn.Managers;
using Jotunn.Utils;
using Kits_Bitz.Under_The_Radar;
using Newtonsoft.Json;
using Pinnacle;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using WxAxW.PinAssistant.Components;
using WxAxW.PinAssistant.Configuration;
using WxAxW.PinAssistant.Core;
using WxAxW.PinAssistant.Patches;
using WxAxW.PinAssistant.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("WxAxWValheimMods")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WxAxWValheimMods")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
[module: UnverifiableCode]
namespace WxAxW.PinAssistant
{
	[BepInPlugin("com.WxAxW.PinAssistant", "PinAssistant", "1.7.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.WxAxW.PinAssistant";

		public const string PluginName = "PinAssistant";

		public const string PluginVersion = "1.7.0";

		public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

		public static Plugin m_instance;

		public bool m_isInGame;

		private readonly Harmony harmony = new Harmony("com.WxAxW.PinAssistant");

		private Coroutine m_coroutineAutoPin;

		private AssetBundle m_assetBundle;

		private List<PluginComponent> pluginComponents;

		public static Plugin Instance => m_instance;

		private void Awake()
		{
			if ((Object)(object)m_instance == (Object)null)
			{
				m_instance = this;
			}
			ModConfig.Init(((BaseUnityPlugin)this).Config);
			m_assetBundle = AssetUtils.LoadAssetBundleFromResources("pin_assistant");
			ModConfig.Instance.IsEnabledConfig.SettingChanged += OnTogglePluginConfig;
			SceneManager.sceneLoaded += OnSceneChange;
			SceneManager.sceneLoaded += GUIManagerExtension.InitialTMPLoad;
			GUIManager.OnCustomGUIAvailable += LoadTrackObjectUI;
			MinimapManager.OnVanillaMapAvailable += LoadMinimapFilterUI;
			MinimapManager.OnVanillaMapAvailable += UpdateMinimapMinZoom;
			pluginComponents = new List<PluginComponent>
			{
				TrackingAssistant.Instance,
				MinimapAssistant.Instance
			};
			foreach (PluginComponent pluginComponent in pluginComponents)
			{
				pluginComponent.Start();
			}
			PatchAll();
			WxAxW.PinAssistant.Utils.Debug.Log(TextType.PLUGIN_ENABLED);
			((Behaviour)this).enabled = false;
		}

		private void Update()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = ModConfig.Instance.TrackLookedObjectConfig.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				TrackingAssistant.Instance.LookAt(ModConfig.Instance.LookDistanceConfig.Value, out var id, out var _);
				TrackObjectUI.Instance?.SetupTrackObject(id);
			}
			value = ModConfig.Instance.PinLookedObjectConfig.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				TrackingAssistant.Instance.PinLookedObject(ModConfig.Instance.LookDistanceConfig.Value, ModConfig.Instance.RedundancyDistanceSameConfig.Value, ModConfig.Instance.RedundancyDistanceAnyConfig.Value);
			}
			value = ModConfig.Instance.ReloadTrackedObjectsConfig.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				TrackingAssistant.Instance.DeserializeTrackedObjects(ModConfig.Instance.TrackedObjectsConfig.Value);
			}
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
			ModConfig.Instance.IsEnabledConfig.SettingChanged -= OnTogglePluginConfig;
			SceneManager.sceneLoaded -= OnSceneChange;
			GUIManager.OnCustomGUIAvailable -= LoadTrackObjectUI;
			MinimapManager.OnVanillaMapAvailable -= LoadMinimapFilterUI;
			foreach (PluginComponent pluginComponent in pluginComponents)
			{
				pluginComponent.Destroy();
			}
			WxAxW.PinAssistant.Utils.Debug.Log(TextType.PLUGIN_DISABLED);
		}

		private IEnumerator StartAutoPinCoroutine()
		{
			while (true)
			{
				TrackingAssistant.Instance.PinLookedObject(ModConfig.Instance.LookDistanceConfig.Value, ModConfig.Instance.RedundancyDistanceSameConfig.Value, ModConfig.Instance.RedundancyDistanceAnyConfig.Value);
				yield return (object)new WaitForSeconds(ModConfig.Instance.TickRateConfig.Value);
			}
		}

		private void PatchAll()
		{
			harmony.PatchAll(typeof(MinimapPatches));
			if (ModExists("Pinnacle"))
			{
				WxAxW.PinAssistant.Utils.Debug.Log("Pinnacle exists patching mod for compatibility");
				harmony.PatchAll(typeof(PinnaclePatches));
			}
			if (ModExists("Kits_Bitz.Under_The_Radar"))
			{
				WxAxW.PinAssistant.Utils.Debug.Log("Under_The_Radar exists patching mod for compatibility");
				harmony.PatchAll(typeof(UnderTheRadarPatches));
			}
		}

		private void OnEnable()
		{
			WxAxW.PinAssistant.Utils.Debug.Log(TextType.MOD_ENABLED);
			foreach (PluginComponent pluginComponent in pluginComponents)
			{
				pluginComponent.enabled = true;
			}
			if ((Object)(object)TrackObjectUI.Instance != (Object)null)
			{
				((Behaviour)TrackObjectUI.Instance).enabled = true;
			}
			if ((Object)(object)FilterPinsUI.Instance != (Object)null)
			{
				((Behaviour)FilterPinsUI.Instance).enabled = true;
				FilterPinsUI.Instance.ModEnable();
			}
			ModConfig.Instance.IsAutoPinningEnabledConfig.SettingChanged += OnToggleAutoPinningConfig;
			ModConfig.Instance.MaxZoomMultiplier.SettingChanged += OnMaxZoomMultiplierConfig;
		}

		private void OnDisable()
		{
			WxAxW.PinAssistant.Utils.Debug.Log(TextType.MOD_DISABLED);
			foreach (PluginComponent pluginComponent in pluginComponents)
			{
				pluginComponent.enabled = false;
			}
			if ((Object)(object)TrackObjectUI.Instance != (Object)null)
			{
				((Behaviour)TrackObjectUI.Instance).enabled = false;
			}
			if ((Object)(object)FilterPinsUI.Instance != (Object)null)
			{
				((Behaviour)FilterPinsUI.Instance).enabled = false;
				FilterPinsUI.Instance.ModDisable();
			}
			ModConfig.Instance.IsAutoPinningEnabledConfig.SettingChanged -= OnToggleAutoPinningConfig;
			ModConfig.Instance.MaxZoomMultiplier.SettingChanged -= OnMaxZoomMultiplierConfig;
		}

		private void ModToggle()
		{
			bool enabled = ModConfig.Instance.IsEnabledConfig.Value && (m_isInGame || ModConfig.Instance.IsDebugModeConfig.Value);
			((Behaviour)this).enabled = enabled;
			UpdateMinimapMinZoom();
			ToggleAutoPinning();
		}

		private void OnSceneChange(Scene scene, LoadSceneMode mode)
		{
			//IL_0019: 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)
			WxAxW.PinAssistant.Utils.Debug.Log(TextType.SCENE_CHANGE, ((Scene)(ref scene)).name);
			Scene activeScene = SceneManager.GetActiveScene();
			m_isInGame = ((Scene)(ref activeScene)).name.Equals("main");
			ModToggle();
		}

		private void ToggleAutoPinning()
		{
			if (!((Behaviour)this).enabled || !ModConfig.Instance.IsAutoPinningEnabledConfig.Value)
			{
				if (m_coroutineAutoPin != null)
				{
					((MonoBehaviour)this).StopCoroutine(m_coroutineAutoPin);
					m_coroutineAutoPin = null;
				}
			}
			else if (m_coroutineAutoPin == null)
			{
				m_coroutineAutoPin = ((MonoBehaviour)this).StartCoroutine("StartAutoPinCoroutine");
			}
		}

		private void UpdateMinimapMinZoom()
		{
			if (!((Object)(object)Minimap.instance == (Object)null))
			{
				float num = 0.01f;
				float value = ModConfig.Instance.MaxZoomMultiplier.Value;
				if (((Behaviour)this).enabled && value != 0f)
				{
					num /= value;
				}
				Minimap.instance.m_minZoom = num;
			}
		}

		private void LoadTrackObjectUI()
		{
			if (m_isInGame || ModConfig.Instance.IsDebugModeConfig.Value)
			{
				TrackObjectUI.Init(m_assetBundle);
			}
		}

		private void LoadMinimapFilterUI()
		{
			FilterPinsUI.Init(m_assetBundle, ModConfig.Instance.IsSearchWindowEnabledConfig.Value);
		}

		private void OnTogglePluginConfig(object sender, EventArgs e)
		{
			ModToggle();
		}

		private void OnToggleAutoPinningConfig(object sender, EventArgs e)
		{
			ToggleAutoPinning();
		}

		private void OnMaxZoomMultiplierConfig(object sender, EventArgs e)
		{
			UpdateMinimapMinZoom();
		}

		private bool ModExists(string assemblyName)
		{
			try
			{
				Assembly.Load(assemblyName);
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private void PrintLayerNames()
		{
			if (ModConfig.Instance.IsDebugModeConfig.Value)
			{
				int num = 32;
				for (int i = 0; i < num; i++)
				{
					string text = LayerMask.LayerToName(i);
					WxAxW.PinAssistant.Utils.Debug.Log("Layer " + i + ": " + text);
				}
			}
		}
	}
}
namespace WxAxW.PinAssistant.Configuration
{
	public enum TextType
	{
		NULL,
		[Text("General")]
		CONFIG_CATEGORY_GENERAL,
		[Text("Hotkeys")]
		CONFIG_CATEGORY_HOTKEYS,
		[Text("Technical")]
		CONFIG_CATEGORY_TECHNICAL,
		[Text("Enabled Mod")]
		CONFIG_NAME_TOGGLE_MOD,
		[Text("Auto Pinning")]
		CONFIG_NAME_TOGGLE_AUTOPINNING,
		[Text("Show Search Window on startup")]
		CONFIG_NAME_TOGGLE_STARTFILTERENABLED,
		[Text("Look Tick Rate")]
		CONFIG_NAME_VAL_TICKRATE,
		[Text("Similar Pin Redundancy Distance")]
		CONFIG_NAME_VAL_DISTANCEREDUNDANCY_SAME,
		[Text("Any Pin Redundancy Distance")]
		CONFIG_NAME_VAL_DISTANCEREDUNDANCY_ANY,
		[Text("Look Distance")]
		CONFIG_NAME_VAL_DISTANCELOOK,
		[Text("Max Mini/Map Zoom Multiplier")]
		CONFIG_NAME_VAL_MAXZOOMMULT,
		[Text("Track Looked Object")]
		CONFIG_NAME_KEY_TRACKOBJECT,
		[Text("Pin Object")]
		CONFIG_NAME_KEY_PINOBJECT,
		[Text("Toggle Search Window")]
		CONFIG_NAME_KEY_TOGGLEFILTERWINDOW,
		[Text("Reload Tracked Objects")]
		CONFIG_NAME_KEY_RELOADTRACKED,
		[Text("Debug Mode")]
		CONFIG_NAME_DEBUGMODE,
		[Text("Objects Tracked")]
		CONFIG_NAME_OBJEECTSTRACKED,
		[Text("Enable or disable plugin\nTo auto pin you must enable '{0}' and look at the object")]
		CONFIG_MESSAGE_TOGGLE_MOD,
		[Text("Enable or disable auto pinning when looking at an object (only auto pins objects from '{0}'")]
		CONFIG_MESSAGE_TOGGLE_AUTOPINNING,
		[Text("Shows/Hides the Search Window on startup.\n(added this for the purpose of Pinnacle so they show/hide in tandem.\nto do so, hide Pinnacle's panel, toggle off this entry and re-enable this mod, you only need to do this once.)")]
		CONFIG_MESSAGE_TOGGLE_STARTFILTERENABLED,
		[Text("The tick rate for when to check the object you're looking at to attempt to pin it\nThe value is 'n seconds per tick'")]
		CONFIG_MESSAGE_VAL_TICKRATE,
		[Text("The minimum distance or space required to prevent pinning similar pins close together. (Based on pin's name, 0 to completely stop this check")]
		CONFIG_MESSAGE_VAL_DISTANCEREDUNDANCY_SAME,
		[Text("The minimum distance or space required to prevent pinning any pins close together. (0 to completely stop this check)")]
		CONFIG_MESSAGE_VAL_DISTANCEREDUNDANCY_ANY,
		[Text("The maximum distance you can detect an object")]
		CONFIG_MESSAGE_VAL_DISTANCELOOK,
		[Text("The multiplier to increase the maximum zoom of the mini/map")]
		CONFIG_MESSAGE_VAL_MAXZOOMMULT,
		[Text("Key to open the GUI\nTo register the object you're looking at to the list of objects to automaticaly pin")]
		CONFIG_MESSAGE_KEY_TRACKOBJECT,
		[Text("Key to manually pin the object you're looking at\nUsed for when you disable '{0}'\n(Object must be tracked using '{1}' to pin)")]
		CONFIG_MESSAGE_KEY_PINOBJECT,
		[Text("Key to show or hide the search window when the map is open")]
		CONFIG_MESSAGE_KEY_TOGGLEFILTERWINDOW,
		[Text("Key to force reload the tracked objects, if you manually modified the config entry for {0}")]
		CONFIG_MESSAGE_KEY_RELOADTRACKED,
		[Text("Enables debug mode, useful for understanding what's happening whenever you use this mod")]
		CONFIG_MESSAGE_DEBUGMODE,
		[Text("List of objects tracked currently being tracked to pin when looked or pressed the '{0}' key\nONLY EDIT THIS IF YOU KNOW WHAT YOU'RE DOING, IF NOT JUST USE THE GUI INSTEAD")]
		CONFIG_MESSAGE_OBJECTSTRACKED,
		[Text("{0}:\tLayerMask: {1} | {2}")]
		OBJECT_INFO,
		[Text("Minimap not found, this should not happen unless Debug Mode is enabled while starting up or in main menu")]
		MINIMAP_NOT_FOUND,
		[Text("No pins found, I assume you're loading your world")]
		WORLD_LOADING,
		[Text("{0}: attempting to add: '{1}' at '{2}'!")]
		PIN_ADDING,
		[Text("Pin Added")]
		PIN_ADDED,
		[Text("This is a ping, not adding to database")]
		PING_ADDING,
		[Text("Pin already exists")]
		PIN_ADDING_EXISTS,
		[Text("Won't add. Nearby pin with same name already exists")]
		PIN_ADDING_EXISTS_SIMILAR_NEARBY,
		[Text("Won't add. Nearby pin exists")]
		PIN_ADDING_EXISTS_NEARBY,
		[Text("Removed '{0}' at '{1}'!")]
		PIN_REMOVED,
		[Text("Cleared mod's pin storage")]
		PINS_CLEARED,
		[Text("Pins Populated")]
		PINS_POPULATED,
		[Text("Empty tracked objects, initializing instead")]
		TRACKED_OBJECTS_INITIALIZED,
		[Text("Loaded tracked objects")]
		TRACKED_OBJECTS_LOADED,
		[Text("Saved tracked objects")]
		TRACKED_OBJECTS_SAVED,
		[Text("Invalid Data or Empty!")]
		TRACKED_OBJECTS_EMPTY,
		[Text("Invalid Data!")]
		TRACKED_OBJECTS_INVALID,
		[Text("The object trying to be pinned is not included in the objects to track")]
		OBJECT_NOT_TRACKED,
		[Text("Dropdown tracked objects populated")]
		OBJECTS_DROPDOWN_LOADED,
		[Text("Track")]
		BUTTON_TRACK,
		[Text("Modify")]
		BUTTON_MODIFY,
		[Text("Cancel")]
		BUTTON_CANCEL,
		[Text("Untrack")]
		BUTTON_UNTRACK,
		[Text("Track Object")]
		HEADER_TRACK,
		[Text("Modify Tracked Object")]
		HEADER_MODIFY,
		[Text("Successfully tracked '{0}'!")]
		TRACK_SUCCESS,
		[Text("Object tracked, but '{0}' conflicts with other ID/s")]
		TRACK_WARNING_CONFLICT,
		[Text("Unable to track '{0}', '{0}' already exists!")]
		TRACK_FAIL,
		[Text("Object ID cannot be empty")]
		TRACK_INVALID,
		[Text("Successfully modified '{0}'!")]
		MODIFY_SUCCESS,
		[Text("Object modified, but '{0}' conflicts with {1}!")]
		MODIFY_WARNING_CONFLICT,
		[Text("Unable to modify '{0}'. New ID '{1}' exists!")]
		MODIFY_FAIL_CONFLICT,
		[Text("Successfully untracked '{0}'!")]
		UNTRACK_SUCCESS,
		[Text("'{0}' is not being tracked? This is not supposed to happen!")]
		UNTRACK_FAIL,
		[Text("Plugin Enabled")]
		PLUGIN_ENABLED,
		[Text("Plugin Destroyed")]
		PLUGIN_DISABLED,
		[Text("Mod Enabled")]
		MOD_ENABLED,
		[Text("Mod Disabled")]
		MOD_DISABLED,
		[Text("Scene changed to: {0}")]
		SCENE_CHANGE,
		[Text("FAIL! This is not supposed to happen! contact developer to fix this")]
		NOT_POSSIBLE,
		[Text("Unable to track '{0}', '{0}' is conflicting with '{1}'")]
		TRACK_FAIL_CONFLICT
	}
	public class TextAttribute : Attribute
	{
		public string Value { get; }

		public TextAttribute(string value)
		{
			Value = value;
		}

		public static string Get(object enumType, params object[] parameters)
		{
			TextAttribute customAttribute = enumType.GetType().GetField(enumType.ToString()).GetCustomAttribute<TextAttribute>();
			if (customAttribute == null)
			{
				return enumType.ToString();
			}
			return string.Format(customAttribute.Value, parameters);
		}
	}
	internal class ModConfig
	{
		private ConfigFile Config;

		private static ModConfig m_instance;

		private ConfigEntry<bool> m_isEnabledConfig;

		private ConfigEntry<bool> m_isAutoPinningEnabledConfig;

		private ConfigEntry<bool> m_isSearchWindowEnabledConfig;

		private ConfigEntry<float> m_tickRateConfig;

		private ConfigEntry<float> m_redundancyDistanceSameConfig;

		private ConfigEntry<float> m_redundancyDistanceAnyConfig;

		private ConfigEntry<float> m_lookDistanceConfig;

		private ConfigEntry<float> m_maxZoomMultiplier;

		private ConfigEntry<KeyboardShortcut> m_trackLookedObjectConfig;

		private ConfigEntry<KeyboardShortcut> m_pinLookedObjectConfig;

		private ConfigEntry<KeyboardShortcut> m_toggleFilterWindowConfig;

		private ConfigEntry<KeyboardShortcut> m_reloadTrackedObjectsConfig;

		private ConfigEntry<string> m_trackedObjectsConfig;

		private ConfigEntry<bool> m_isDebugModeConfig;

		public static ModConfig Instance => m_instance;

		public ConfigEntry<bool> IsEnabledConfig
		{
			get
			{
				return m_isEnabledConfig;
			}
			set
			{
				m_isEnabledConfig = value;
			}
		}

		public ConfigEntry<bool> IsAutoPinningEnabledConfig
		{
			get
			{
				return m_isAutoPinningEnabledConfig;
			}
			set
			{
				m_isAutoPinningEnabledConfig = value;
			}
		}

		public ConfigEntry<bool> IsSearchWindowEnabledConfig
		{
			get
			{
				return m_isSearchWindowEnabledConfig;
			}
			set
			{
				m_isSearchWindowEnabledConfig = value;
			}
		}

		public ConfigEntry<float> TickRateConfig
		{
			get
			{
				return m_tickRateConfig;
			}
			set
			{
				m_tickRateConfig = value;
			}
		}

		public ConfigEntry<float> RedundancyDistanceSameConfig
		{
			get
			{
				return m_redundancyDistanceSameConfig;
			}
			set
			{
				m_redundancyDistanceSameConfig = value;
			}
		}

		public ConfigEntry<float> RedundancyDistanceAnyConfig
		{
			get
			{
				return m_redundancyDistanceAnyConfig;
			}
			set
			{
				m_redundancyDistanceAnyConfig = value;
			}
		}

		public ConfigEntry<float> LookDistanceConfig
		{
			get
			{
				return m_lookDistanceConfig;
			}
			set
			{
				m_lookDistanceConfig = value;
			}
		}

		public ConfigEntry<float> MaxZoomMultiplier
		{
			get
			{
				return m_maxZoomMultiplier;
			}
			set
			{
				m_maxZoomMultiplier = value;
			}
		}

		public ConfigEntry<KeyboardShortcut> TrackLookedObjectConfig
		{
			get
			{
				return m_trackLookedObjectConfig;
			}
			set
			{
				m_trackLookedObjectConfig = value;
			}
		}

		public ConfigEntry<KeyboardShortcut> PinLookedObjectConfig
		{
			get
			{
				return m_pinLookedObjectConfig;
			}
			set
			{
				m_pinLookedObjectConfig = value;
			}
		}

		public ConfigEntry<KeyboardShortcut> ToggleFilterWindowConfig
		{
			get
			{
				return m_toggleFilterWindowConfig;
			}
			set
			{
				m_toggleFilterWindowConfig = value;
			}
		}

		public ConfigEntry<KeyboardShortcut> ReloadTrackedObjectsConfig
		{
			get
			{
				return m_reloadTrackedObjectsConfig;
			}
			set
			{
				m_reloadTrackedObjectsConfig = value;
			}
		}

		public ConfigEntry<string> TrackedObjectsConfig
		{
			get
			{
				return m_trackedObjectsConfig;
			}
			set
			{
				m_trackedObjectsConfig = value;
			}
		}

		public ConfigEntry<bool> IsDebugModeConfig
		{
			get
			{
				return m_isDebugModeConfig;
			}
			set
			{
				m_isDebugModeConfig = value;
			}
		}

		internal static void Init(ConfigFile configFile)
		{
			if (m_instance == null)
			{
				m_instance = new ModConfig();
				m_instance.SetupValues(configFile);
			}
		}

		private void SetupValues(ConfigFile configFile)
		{
			//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_006f: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Expected O, but got Unknown
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Expected O, but got Unknown
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Expected O, but got Unknown
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Expected O, but got Unknown
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Expected O, but got Unknown
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Expected O, but got Unknown
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Expected O, but got Unknown
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Expected O, but got Unknown
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Expected O, but got Unknown
			//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Expected O, but got Unknown
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c6: Expected O, but got Unknown
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0639: Expected O, but got Unknown
			//IL_0639: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Expected O, but got Unknown
			Config = configFile;
			m_isEnabledConfig = Config.Bind<bool>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_TOGGLE_MOD), true, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_TOGGLE_MOD, TextAttribute.Get(TextType.CONFIG_NAME_TOGGLE_AUTOPINNING)), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 8
			} }));
			m_isAutoPinningEnabledConfig = Config.Bind<bool>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_TOGGLE_AUTOPINNING), true, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_TOGGLE_AUTOPINNING, TextAttribute.Get(TextType.CONFIG_NAME_KEY_TRACKOBJECT)), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 7
			} }));
			m_isSearchWindowEnabledConfig = Config.Bind<bool>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_TOGGLE_STARTFILTERENABLED), true, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_TOGGLE_STARTFILTERENABLED), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 6
			} }));
			m_tickRateConfig = Config.Bind<float>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_VAL_TICKRATE), 1f, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_VAL_TICKRATE), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 5
			} }));
			m_redundancyDistanceSameConfig = Config.Bind<float>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_VAL_DISTANCEREDUNDANCY_SAME), 20f, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_VAL_DISTANCEREDUNDANCY_SAME), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 4
			} }));
			m_redundancyDistanceAnyConfig = Config.Bind<float>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_VAL_DISTANCEREDUNDANCY_ANY), 10f, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_VAL_DISTANCEREDUNDANCY_ANY), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 3
			} }));
			m_lookDistanceConfig = Config.Bind<float>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_VAL_DISTANCELOOK), 25f, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_VAL_DISTANCELOOK), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }));
			m_maxZoomMultiplier = Config.Bind<float>(TextAttribute.Get(TextType.CONFIG_CATEGORY_GENERAL), TextAttribute.Get(TextType.CONFIG_NAME_VAL_MAXZOOMMULT), 2f, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_VAL_MAXZOOMMULT), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }));
			m_trackLookedObjectConfig = Config.Bind<KeyboardShortcut>(TextAttribute.Get(TextType.CONFIG_CATEGORY_HOTKEYS), TextAttribute.Get(TextType.CONFIG_NAME_KEY_TRACKOBJECT), new KeyboardShortcut((KeyCode)116, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_KEY_TRACKOBJECT), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 4
			} }));
			m_pinLookedObjectConfig = Config.Bind<KeyboardShortcut>(TextAttribute.Get(TextType.CONFIG_CATEGORY_HOTKEYS), TextAttribute.Get(TextType.CONFIG_NAME_KEY_PINOBJECT), new KeyboardShortcut((KeyCode)112, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_KEY_PINOBJECT, TextAttribute.Get(TextType.CONFIG_NAME_TOGGLE_AUTOPINNING), TextAttribute.Get(TextType.CONFIG_NAME_KEY_TRACKOBJECT)), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 3
			} }));
			m_toggleFilterWindowConfig = Config.Bind<KeyboardShortcut>(TextAttribute.Get(TextType.CONFIG_CATEGORY_HOTKEYS), TextAttribute.Get(TextType.CONFIG_NAME_KEY_TOGGLEFILTERWINDOW), new KeyboardShortcut((KeyCode)9, Array.Empty<KeyCode>()), new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_KEY_TOGGLEFILTERWINDOW), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }));
			m_reloadTrackedObjectsConfig = Config.Bind<KeyboardShortcut>(TextAttribute.Get(TextType.CONFIG_CATEGORY_HOTKEYS), TextAttribute.Get(TextType.CONFIG_NAME_KEY_RELOADTRACKED), default(KeyboardShortcut), new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_KEY_RELOADTRACKED, TextAttribute.Get(TextType.CONFIG_NAME_OBJEECTSTRACKED)), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }));
			m_isDebugModeConfig = Config.Bind<bool>(TextAttribute.Get(TextType.CONFIG_CATEGORY_TECHNICAL), TextAttribute.Get(TextType.CONFIG_NAME_DEBUGMODE), false, new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_DEBUGMODE), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 2
			} }));
			m_trackedObjectsConfig = Config.Bind<string>(TextAttribute.Get(TextType.CONFIG_CATEGORY_TECHNICAL), TextAttribute.Get(TextType.CONFIG_NAME_OBJEECTSTRACKED), "", new ConfigDescription(TextAttribute.Get(TextType.CONFIG_MESSAGE_OBJECTSTRACKED, TextAttribute.Get(TextType.CONFIG_NAME_KEY_PINOBJECT)), (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Order = 1
			} }));
		}
	}
}
namespace WxAxW.PinAssistant.Utils
{
	internal static class DictionaryExtensions
	{
		public static bool ChangeKey<TKey, TValue>(this IDictionary<TKey, TValue> dict, TKey oldKey, TKey newKey)
		{
			if (!dict.TryGetValue(oldKey, out var value))
			{
				return false;
			}
			dict.Remove(oldKey);
			dict.Add(newKey, value);
			return true;
		}
	}
	internal static class TMPDropdownExtensions
	{
		public static void AddOptionWithList<T>(this TMP_Dropdown dropDown, string optionName, List<T> list, T value)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			dropDown.options.Add(new OptionData(optionName));
			list.Add(value);
		}
	}
	internal static class GUIManagerExtension
	{
		private static readonly FieldInfo privateFieldInfoGUIInStart = typeof(GUIManager).GetField("GUIInStart", BindingFlags.Instance | BindingFlags.NonPublic);

		private static bool GUIInStart;

		public static readonly List<Sprite> m_mapIcons = new List<Sprite>();

		public static TMP_FontAsset AveriaSerif { get; set; }

		public static TMP_FontAsset TMPNorse { get; set; }

		public static void InitialTMPLoad(this GUIManager @this, Scene scene, LoadSceneMode loadMode)
		{
			if (!(((Scene)(ref scene)).name != "start"))
			{
				TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				AveriaSerif = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset x) => ((Object)x).name == "Valheim-AveriaSerifLibre"));
				TMPNorse = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset x) => ((Object)x).name == "Valheim-Norse"));
				if ((Object)(object)AveriaSerif == (Object)null || (Object)(object)TMPNorse == (Object)null)
				{
					throw new Exception("Fonts not found");
				}
				SceneManager.sceneLoaded -= InitialTMPLoad;
			}
		}

		public static void UpdateGUIInStart(this GUIManager @this)
		{
			GUIInStart = (bool)privateFieldInfoGUIInStart.GetValue(@this);
		}

		public static void ApplyTMPTextStyle(this GUIManager @this, TMP_Text text, TMP_FontAsset font, Color color, int fontSize = 16, bool createOutline = true)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			text.font = font;
			text.fontSize = fontSize;
			((Graphic)text).color = color;
			text.fontStyle = (FontStyles)1;
			if (createOutline)
			{
				((Shadow)ExposedGameObjectExtension.GetOrAddComponent<Outline>(((Component)text).gameObject)).effectColor = Color.black;
			}
		}

		public static void ApplyTMPTextStyle(this GUIManager @this, TMP_Text text, Color color, int fontSize = 16, bool createOutline = true)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			@this.ApplyTMPTextStyle(text, AveriaSerif, color, fontSize, createOutline);
		}

		public static void ApplyTMPTextStyle(this GUIManager @this, TMP_Text text, int fontSize = 16)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			@this.ApplyTMPTextStyle(text, AveriaSerif, Color.white, fontSize);
		}

		public static void ApplyTMPButtonStyle(this GUIManager @this, Button button, int fontSize = 16)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			@this.ApplyButtonStyle(button, fontSize);
			TMP_Text componentInChildren = ((Component)button).GetComponentInChildren<TMP_Text>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				@this.ApplyTMPTextStyle(componentInChildren, @this.ValheimOrange, fontSize);
				componentInChildren.alignment = (TextAlignmentOptions)514;
			}
		}

		[Obsolete("Only here for backward compat")]
		public static void ApplyTMPInputFieldStyle(this GUIManager @this, TMP_InputField field)
		{
			@this.ApplyTMPInputFieldStyle(field, 16);
		}

		public static void ApplyTMPInputFieldStyle(this GUIManager @this, TMP_InputField field, int fontSize = 16)
		{
			@this.ApplyTMPInputFieldStyle(field, AveriaSerif, fontSize);
		}

		public static void ApplyTMPInputFieldStyle(this GUIManager @this, TMP_InputField field, TMP_FontAsset font, int fontSize = 16)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			@this.UpdateGUIInStart();
			Graphic targetGraphic = ((Selectable)field).targetGraphic;
			Image val = (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
			if (val != null)
			{
				((Graphic)val).color = Color.white;
				val.sprite = @this.GetSprite("text_field");
				val.pixelsPerUnitMultiplier = (GUIInStart ? 2f : 1f);
			}
			Graphic placeholder = field.placeholder;
			TMP_Text val2 = (TMP_Text)(object)((placeholder is TMP_Text) ? placeholder : null);
			if (val2 != null)
			{
				val2.font = font;
				val2.fontStyle = (FontStyles)3;
				((Graphic)val2).color = Color.grey;
				val2.fontSize = fontSize;
			}
			if (Object.op_Implicit((Object)(object)field.textComponent))
			{
				@this.ApplyTMPTextStyle(field.textComponent, font, Color.white, fontSize);
			}
		}

		public static void ApplyTMPDropdownStyle(this GUIManager @this, TMP_Dropdown dropdown, int fontSize = 16)
		{
			//IL_00c4: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: 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)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			@this.UpdateGUIInStart();
			((Component)dropdown).gameObject.layer = 5;
			if ((Object)(object)dropdown.template != (Object)null)
			{
				((Component)dropdown.template).gameObject.layer = 5;
			}
			if (Object.op_Implicit((Object)(object)dropdown.captionText))
			{
				@this.ApplyTMPTextStyle(dropdown.captionText, fontSize);
			}
			if (Object.op_Implicit((Object)(object)dropdown.itemText))
			{
				@this.ApplyTMPTextStyle(dropdown.itemText, fontSize);
			}
			Image val = default(Image);
			if (((Component)dropdown).TryGetComponent<Image>(ref val))
			{
				val.sprite = @this.GetSprite("text_field");
				val.pixelsPerUnitMultiplier = (GUIInStart ? 2f : 1f);
			}
			GameObject gameObject = ((Component)((Component)dropdown).transform.Find("Arrow")).gameObject;
			gameObject.transform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, 180f));
			Image val2 = default(Image);
			if (gameObject.TryGetComponent<Image>(ref val2))
			{
				gameObject.SetSize(25f, 25f);
				val2.sprite = @this.GetSprite("map_marker");
				((Graphic)val2).color = Color.white;
				val2.pixelsPerUnitMultiplier = (GUIInStart ? 2f : 1f);
			}
			ScrollRect val3 = default(ScrollRect);
			if (Object.op_Implicit((Object)(object)dropdown.template) && ((Component)dropdown.template).TryGetComponent<ScrollRect>(ref val3))
			{
				@this.ApplyScrollRectStyle(val3);
			}
			Image val4 = default(Image);
			if (Object.op_Implicit((Object)(object)dropdown.template) && ((Component)dropdown.template).TryGetComponent<Image>(ref val4))
			{
				val4.sprite = @this.GetSprite("button_small");
				((Graphic)val4).color = Color.white;
				val4.pixelsPerUnitMultiplier = (GUIInStart ? 2f : 1f);
			}
			GameObject gameObject2 = ((Component)((Transform)dropdown.template).Find("Viewport/Content/Item")).gameObject;
			Toggle val5 = default(Toggle);
			if (Object.op_Implicit((Object)(object)gameObject2) && gameObject2.TryGetComponent<Toggle>(ref val5))
			{
				val5.toggleTransition = (ToggleTransition)0;
				((Selectable)val5).colors = @this.ValheimToggleColorBlock;
				Toggle obj = val5;
				SpriteState spriteState = default(SpriteState);
				((SpriteState)(ref spriteState)).highlightedSprite = @this.GetSprite("button_highlight");
				((Selectable)obj).spriteState = spriteState;
				Graphic targetGraphic = ((Selectable)val5).targetGraphic;
				Image val6 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
				if (val6 != null)
				{
					((Behaviour)val6).enabled = false;
				}
				Graphic graphic = val5.graphic;
				Image val7 = (Image)(object)((graphic is Image) ? graphic : null);
				if (val7 != null)
				{
					val7.sprite = @this.GetSprite("checkbox_marker");
					((Graphic)val7).color = Color.white;
					val7.type = (Type)0;
					((MaskableGraphic)val7).maskable = true;
					val7.pixelsPerUnitMultiplier = (GUIInStart ? 2f : 1f);
					((Shadow)ExposedGameObjectExtension.GetOrAddComponent<Outline>(((Component)val7).gameObject)).effectColor = Color.black;
				}
			}
		}

		public static void ApplyTMPToggleStyle(this GUIManager @this, Toggle toggle, int fontSize = 16)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			@this.ApplyToogleStyle(toggle);
			TMP_Text componentInChildren = ((Component)toggle).GetComponentInChildren<TMP_Text>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				@this.ApplyTMPTextStyle(componentInChildren, @this.ValheimOrange, fontSize);
				componentInChildren.alignment = (TextAlignmentOptions)513;
			}
		}

		internal static GameObject SetSize(this GameObject go, float width, float height)
		{
			RectTransform component = go.GetComponent<RectTransform>();
			component.SetSizeWithCurrentAnchors((Axis)0, width);
			component.SetSizeWithCurrentAnchors((Axis)1, height);
			return go;
		}
	}
	[Serializable]
	public class LooseDictionary<TValue> where TValue : IComparable<TValue>
	{
		public class TraverseDetails
		{
			public string searchKey;

			public string originalKey;

			public TValue value;

			public TrieNode nodeResult;

			public string actualKey;

			public bool conflicting;

			public string blackListedWord;

			public bool deleteMode;

			public bool exactMatchOnly;

			public StringBuilder keyBuilder = new StringBuilder();

			public TValue conflictingNodeValue;

			public bool endOfDeleteTraversal;

			public TraverseDetails(string searchKey, TValue value = default(TValue), string actualKey = "", string blackListedWord = "", bool deleteMode = false, bool exactMatchOnly = false)
			{
				this.searchKey = searchKey;
				originalKey = searchKey;
				this.value = value;
				this.actualKey = actualKey;
				this.blackListedWord = blackListedWord;
				this.deleteMode = deleteMode;
				this.exactMatchOnly = exactMatchOnly;
			}
		}

		public class TrieNode : IComparable<TrieNode>
		{
			private readonly Dictionary<char, TrieNode> m_children = new Dictionary<char, TrieNode>();

			private TValue m_value;

			private bool m_nodeExactMatchOnly;

			private string m_blackListWord = "";

			public TValue Value
			{
				get
				{
					return m_value;
				}
				set
				{
					m_value = value;
				}
			}

			public bool NodeExactMatchOnly
			{
				get
				{
					return m_nodeExactMatchOnly;
				}
				set
				{
					m_nodeExactMatchOnly = value;
				}
			}

			public string BlackListWord
			{
				get
				{
					return m_blackListWord;
				}
				set
				{
					m_blackListWord = value;
				}
			}

			public TrieNode()
			{
			}

			public TrieNode(TValue value, bool nodeExactMatchOnly, string blackListWord)
			{
				SetValues(value, nodeExactMatchOnly, blackListWord);
			}

			public TrieNode Clone()
			{
				return new TrieNode(m_value, m_nodeExactMatchOnly, m_blackListWord);
			}

			public bool AddNode(string key, TrieNode nodeToAdd, bool forceAdd = false)
			{
				char key2 = key[0];
				if (key.Length > 1)
				{
					string key3 = key.Substring(1);
					if (!m_children.TryGetValue(key2, out var value))
					{
						value = new TrieNode();
						m_children.Add(key2, value);
					}
					return value.AddNode(key3, nodeToAdd, forceAdd);
				}
				if (m_children.TryGetValue(key2, out var value2))
				{
					if (!forceAdd)
					{
						return false;
					}
					value2.SetValues(nodeToAdd);
				}
				else
				{
					m_children.Add(key2, nodeToAdd);
				}
				return true;
			}

			public void Remove(char childNodeKey, TraverseDetails td)
			{
				TrieNode trieNode = m_children[childNodeKey];
				trieNode.ResetValues();
				if (trieNode.m_children.Count != 0)
				{
					td.endOfDeleteTraversal = true;
				}
				else
				{
					m_children.Remove(childNodeKey);
				}
			}

			public void Clear()
			{
				m_children.Clear();
				m_value = default(TValue);
				m_nodeExactMatchOnly = false;
				m_blackListWord = "";
			}

			public bool TraverseRecursive(TraverseDetails td, int currentIndex = 0)
			{
				if (currentIndex >= td.searchKey.Length)
				{
					return false;
				}
				char c = td.searchKey[currentIndex];
				td.keyBuilder.Append(c);
				if (!m_children.TryGetValue(c, out var value))
				{
					td.keyBuilder.Clear();
					return false;
				}
				if (IsNodeValid(value, td.originalKey, currentIndex, td.exactMatchOnly))
				{
					td.value = value.m_value;
					td.nodeResult = value;
					td.actualKey = td.keyBuilder.ToString();
					if (td.deleteMode)
					{
						Remove(c, td);
						return true;
					}
					td.conflicting = CheckChildrenValid(td.searchKey, td.exactMatchOnly);
					return true;
				}
				if (!value.TraverseRecursive(td, currentIndex + 1))
				{
					return false;
				}
				if (td.deleteMode && !td.endOfDeleteTraversal)
				{
					Remove(c, td);
				}
				return true;
			}

			private bool IsNodeValid(TrieNode nodeToCheck, string key, int currentIndex, bool exactMatchOnly = false)
			{
				if (nodeToCheck.m_value == null || ((nodeToCheck.m_nodeExactMatchOnly || exactMatchOnly) && currentIndex != key.Length - 1) || (!string.IsNullOrEmpty(nodeToCheck.m_blackListWord) && key.IndexOf(nodeToCheck.m_blackListWord, StringComparison.OrdinalIgnoreCase) != -1))
				{
					return false;
				}
				return true;
			}

			private void FindAllNodeValues(List<TrieNode> allValues)
			{
				foreach (TrieNode value in m_children.Values)
				{
					allValues.Add(value);
					value.FindAllNodeValues(allValues);
				}
			}

			private bool CheckChildrenValid(string key, bool exactMatch)
			{
				if (exactMatch)
				{
					return false;
				}
				List<TrieNode> list = new List<TrieNode>();
				FindAllNodeValues(list);
				for (int i = 0; i < list.Count; i++)
				{
					TrieNode trieNode = list[i];
					if (trieNode.m_value != null && !trieNode.m_nodeExactMatchOnly && (string.IsNullOrEmpty(trieNode.m_blackListWord) || key.IndexOf(trieNode.m_blackListWord, StringComparison.OrdinalIgnoreCase) == -1))
					{
						return true;
					}
				}
				return false;
			}

			public bool TryGetValueRecursiveLite(string key, string originalKey, out TValue result, int currentIndex = 0)
			{
				result = default(TValue);
				if (currentIndex >= key.Length)
				{
					return false;
				}
				char key2 = key[currentIndex];
				if (!m_children.TryGetValue(key2, out var value))
				{
					return false;
				}
				if (IsNodeValid(value, originalKey, currentIndex))
				{
					result = value.m_value;
					return true;
				}
				return value.TryGetValueRecursiveLite(key, originalKey, out result, currentIndex + 1);
			}

			public void SetValues(TrieNode nodeToRetrieve)
			{
				SetValues(nodeToRetrieve.Value, nodeToRetrieve.NodeExactMatchOnly, nodeToRetrieve.BlackListWord);
			}

			public void SetValues(TraverseDetails td)
			{
				SetValues(td.value, td.exactMatchOnly, td.blackListedWord);
			}

			public void SetValues(TValue value, bool exactMatchOnly, string blackListedWord)
			{
				m_value = value;
				m_nodeExactMatchOnly = exactMatchOnly;
				m_blackListWord = blackListedWord;
			}

			private void ResetValues()
			{
				m_value = default(TValue);
				m_nodeExactMatchOnly = false;
				m_blackListWord = string.Empty;
			}

			public bool TraverseLooseRecursive(StringBuilder keyBuilder, TraverseDetails td, int currentIndex = 0, int nodeLength = 1)
			{
				if (currentIndex >= td.searchKey.Length)
				{
					return false;
				}
				bool flag = true;
				char c = td.searchKey[currentIndex];
				keyBuilder.Append(c);
				if (!m_children.TryGetValue(c, out var value))
				{
					if (td.exactMatchOnly)
					{
						return false;
					}
					value = this;
					keyBuilder.Clear();
					flag = false;
					nodeLength--;
				}
				if (IsNodeValidLoose(value, td.searchKey, nodeLength, td.exactMatchOnly))
				{
					td.value = value.m_value;
					td.nodeResult = value;
					td.actualKey = keyBuilder.ToString();
					td.conflicting = CheckChildrenValid(td.searchKey, td.exactMatchOnly);
					if (td.deleteMode)
					{
						Remove(c, td);
					}
					return true;
				}
				bool flag2 = value.TraverseLooseRecursive(keyBuilder, td, currentIndex + 1, nodeLength + 1);
				if (flag && !flag2)
				{
					value = this;
					flag2 = value.TraverseLooseRecursive(keyBuilder, td, currentIndex + 1, nodeLength);
					keyBuilder.Clear();
				}
				if (!flag2)
				{
					return false;
				}
				if (td.deleteMode && !td.endOfDeleteTraversal)
				{
					Remove(c, td);
				}
				return true;
			}

			public bool TryGetValueLooseRecursiveLite(string key, out TValue result, int currentIndex = 0, int nodeLength = 1)
			{
				result = default(TValue);
				if (currentIndex >= key.Length)
				{
					return false;
				}
				bool flag = true;
				char key2 = key[currentIndex];
				if (!m_children.TryGetValue(key2, out var value))
				{
					value = this;
					flag = false;
					nodeLength--;
				}
				if (IsNodeValidLoose(value, key, nodeLength))
				{
					result = value.m_value;
					return true;
				}
				bool flag2 = value.TryGetValueLooseRecursiveLite(key, out result, currentIndex + 1, nodeLength + 1);
				if (flag && !flag2)
				{
					value = this;
					flag2 = value.TryGetValueLooseRecursiveLite(key, out result, currentIndex + 1, nodeLength);
				}
				return flag2;
			}

			private bool IsNodeValidLoose(TrieNode nodeToCheck, string key, int nodeLength, bool exactMatchOnly = false)
			{
				if (nodeToCheck.m_value == null || ((nodeToCheck.m_nodeExactMatchOnly || exactMatchOnly) && nodeLength != key.Length) || (!string.IsNullOrEmpty(nodeToCheck.m_blackListWord) && key.IndexOf(nodeToCheck.m_blackListWord, StringComparison.OrdinalIgnoreCase) != -1))
				{
					return false;
				}
				return true;
			}

			public int CompareTo(TrieNode other)
			{
				return m_value.CompareTo(other.m_value);
			}
		}

		[JsonProperty("Version")]
		private readonly string m_version = "2.0";

		private Dictionary<string, TrieNode> m_altDictionary = new Dictionary<string, TrieNode>();

		private TrieNode root = new TrieNode();

		[JsonProperty("Alternate Dictionary")]
		public Dictionary<string, TrieNode> AltDictionary
		{
			get
			{
				return m_altDictionary;
			}
			set
			{
				m_altDictionary = value;
				InitializeTrieFromDict();
			}
		}

		public void InitializeTrieFromDict()
		{
			root = new TrieNode();
			foreach (KeyValuePair<string, TrieNode> item in m_altDictionary)
			{
				root.AddNode(item.Key, item.Value, forceAdd: true);
			}
		}

		public bool Add(string key, TValue value, out bool conflicting, string blackListWord = "", bool exactMatchOnly = false)
		{
			key = key.ToLower();
			conflicting = false;
			if (m_altDictionary.ContainsKey(key))
			{
				return false;
			}
			TrieNode trieNode = new TrieNode(value, exactMatchOnly, blackListWord);
			TraverseDetails traverseDetails = new TraverseDetails(key, value, "", blackListWord, deleteMode: false, exactMatchOnly);
			if (!traverseDetails.exactMatchOnly)
			{
				conflicting = Traverse(traverseDetails);
			}
			root.AddNode(key, trieNode);
			m_altDictionary.Add(key, trieNode);
			return true;
		}

		public bool Modify(string key, TValue newValue, bool newNodeExact, string newBlackListWord)
		{
			key = key.ToLower();
			if (!m_altDictionary.TryGetValue(key, out var value))
			{
				return false;
			}
			value.SetValues(newValue, newNodeExact, newBlackListWord);
			return true;
		}

		public bool ChangeKey(string key, string newKey, out bool conflicting, out TValue conflictingValue)
		{
			key = key.ToLower();
			newKey = newKey.ToLower();
			conflicting = false;
			conflictingValue = default(TValue);
			if (key.Equals(newKey))
			{
				return true;
			}
			if (m_altDictionary.ContainsKey(newKey) || !m_altDictionary.TryGetValue(key, out var value))
			{
				return false;
			}
			TrieNode trieNode = value.Clone();
			m_altDictionary.Remove(key);
			m_altDictionary.Add(newKey, trieNode);
			RemoveNode(key);
			string searchKey = key;
			bool nodeExactMatchOnly = trieNode.NodeExactMatchOnly;
			TraverseDetails traverseDetails = new TraverseDetails(searchKey, default(TValue), "", "", deleteMode: false, nodeExactMatchOnly);
			Traverse(traverseDetails);
			conflicting = traverseDetails.conflicting;
			conflictingValue = traverseDetails.value;
			root.AddNode(newKey, trieNode);
			return true;
		}

		public bool Remove(string key)
		{
			key = key.ToLower();
			if (!m_altDictionary.Remove(key))
			{
				return false;
			}
			RemoveNode(key);
			return true;
		}

		public void SortTrackedObjects()
		{
			List<KeyValuePair<string, TrieNode>> source = m_altDictionary.OrderBy((KeyValuePair<string, TrieNode> kvp) => kvp.Value).ToList();
			m_altDictionary = source.ToDictionary((KeyValuePair<string, TrieNode> kvp) => kvp.Key, (KeyValuePair<string, TrieNode> kvp) => kvp.Value);
		}

		public void Clear()
		{
			if (m_altDictionary.Count != 0)
			{
				m_altDictionary.Clear();
				root.Clear();
			}
		}

		public bool TryGetValueLoose(string key, out TValue value, bool exactMatch = false)
		{
			key = key.ToLower();
			value = default(TValue);
			if (m_altDictionary.TryGetValue(key, out var value2))
			{
				value = value2.Value;
				return true;
			}
			if (exactMatch)
			{
				return false;
			}
			TraverseDetails traverseDetails = new TraverseDetails(key);
			bool result = Traverse(traverseDetails);
			value = traverseDetails.value;
			return result;
		}

		public bool RemoveNode(string key)
		{
			TraverseDetails traverseDetails = new TraverseDetails(key, default(TValue), "", "", deleteMode: true, exactMatchOnly: true);
			return Traverse(traverseDetails);
		}

		public bool TryGetNodeLoose(string key, out TrieNode nodeResult)
		{
			TraverseDetails traverseDetails = new TraverseDetails(key);
			bool result = Traverse(traverseDetails);
			nodeResult = traverseDetails.nodeResult;
			return result;
		}

		public bool TryGetValueLooseLite(string key, out TValue result)
		{
			result = default(TValue);
			key = key.ToLower();
			if (m_altDictionary.TryGetValue(key, out var value))
			{
				result = value.Value;
				return true;
			}
			for (int i = 0; i < key.Length; i++)
			{
				string key2 = key.Substring(i);
				if (root.TryGetValueRecursiveLite(key2, key, out result))
				{
					return true;
				}
			}
			return false;
		}

		public bool Traverse(TraverseDetails traverseDetails)
		{
			if (traverseDetails.exactMatchOnly)
			{
				return root.TraverseRecursive(traverseDetails);
			}
			string searchKey = traverseDetails.searchKey;
			for (int i = 0; i < traverseDetails.searchKey.Length; i++)
			{
				traverseDetails.searchKey = searchKey.Substring(i);
				if (root.TraverseRecursive(traverseDetails))
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class Debug
	{
		public static void Log(object message)
		{
			if (ModConfig.Instance.IsDebugModeConfig.Value)
			{
				Logger.LogInfo(message);
			}
		}

		public static string Log(TextType messageType, params object[] parameters)
		{
			string text = TextAttribute.Get(messageType, parameters);
			if (ModConfig.Instance.IsDebugModeConfig.Value)
			{
				Logger.LogInfo((object)text);
			}
			return text;
		}

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

		public static string Warning(TextType messageType, params object[] parameters)
		{
			string text = TextAttribute.Get(messageType, parameters);
			Logger.LogWarning((object)text);
			return text;
		}

		public static void Error(object message)
		{
			Logger.LogError(message);
		}
	}
}
namespace WxAxW.PinAssistant.Patches
{
	[HarmonyPatch(typeof(PinEditPanel))]
	internal class PinnaclePatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetTargetPin")]
		private static void PostfixSetTargetPin(ref PinData pin)
		{
			MinimapPatches.SetTargetPin(pin);
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnPinNameValueChange")]
		[HarmonyPatch("OnPinTypeValueChange")]
		private static void PostfixOnPinUpdate()
		{
			MinimapPatches.UpdatePin();
		}
	}
	[HarmonyPatch(typeof(RadarPinComponent))]
	internal class UnderTheRadarPatches
	{
		[HarmonyTranspiler]
		[HarmonyPatch("Update")]
		private static IEnumerable<CodeInstruction> TranspilerIgnoreRadarPin(IEnumerable<CodeInstruction> instructions)
		{
			return MinimapPatches.ExcludePinsInMethod(instructions, isVirtual: true);
		}
	}
	[HarmonyPatch(typeof(Minimap))]
	internal class MinimapPatches
	{
		public static bool isSpecialPin = false;

		public static bool isManualPin = false;

		public static PinData m_edittingPinInitial = new PinData();

		public static PinData m_edittingPin;

		public static event Action<PinData> OnPinAdd;

		public static event Action<PinData> OnPinRemove;

		public static event Action OnPinClear;

		public static event Action<PinData> OnPinSetTarget;

		public static event Action OnPinUpdate;

		private static FieldInfo AccessMinimapField(string field)
		{
			return AccessTools.Field(typeof(Minimap), field);
		}

		[HarmonyPostfix]
		[HarmonyPatch("AddPin")]
		private static void Postfix(ref PinData __result)
		{
			MinimapPatches.OnPinAdd?.Invoke(__result);
			isSpecialPin = false;
			isManualPin = false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("RemovePin", new Type[] { typeof(PinData) })]
		private static void Prefix(ref PinData pin)
		{
			MinimapPatches.OnPinRemove?.Invoke(pin);
		}

		[HarmonyPrefix]
		[HarmonyPatch("ClearPins")]
		private static void PrefixClearPins()
		{
			MinimapPatches.OnPinClear?.Invoke();
		}

		[HarmonyPostfix]
		[HarmonyPatch("UpdatePins")]
		private static void PostFixUpdatePins()
		{
			if (ModConfig.Instance.IsEnabledConfig.Value)
			{
				MinimapAssistant.Instance.FilterPins();
				MinimapAssistant.Instance.ColorPins();
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("UpdateMap")]
		[HarmonyPatch("OnMapDblClick")]
		private static IEnumerable<CodeInstruction> TranspilerIsManualPin(IEnumerable<CodeInstruction> instructions)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			return FindBeforeCall(instructions, isVirtual: false, AccessTools.Method(typeof(Minimap), "ShowPinNameInput", (Type[])null, (Type[])null)).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
				new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.Field(typeof(MinimapPatches), "isManualPin"))
			}).InstructionEnumeration();
		}

		[HarmonyPostfix]
		[HarmonyPatch("ShowPinNameInput")]
		private static void PostFixShowPinNameInput(Minimap __instance, ref bool __runOriginal)
		{
			if (__runOriginal)
			{
				WxAxW.PinAssistant.Utils.Debug.Log("New manual pin added");
				SetTargetPin(__instance.m_namePin);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("HidePinTextInput")]
		private static void PrefixHidePinTextInput(Minimap __instance)
		{
			if (__instance.m_namePin != null)
			{
				WxAxW.PinAssistant.Utils.Debug.Log("New manual pin editted");
				MinimapPatches.OnPinUpdate?.Invoke();
				SetTargetPin(null);
			}
		}

		public static void SetTargetPin(PinData pin)
		{
			MinimapPatches.OnPinSetTarget?.Invoke(pin);
			m_edittingPin = pin;
			CopyValues(m_edittingPin);
		}

		public static void UpdatePin()
		{
			MinimapPatches.OnPinUpdate?.Invoke();
			CopyValues(m_edittingPin);
		}

		private static void CopyValues(PinData pin)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			if (pin != null)
			{
				m_edittingPinInitial.m_name = pin.m_name;
				m_edittingPinInitial.m_type = pin.m_type;
				m_edittingPinInitial.m_pos = pin.m_pos;
			}
		}

		[HarmonyTranspiler]
		[HarmonyPatch("DiscoverLocation")]
		[HarmonyPatch("UpdateProfilePins")]
		[HarmonyPatch("UpdateEventPin")]
		[HarmonyPatch("UpdateLocationPins")]
		[HarmonyPatch("UpdatePlayerPins")]
		[HarmonyPatch("UpdatePingPins")]
		[HarmonyPatch("UpdateShoutPins")]
		private static IEnumerable<CodeInstruction> TranspilerIgnoreNewPin(IEnumerable<CodeInstruction> instructions)
		{
			return ExcludePinsInMethod(instructions);
		}

		public static IEnumerable<CodeInstruction> ExcludePinsInMethod(IEnumerable<CodeInstruction> instructions, bool isVirtual = false)
		{
			return FindBeforeCall(instructions, isVirtual, AccessTools.Method(typeof(Minimap), "AddPin", (Type[])null, (Type[])null)).Repeat((Action<CodeMatcher>)delegate(CodeMatcher matcher)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				matcher.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
				{
					new CodeInstruction(OpCodes.Ldc_I4_1, (object)null),
					new CodeInstruction(OpCodes.Stsfld, (object)AccessTools.Field(typeof(MinimapPatches), "isSpecialPin"))
				}).Advance(1);
			}, (Action<string>)null).InstructionEnumeration();
		}

		private static CodeMatcher FindBeforeCall(IEnumerable<CodeInstruction> instructions, bool isVirtual, MethodInfo method)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)(isVirtual ? OpCodes.Callvirt : OpCodes.Call), (object)method, (string)null)
			});
		}
	}
}
namespace WxAxW.PinAssistant.Core
{
	public abstract class PluginComponent
	{
		private bool m_enabled;

		public bool enabled
		{
			get
			{
				return m_enabled;
			}
			set
			{
				if (m_enabled != value)
				{
					m_enabled = value;
					if (m_enabled)
					{
						OnEnable();
					}
					else
					{
						OnDisable();
					}
				}
			}
		}

		public abstract void Start();

		public abstract void Destroy();

		public abstract void OnEnable();

		public abstract void OnDisable();
	}
	internal class MinimapAssistant : PluginComponent
	{
		private class PinGroup
		{
			private readonly List<PinData> m_pins = new List<PinData>();

			private string pinName = string.Empty;

			private PinType pinType = (PinType)8;

			private Color m_pinColor;

			private Color m_pinColorShared;

			public Color PinColor
			{
				get
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					return m_pinColor;
				}
				set
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_002c: 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_003d: Unknown result type (might be due to invalid IL or missing references)
					m_pinColor = value;
					m_pinColorShared = new Color(value.r * 0.7f, value.g * 0.7f, value.b * 0.7f, value.a * 0.8f);
				}
			}

			public PinGroup(string pinName, PinType pinType, Color pinColor)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				SetValues(pinName, pinType, pinColor);
			}

			public void ApplyColor()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				if (m_pinColor == Color.white)
				{
					return;
				}
				Color pinColorShared = m_pinColorShared;
				pinColorShared.a *= Minimap.instance.m_sharedMapDataFade;
				foreach (PinData pin in m_pins)
				{
					Image iconElement = pin.m_iconElement;
					if (!((Object)(object)iconElement == (Object)null))
					{
						((Graphic)iconElement).color = ((pin.m_ownerID == 0L) ? m_pinColor : pinColorShared);
					}
				}
			}

			public void ResetColor()
			{
				//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)
				m_pinColor = Color.white;
			}

			public void ModifyPins(string newName, PinType newType)
			{
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				if (!pinName.Equals(newName))
				{
					pinName = newName;
					foreach (PinData pin in m_pins)
					{
						SetPinName(pin, pinName);
					}
				}
				if (pinType == newType)
				{
					return;
				}
				pinType = newType;
				Sprite sprite = Minimap.instance.GetSprite(pinType);
				foreach (PinData pin2 in m_pins)
				{
					SetPinType(pin2, pinType, sprite);
				}
			}

			public void Add(PinData pin)
			{
				m_pins.Add(pin);
			}

			public void AddRange(PinGroup pinGroup)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				pinGroup.ModifyPins(pinName, pinType);
				AddFormattedRange(pinGroup);
			}

			public void AddFormattedRange(PinGroup pinGroup)
			{
				m_pins.AddRange(pinGroup.m_pins);
				pinGroup.Clear();
			}

			public bool Remove(PinData pin)
			{
				if (m_pins.Remove(pin))
				{
					WxAxW.PinAssistant.Utils.Debug.Log("Removed pin");
					return true;
				}
				return false;
			}

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

			public void SetValues(string pinName, PinType pinType, Color pinColor)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				this.pinName = pinName;
				this.pinType = pinType;
				PinColor = pinColor;
			}
		}

		private static MinimapAssistant m_instance = new MinimapAssistant();

		private readonly Dictionary<string, PinGroup> m_pins = new Dictionary<string, PinGroup>();

		private IEnumerable<PinData> m_listUnfilteredPinsQuery;

		private List<PinData> m_listUnfilteredPins;

		private Dictionary<PinType, Tuple<Sprite, string>> m_dictionaryPinType = new Dictionary<PinType, Tuple<Sprite, string>>();

		private bool m_dictionaryPinTypePopulated;

		public Action OnDictionaryPinTypePopulated;

		public static MinimapAssistant Instance
		{
			get
			{
				return m_instance;
			}
			private set
			{
				m_instance = value;
			}
		}

		public Dictionary<PinType, Tuple<Sprite, string>> DictionaryPinType
		{
			get
			{
				return m_dictionaryPinType;
			}
			set
			{
				m_dictionaryPinType = value;
			}
		}

		public bool DictionaryPinTypePopulated
		{
			get
			{
				return m_dictionaryPinTypePopulated;
			}
			set
			{
				m_dictionaryPinTypePopulated = value;
			}
		}

		public override void Start()
		{
			MinimapPatches.OnPinAdd += OnPinAdd;
			MinimapPatches.OnPinRemove += OnPinRemove;
			MinimapPatches.OnPinSetTarget += OnPinSetup;
			MinimapPatches.OnPinUpdate += OnPinUpdate;
			MinimapManager.OnVanillaMapAvailable += PopulateIcons;
		}

		public override void Destroy()
		{
			MinimapPatches.OnPinAdd -= OnPinAdd;
			MinimapPatches.OnPinRemove -= OnPinRemove;
			MinimapPatches.OnPinSetTarget -= OnPinSetup;
			MinimapPatches.OnPinUpdate -= OnPinUpdate;
			m_instance = null;
		}

		public override void OnEnable()
		{
			OnTrackedObjectsReload(TrackingAssistant.Instance.TrackedObjects);
			TrackingAssistant.Instance.OnTrackedObjectAdd += OnTrackedObjectAdd;
			TrackingAssistant.Instance.OnTrackedObjectRemove += OnTrackedObjectRemove;
			TrackingAssistant.Instance.OnTrackedObjectUpdate += OnTrackedObjectUpdate;
			TrackingAssistant.Instance.OnTrackedObjectsReload += OnTrackedObjectsReload;
		}

		public override void OnDisable()
		{
			TrackingAssistant.Instance.OnTrackedObjectAdd -= OnTrackedObjectAdd;
			TrackingAssistant.Instance.OnTrackedObjectRemove -= OnTrackedObjectRemove;
			TrackingAssistant.Instance.OnTrackedObjectUpdate -= OnTrackedObjectUpdate;
			TrackingAssistant.Instance.OnTrackedObjectsReload -= OnTrackedObjectsReload;
			ResetFilteredPins();
		}

		private void PopulateIcons()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			Array values = Enum.GetValues(typeof(PinType));
			m_dictionaryPinType.Add((PinType)8, new Tuple<Sprite, string>(null, "None"));
			foreach (PinType item2 in values)
			{
				if ((int)item2 != 8)
				{
					Sprite sprite = Minimap.instance.GetSprite(item2);
					string item = FormatSpriteName(((Object)sprite).name);
					m_dictionaryPinType.Add(item2, new Tuple<Sprite, string>(sprite, item));
				}
			}
			MinimapManager.OnVanillaMapAvailable -= PopulateIcons;
			m_dictionaryPinTypePopulated = true;
			OnDictionaryPinTypePopulated?.Invoke();
		}

		private string FormatSpriteName(string sprName)
		{
			sprName = Regex.Replace(sprName, "mapicon_", string.Empty);
			if (sprName.IndexOf("_32") != -1)
			{
				sprName = Regex.Replace(sprName, "_32", string.Empty);
			}
			if (sprName.IndexOf("_colored") != -1)
			{
				sprName = Regex.Replace(sprName, "_colored", string.Empty);
			}
			sprName = Regex.Replace(sprName, "(^\\w)|(\\s\\w)", (Match m) => m.Value.ToUpper());
			return sprName;
		}

		public void ColorPins()
		{
			foreach (KeyValuePair<string, PinGroup> pin in m_pins)
			{
				pin.Value.ApplyColor();
			}
		}

		public void SearchPins(string pinNameQuery, PinType pinTypeQuery, bool whitelist = false, bool isRegex = false)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			ResetFilteredPins();
			if (isRegex)
			{
				if (!IsRegexValid(pinNameQuery))
				{
					return;
				}
				m_listUnfilteredPinsQuery = TrackingAssistant.Instance.Pins.Values.Where(delegate(PinData pinData)
				{
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					bool num2 = Regex.IsMatch(pinData.m_name, pinNameQuery, RegexOptions.IgnoreCase);
					bool flag3 = PinTypeMatches(pinData.m_type, pinTypeQuery);
					bool flag4 = num2 && flag3;
					return (!whitelist) ? flag4 : (!flag4);
				});
			}
			else
			{
				bool isExact = IsExact(pinNameQuery, out pinNameQuery);
				m_listUnfilteredPinsQuery = TrackingAssistant.Instance.Pins.Values.Where(delegate(PinData pinData)
				{
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_003e: Unknown result type (might be due to invalid IL or missing references)
					bool num = CompareSearch(pinData.m_name, pinNameQuery, isExact);
					bool flag = PinTypeMatches(pinData.m_type, pinTypeQuery);
					bool flag2 = num && flag;
					return (!whitelist) ? flag2 : (!flag2);
				});
			}
			m_listUnfilteredPins = m_listUnfilteredPinsQuery.ToList();
		}

		private bool IsRegexValid(string pinNameQuery)
		{
			try
			{
				Regex.Match("", pinNameQuery);
				return true;
			}
			catch (Exception)
			{
				WxAxW.PinAssistant.Utils.Debug.Warning("Invalid RegEx Pattern!");
				return false;
			}
		}

		private bool IsExact(string pinNameQuery, out string trimmedString)
		{
			trimmedString = pinNameQuery;
			string pattern = "^\".*\"$";
			bool flag = Regex.IsMatch(pinNameQuery, pattern) || string.IsNullOrEmpty(pinNameQuery);
			if (flag)
			{
				trimmedString = pinNameQuery.Trim(new char[1] { '"' });
			}
			return flag;
		}

		private bool PinTypeMatches(PinType pinType, PinType pinTypeQuery)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if ((int)pinTypeQuery == 8)
			{
				return true;
			}
			return pinType == pinTypeQuery;
		}

		private bool CompareSearch(string foundPin, string query, bool isExact = false)
		{
			if (isExact)
			{
				return foundPin.Equals(query, StringComparison.OrdinalIgnoreCase);
			}
			return foundPin.IndexOf(query, StringComparison.OrdinalIgnoreCase) != -1;
		}

		public void ResetFilteredPins()
		{
			if (m_listUnfilteredPinsQuery != null)
			{
				FilterPins(renderPins: true);
				m_listUnfilteredPinsQuery = null;
				m_listUnfilteredPins = null;
			}
		}

		public void FilterPins()
		{
			if (m_listUnfilteredPinsQuery != null)
			{
				FilterPins(renderPins: false);
			}
		}

		public void FilterPins(bool renderPins)
		{
			foreach (PinData listUnfilteredPin in m_listUnfilteredPins)
			{
				PinNameData namePinData = listUnfilteredPin.m_NamePinData;
				if (namePinData != null)
				{
					GameObject pinNameGameObject = namePinData.PinNameGameObject;
					if (pinNameGameObject != null)
					{
						pinNameGameObject.SetActive(renderPins);
					}
				}
				RectTransform uiElement = listUnfilteredPin.m_uiElement;
				if (uiElement != null)
				{
					((Component)uiElement).gameObject.SetActive(renderPins);
				}
			}
		}

		private PinGroup InitializeKey(PinData newPin, Color pinColor)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return InitializeKey(GetPinKey(newPin), newPin.m_name, newPin.m_type, pinColor);
		}

		private PinGroup InitializeKey(string key, string pinName, PinType pinType, Color pinColor, bool forceChangeColor = false)
		{
			//IL_0021: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			if (!m_pins.TryGetValue(key, out var value))
			{
				WxAxW.PinAssistant.Utils.Debug.Log("Created colored pin group for " + key);
				PinGroup pinGroup = new PinGroup(pinName, pinType, pinColor);
				m_pins.Add(key, pinGroup);
				return pinGroup;
			}
			if (forceChangeColor)
			{
				WxAxW.PinAssistant.Utils.Debug.Log("Colored pin group named, '" + key + "' exists, Changing the color only instead.");
				value.PinColor = pinColor;
			}
			return value;
		}

		public void ModifyPin(PinData pinData, string newName, PinType newType)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			ModifyPin(pinData, pinData.m_name, newName, pinData.m_type, newType);
		}

		public void ModifyPin(PinData pinData, string oldName, string newName, PinType oldType, PinType newType)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			WxAxW.PinAssistant.Utils.Debug.Log($"Modifying {oldName} | {oldType} to {newName} | {newType}");
			if (oldName.Equals(newName) && oldType == newType)
			{
				return;
			}
			string pinKey = GetPinKey(oldName, oldType);
			if (!m_pins.TryGetValue(pinKey, out var value))
			{
				WxAxW.PinAssistant.Utils.Debug.Error("Pin group not found, contact dev");
				return;
			}
			if (!value.Remove(pinData))
			{
				WxAxW.PinAssistant.Utils.Debug.Error("Pin not found in group, contact dev");
			}
			if (!oldName.Equals(newName))
			{
				SetPinName(pinData, newName);
			}
			if (!((object)(PinType)(ref oldType)).Equals((object?)newType))
			{
				SetPinType(pinData, newType);
			}
			PinAdd(pinData);
		}

		public void ModifyPins(string oldPinsQuery, string newPinsName, PinType oldType, PinType newType, bool isRegex)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			WxAxW.PinAssistant.Utils.Debug.Log("Renaming all matching pins");
			if (isRegex && !IsRegexValid(oldPinsQuery))
			{
				WxAxW.PinAssistant.Utils.Debug.Error("Invalid Regex pattern!");
				return;
			}
			bool isExact = IsExact(oldPinsQuery, out oldPinsQuery);
			foreach (PinData value in TrackingAssistant.Instance.Pins.Values)
			{
				if ((isRegex ? Regex.IsMatch(value.m_name, oldPinsQuery, RegexOptions.IgnoreCase) : CompareSearch(value.m_name, oldPinsQuery, isExact)) && PinTypeMatches(value.m_type, oldType))
				{
					PinType newType2 = (((int)newType == 8) ? value.m_type : newType);
					ModifyPin(value, newPinsName, newType2);
				}
			}
			UpdateUnfilteredPins();
		}

		private void TransferPinGroup(string oldPinsName, string newPinsName, PinType oldType, PinType newType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if ((int)newType == 8 || (oldPinsName.Equals(newPinsName) && oldType == newType))
			{
				return;
			}
			string pinKey = GetPinKey(newPinsName, newType);
			string pinKey2 = GetPinKey(oldPinsName, oldType);
			if (m_pins.ContainsKey(pinKey2))
			{
				PinGroup pinGroup = InitializeKey(pinKey, newPinsName, newType, Color.white);
				if (!m_pins.TryGetValue(pinKey2, out var value))
				{
					WxAxW.PinAssistant.Utils.Debug.Log("No pins exists with current pin name and type.");
					return;
				}
				value.ModifyPins(newPinsName, newType);
				pinGroup.AddFormattedRange(value);
			}
		}

		private string GetPinKey(PinData pinData)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return GetPinKey(pinData.m_name, pinData.m_type);
		}

		private string GetPinKey(string pinName, PinType pinType)
		{
			return pinName.ToLower() + "_" + ((object)(PinType)(ref pinType)).ToString();
		}

		public void UpdateUnfilteredPins()
		{
			if (m_listUnfilteredPins != null)
			{
				m_listUnfilteredPins = m_listUnfilteredPinsQuery.ToList();
			}
		}

		private void PinAdd(PinData pin)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			InitializeKey(pin, Color.white).Add(pin);
		}

		private void OnPinAdd(PinData pin)
		{
			if (!MinimapPatches.isSpecialPin)
			{
				PinAdd(pin);
				if (!MinimapPatches.isManualPin)
				{
					UpdateUnfilteredPins();
				}
			}
		}

		private void OnPinRemove(PinData pin)
		{
			if (m_pins.TryGetValue(GetPinKey(pin), out var value))
			{
				value.Remove(pin);
			}
		}

		private void OnPinSetup(PinData pin)
		{
			if (MinimapPatches.m_edittingPin != null && pin != MinimapPatches.m_edittingPin)
			{
				UpdateUnfilteredPins();
			}
		}

		private void OnPinUpdate()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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)
			if (MinimapPatches.m_edittingPin != null)
			{
				string name = MinimapPatches.m_edittingPinInitial.m_name;
				string name2 = MinimapPatches.m_edittingPin.m_name;
				PinType type = MinimapPatches.m_edittingPinInitial.m_type;
				PinType type2 = MinimapPatches.m_edittingPin.m_type;
				WxAxW.PinAssistant.Utils.Debug.Log($"Updating pin from, {name} | {type}, to {name2} | {type2}");
				ModifyPin(MinimapPatches.m_edittingPin, name, name2, type, type2);
			}
		}

		private void OnTrackedObjectAdd(TrackedObject trackedObject)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			string name = trackedObject.Name;
			PinType icon = trackedObject.Icon;
			Color pinColor = trackedObject.PinColor;
			WxAxW.PinAssistant.Utils.Debug.Log("Initializing pin name storage for tracked object, " + trackedObject.ObjectID + ".");
			string pinKey = GetPinKey(name, icon);
			InitializeKey(pinKey, name, icon, pinColor, forceChangeColor: true);
		}

		private void OnTrackedObjectRemove(TrackedObject trackedObject)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			string pinKey = GetPinKey(trackedObject.Name, trackedObject.Icon);
			if (!m_pins.TryGetValue(pinKey, out var value))
			{
				WxAxW.PinAssistant.Utils.Debug.Error("Failed to remove group, contact dev!");
				return;
			}
			WxAxW.PinAssistant.Utils.Debug.Log("Removing color for " + trackedObject.ObjectID);
			value.PinColor = Color.white;
		}

		private void OnTrackedObjectUpdate(TrackedObject trackedObject, TrackedObject newTrackedObject, bool modifyPins)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			string name = trackedObject.Name;
			PinType icon = trackedObject.Icon;
			string name2 = newTrackedObject.Name;
			PinType icon2 = newTrackedObject.Icon;
			if (name.Equals(name2) && icon == icon2)
			{
				return;
			}
			string pinKey = GetPinKey(name, icon);
			if (!m_pins.TryGetValue(pinKey, out var value))
			{
				WxAxW.PinAssistant.Utils.Debug.Error("Failed to update group, contact dev!");
				return;
			}
			if (modifyPins)
			{
				TransferPinGroup(name, name2, icon, icon2);
			}
			value.ResetColor();
			OnTrackedObjectAdd(newTrackedObject);
		}

		private void OnTrackedObjectsReload(LooseDictionary<TrackedObject> trackedObjects)
		{
			foreach (KeyValuePair<string, PinGroup> pin in m_pins)
			{
				pin.Value.ResetColor();
			}
			foreach (LooseDictionary<TrackedObject>.TrieNode value in trackedObjects.AltDictionary.Values)
			{
				OnTrackedObjectAdd(value.Value);
			}
			WxAxW.PinAssistant.Utils.Debug.Log("Minimap Pin color reloaded");
		}

		public static void SetPinName(PinData pin, string newName)
		{
			pin.m_name = newName;
			PinNameData namePinData = pin.m_NamePinData;
			if (namePinData != null)
			{
				TMP_Text pinNameText = namePinData.PinNameText;
				if (pinNameText != null)
				{
					pinNameText.SetText(newName);
				}
			}
		}

		public static void SetPinType(PinData pin, PinType newPinType, Sprite pinSprite = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			pin.m_type = newPinType;
			if ((Object)(object)pinSprite == (Object)null)
			{
				pinSprite = Minimap.instance.GetSprite(newPinType);
			}
			pin.m_icon = pinSprite;
			if (!((Object)(object)pin.m_iconElement == (Object)null))
			{
				pin.m_iconElement.sprite = pin.m_icon;
			}
		}
	}
	[Serializable]
	public class TrackedObject : IComparable<TrackedObject>
	{
		public class SerializableColor
		{
			public float r = 1f;

			public float g = 1f;

			public float b = 1f;

			public float a = 1f;

			public SerializableColor()
			{
			}

			public SerializableColor(Color color)
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				SetWithColor(color);
			}

			public SerializableColor(float r, float g, float b, float a)
			{
				this.r = r;
				this.g = g;
				this.b = b;
				this.a = a;
			}

			public void SetWithColor(Color color)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				r = color.r;
				g = color.g;
				b = color.b;
				a = color.a;
			}

			internal void ConvertToColor(ref Color pinColor)
			{
				pinColor.r = r;
				pinColor.g = g;
				pinColor.b = b;
				pinColor.a = a;
			}
		}

		private string m_objectID;

		private string m_name;

		private string m_blackListWords;

		private PinType m_icon;

		private Color m_pinColor = Color.white;

		private bool m_save;

		private bool m_isChecked;

		private bool m_isExactMatchOnly;

		private SerializableColor m_serializeColor = new SerializableColor();

		public string ObjectID
		{
			get
			{
				return m_objectID;
			}
			set
			{
				m_objectID = value;
			}
		}

		public string Name
		{
			get
			{
				return m_name;
			}
			set
			{
				m_name = value;
			}
		}

		public string BlackListWords
		{
			get
			{
				return m_blackListWords;
			}
			set
			{
				m_blackListWords = value;
			}
		}

		public PinType Icon
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return m_icon;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				m_icon = value;
			}
		}

		[JsonIgnore]
		public Color PinColor
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return m_pinColor;
			}
			set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				m_pinColor = value;
			}
		}

		public bool Save
		{
			get
			{
				return m_save;
			}
			set
			{
				m_save = value;
			}
		}

		public bool IsChecked
		{
			get
			{
				return m_isChecked;
			}
			set
			{
				m_isChecked = value;
			}
		}

		public bool IsExactMatchOnly
		{
			get
			{
				return m_isExactMatchOnly;
			}
			set
			{
				m_isExactMatchOnly = value;
			}
		}

		public SerializableColor SerializeColor
		{
			get
			{
				return m_serializeColor;
			}
			set
			{
				m_serializeColor = value;
				m_serializeColor.ConvertToColor(ref m_pinColor);
			}
		}

		public TrackedObject()
		{
		}//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)


		public TrackedObject(string objectID, string name, string blackListWords, PinType icon, Color pinColor, bool save = true, bool isChecked = false, bool isExact = false)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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)
			SetValues(objectID, name, blackListWords, icon, pinColor, save, isChecked, isExact);
		}

		public void SetValues(TrackedObject newValues)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			SetValues(newValues.ObjectID, newValues.Name, newValues.BlackListWords, newValues.Icon, newValues.PinColor, newValues.Save, newValues.IsChecked, newValues.IsExactMatchOnly);
		}

		public void SetValues(string objectID, string name, string blackListWords, PinType icon, Color pinColor, bool save = true, bool isChecked = false, bool isExact = false)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			m_objectID = objectID;
			m_name = name;
			m_blackListWords = blackListWords;
			m_icon = icon;
			if (m_serializeColor == null)
			{
				m_serializeColor = new SerializableColor(pinColor);
			}
			else
			{
				m_serializeColor.SetWithColor(pinColor);
			}
			m_pinColor = pinColor;
			m_save = save;
			m_isChecked = isChecked;
			m_isExactMatchOnly = isExact;
		}

		public int GetPinIntAsDropdown()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected I4, but got Unknown
			int num = (int)Icon;
			if (num >= 8)
			{
				return num - 1;
			}
			return num;
		}

		public override string ToString()
		{
			if (string.IsNullOrEmpty(m_name))
			{
				return "object";
			}
			return m_name;
		}

		public override bool Equals(object obj)
		{
			if (obj is TrackedObject trackedObject)
			{
				return m_objectID == trackedObject.m_objectID;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return 1328540911 + EqualityComparer<string>.Default.GetHashCode(m_objectID);
		}

		public int CompareTo(TrackedObject other)
		{
			return m_name.CompareTo(other.m_name);
		}
	}
	public class TrackingAssistant : PluginComponent
	{
		public delegate string OnModifiedTrackedObjectsHandler();

		private static TrackingAssistant m_instance = new TrackingAssistant();

		private Dictionary<Vector3, PinData> m_pins = new Dictionary<Vector3, PinData>();

		private LooseDictionary<TrackedObject> m_trackedObjects = new LooseDictionary<TrackedObject>();

		public int m_layersToCheck = LayerMask.GetMask(new string[7] { "Default", "Default_small", "item", "piece", "piece_nonsolid", "static_solid", "terrain" });

		public List<Type> m_trackedTypes = new List<Type>();

		public static TrackingAssistant Instance => m_instance;

		public Dictionary<Vector3, PinData> Pins
		{
			get
			{
				return m_pins;
			}
			set
			{
				m_pins = value;
			}
		}

		public LooseDictionary<TrackedObject> TrackedObjects
		{
			get
			{
				return m_trackedObjects;
			}
			set
			{
				m_trackedObjects = value;
			}
		}

		public event OnModifiedTrackedObjectsHandler OnModifiedTrackedObjects;

		public event Action<TrackedObject> OnTrackedObjectAdd;

		public event Action<TrackedObject> OnTrackedObjectRemove;

		public event Action<TrackedObject, TrackedObject, bool> OnTrackedObjectUpdate;

		public event Action<LooseDictionary<TrackedObject>> OnTrackedObjectSaved;

		public event Action<LooseDictionary<TrackedObject>> OnTrackedObjectsReload;

		public override void Start()
		{
		}

		public override void OnEnable()
		{
			DeserializeTrackedObjects(ModConfig.Instance.TrackedObjectsConfig.Value);
			MinimapPatches.OnPinAdd += OnPinAdd;
			MinimapPatches.OnPinRemove += OnPinRemove;
			MinimapPatches.OnPinUpdate += OnPinUpdate;
			MinimapPatches.OnPinClear += OnPinsClear;
			OnModifiedTrackedObjects += SerializeTrackedObjects;
			PopulatePins();
		}

		public override void OnDisable()
		{
			m_trackedTypes.Clear();
			m_trackedObjects.Clear();
			MinimapPatches.OnPinAdd -= OnPinAdd;
			MinimapPatches.OnPinRemove -= OnPinRemove;
			MinimapPatches.OnPinUpdate -= OnPinUpdate;
			MinimapPatches.OnPinClear -= OnPinsClear;
			OnModifiedTrackedObjects -= SerializeTrackedObjects;
			ClearPins();
		}

		public override void Destroy()
		{
			m_instance = null;
		}

		public void PinLookedObject(float lookDistance, float redundancyDistanceSame, float redundancyDistanceAny)
		{
			if (LookAt(lookDistance, out var id, out var obj))
			{
				AddObjAsPin(id, obj, redundancyDistanceSame, redundancyDistanceAny);
			}
		}

		public bool LookAt(float lookDistance, out string id, out GameObject obj)
		{
			//IL_0023: 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)
			id = string.Empty;
			obj = null;
			if ((Object)(object)GameCamera.instance == (Object)null)
			{
				return false;
			}
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, ref val, lookDistance, m_layersToCheck))
			{
				return false;
			}
			if (((Component)((RaycastHit)(ref val)).transform).gameObject.layer == 11)
			{
				return false;
			}
			obj = ((Component)((RaycastHit)(ref val)).transform.root).gameObject;
			id = ModifyLookedObject(obj);
			WxAxW.PinAssistant.Utils.Debug.Log(TextType.OBJECT_INFO, id, LayerMask.LayerToName(obj.layer), obj.layer);
			return true;
		}

		private string ModifyLookedObject(GameObject obj)
		{
			switch (((Object)obj).name)
			{
			case "LocationProxy(Clone)":
				return ((Object)obj.transform.GetChild(0)).name;
			case "___MineRock5 m_meshFilter":
				return "Invalid! Track undamaged instead";
			case "DG_ForestCrypt(Clone)":
			case "DG_SunkenCrypt(Clone)":
			case "TreasureChest_forestcrypt(Clone)":
			case "TreasureChest_sunkencrypt(Clone)":
			case "Pickable_ForestCryptRemains01(Clone)":
			case "Pickable_ForestCryptRemains02(Clone)":
			case "Pickable_ForestCryptRemains03(Clone)":
			case "Pickable_ForestCryptRandom(Clone)":
			case "Pickable_SunkenCryptRandom(Clone)":
			case "dungeon_forestcrypt_door(Clone)":
			case "sunken_crypt_gate(Clone)":
				return "";
			default:
				return ((Object)obj).name;
			}
		}

		public void AddObjAsPin(string id, GameObject obj, float redundancyDistanceSame, float redundancyDistanceAny)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (Minimap.instance == null)
			{
				return;
			}
			if (!m_trackedObjects.TryGetValueLooseLite(id, out var result))
			{
				WxAxW.PinAssistant.Utils.Debug.Log(TextType.OBJECT_NOT_TRACKED);
				return;
			}
			Vector3 position = obj.transform.position;
			if (CheckPinPositionExist(position))
			{
				WxAxW.PinAssistant.Utils.Debug.Log(TextType.PIN_ADDING_EXISTS);
			}
			else if (redundancyDistanceAny != 0f && !CheckValidPinPosition(position, result.Name, redundancyDistanceAny, allPins: true))
			{
				WxAxW.PinAssistant.Utils.Debug.Log(TextType.PIN_ADDING_EXISTS_NEARBY);
			}
			else if (redundancyDistanceSame != 0f && !CheckValidPinPosition(position, result.Name, redundancyDistanceSame, allPins: false))
			{
				WxAxW.PinAssistant.Utils.Debug.Log(TextType.PIN_ADDING_EXISTS_SIMILAR_NEARBY);
			}
			else
			{
				Minimap.instance.AddPin(position, result.Icon, result.Name, result.Save, result.IsChecked, 0L, "");
			}
		}

		private bool CheckPinPositionExist(Vector3 pinPos)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return m_pins.ContainsKey(pinPos);
		}

		public string FormatObjectName(string name)
		{
			name = Regex.Replace(name, "_", " ");
			name = Regex.Replace(name, "(?:\\d|\\(clone\\))|\\b(?:pickable|small)\\b", string.Empty, RegexOptions.IgnoreCase);
			string text = Regex.Replace(name, "rock", string.Empty, RegexOptions.IgnoreCase);
			if (!string.IsNullOrWhiteSpace(text))
			{
				name = text;
			}
			name = Regex.Replace(name, "\\b\\w", (Match m) => m.Value.ToUpper());
			name = Regex.Replace(name, "([a-z])([A-Z])", "$1 $2").Trim();
			return name;
		}

		private bool CheckValidPinPosition(Vector3 pinToAdd, string pinName, float redundancyDistance, bool allPins)
		{
			//IL_0032: 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)
			foreach (PinData value in m_pins.Values)
			{
				if ((allPins || value.m_name.IndexOf(pinName, StringComparison.OrdinalIgnoreCase) != -1) && !CheckValidDistance(pinToAdd, value.m_pos, redundancyDistance))
				{
					return false;
				}
			}
			return true;
		}

		private bool CheckValidDistance(Vector3 v1, Vector3 v2, float redundancyDistance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return Get2DDistance(v1, v2) > redundancyDistance;
		}

		private float Get2DDistance(Vector3 v1, Vector3 v2)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			return Mathf.Sqrt(Mathf.Pow(v2.x - v1.x, 2f) + Mathf.Pow(v2.z - v1.z, 2f));
		}

		private void PopulatePins()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Minimap.instance == (Object)n