Decompiled source of QuickPing v1.0.4

plugins/QuickPing.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Managers;
using Jotunn.Utils;
using QuickPing.Patches;
using QuickPing.Utilities;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("QuickPing")]
[assembly: AssemblyDescription("Ping what you see !")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Atopy")]
[assembly: AssemblyProduct("QuickPing")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("31e0f113-b41a-497c-89f8-8db164e0b3eb")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyFileVersion("1.5.12.0")]
[assembly: AssemblyInformationalVersion("1.5.12+4.Branch.master.Sha.1e083f6a3acc3b112194f8beee00ac48cc4657ae")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.12.0")]
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
	public static string Major = "1";

	public static string Minor = "5";

	public static string Patch = "12";

	public static string PreReleaseTag = "";

	public static string PreReleaseTagWithDash = "";

	public static string PreReleaseLabel = "";

	public static string PreReleaseLabelWithDash = "";

	public static string PreReleaseNumber = "";

	public static string WeightedPreReleaseNumber = "60000";

	public static string BuildMetaData = "4";

	public static string BuildMetaDataPadded = "0004";

	public static string FullBuildMetaData = "4.Branch.master.Sha.1e083f6a3acc3b112194f8beee00ac48cc4657ae";

	public static string MajorMinorPatch = "1.5.12";

	public static string SemVer = "1.5.12";

	public static string LegacySemVer = "1.5.12";

	public static string LegacySemVerPadded = "1.5.12";

	public static string AssemblySemVer = "1.5.12.0";

	public static string AssemblySemFileVer = "1.5.12.0";

	public static string FullSemVer = "1.5.12+4";

	public static string InformationalVersion = "1.5.12+4.Branch.master.Sha.1e083f6a3acc3b112194f8beee00ac48cc4657ae";

	public static string BranchName = "master";

	public static string EscapedBranchName = "master";

	public static string Sha = "1e083f6a3acc3b112194f8beee00ac48cc4657ae";

	public static string ShortSha = "1e083f6";

	public static string NuGetVersionV2 = "1.5.12";

	public static string NuGetVersion = "1.5.12";

	public static string NuGetPreReleaseTagV2 = "";

	public static string NuGetPreReleaseTag = "";

	public static string VersionSourceSha = "857c4f5ad42c173f7e156e33323222f6a99868b8";

	public static string CommitsSinceVersionSource = "4";

	public static string CommitsSinceVersionSourcePadded = "0004";

	public static string UncommittedChanges = "2";

	public static string CommitDate = "2026-09-25";
}
namespace QuickPing
{
	public enum HoverType
	{
		GameObject,
		Character,
		Hoverable,
		Piece,
		Location
	}
	public class HoverObject
	{
		public GameObject Hover;

		public IDestructible Destructible;

		public Vector3 pos;

		public Vector3 center;

		public HoverType type;

		public bool pinable;

		public string Name { get; set; }
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.atopy.plugins.quickping", "QuickPing", "1.0.4")]
	public class QuickPingPlugin : BaseUnityPlugin
	{
		public static QuickPingPlugin Instance { get; set; }

		public static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Settings.Init();
			Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing);
			Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Minimap_Patch.AddPin);
			Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing);
			Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Minimap_Patch.ForceAddPin);
			Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Player_Patch.SendRename);
			Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Minimap_Patch.RenamePin);
			SafePatch(typeof(Player_Patch));
			SafePatch(typeof(Minimap_Patch));
			SafePatch(typeof(Terminal_Patch));
			SafePatch(typeof(MineRock5_Patch));
			SafePatch(typeof(Destructible_Patch));
			SafePatch(typeof(WearNTear_Patch));
			SafePatch(typeof(Game_Patch));
			SafePatch(typeof(Character_Patch));
			SafePatch(typeof(ChatPing_Patch));
		}

		private static void SafePatch(Type t)
		{
			try
			{
				Harmony.CreateAndPatchAll(t, "com.atopy.plugins.quickping");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("QuickPing: failed to patch " + t.Name + ": " + ex.Message));
			}
		}
	}
	internal static class Settings
	{
		public const string DefaultPingText = "PING !";

		public static ConfigEntry<bool> PingWhereLooking { get; private set; }

		public static ConfigEntry<bool> AddPin { get; private set; }

		public static ConfigEntry<KeyCode> PingKey { get; private set; }

		public static ConfigEntry<KeyCode> PinEverythingKey { get; internal set; }

		public static ConfigEntry<KeyboardShortcut> RenameKey { get; internal set; }

		public static ConfigEntry<PinType> DefaultPinType { get; internal set; }

		public static ConfigEntry<string> DefaultPinName { get; internal set; }

		public static ConfigEntry<Color> PlayerColor { get; private set; }

		public static ConfigEntry<Color> ShoutColor { get; private set; }

		public static ConfigEntry<Color> WhisperColor { get; private set; }

		public static ConfigEntry<Color> PingColor { get; private set; }

		public static ConfigEntry<Color> DefaultColor { get; private set; }

		public static ConfigEntry<float> ClosestPinRange { get; private set; }

		public static ConfigEntry<float> PinExclusionRange { get; private set; }

		public static ConfigEntry<float> LocationProximityRange { get; private set; }

		public static ButtonConfig PingBtn { get; private set; }

		public static ButtonConfig PingEverythingBtn { get; private set; }

		public static ButtonConfig RenameBtn { get; private set; }

		public static void Init()
		{
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			PingWhereLooking = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "PingWhereLooking", true, "Create a ping where you are looking when you press <PingKey>");
			AddPin = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "AddPinOnMap", true, "If true, add a pin when useful resources (copper, berries, campfire, portals etc.) are pinged.");
			ClosestPinRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "ClosestPinRange", 2f, "Minimum distance between objects to pin/replace portal tag");
			LocationProximityRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "LocationProximityRange", 10f, "Maximum distance (meters) from a hit point to a Location anchor to consider the hit 'part of' that location (for camps, villages, etc).");
			PinExclusionRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "PinExclusionRange", 10f, "Minimum distance between any two pins (auto or forced). Pings inside this radius of an existing pin are ignored.");
			DefaultPinType = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<PinType>("General", "DefaultPinType", (PinType)11, "Default pin when forcing adding a pin on map");
			DefaultPinName = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<string>("General", "DefaultPinName", "", "Name used for force-pinned objects that have no natural name. Set via the Pin Editor 'Use as default' toggle.");
			PlayerColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "PlayerColor", Color.green, "Color for Player name in pings/messages.");
			ShoutColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "ShoutColor", Color.yellow, "Color for Shout ping.");
			WhisperColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "WhisperColor", new Color(1f, 1f, 1f, 0.75f), "Color for Whisper ping.");
			PingColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "PingColor", new Color(0.6f, 0.7f, 1f, 1f), "Color for \"Ping\" ping.");
			DefaultColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "DefaultColor", Color.white, "Default color");
			PingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingInputKey", (KeyCode)122, "The keybind to trigger a ping where you are looking");
			PinEverythingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingEverythingInputKey", (KeyCode)121, "Add a pin on minimap to whatever you're looking at.");
			RenameKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyboardShortcut>("Bindings", "RenameInputKey", new KeyboardShortcut(PinEverythingKey.Value, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("The keybind to rename a ping", (AcceptableValueBase)null, Array.Empty<object>()));
			AddInputs();
		}

		public static void AddInputs()
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_005f: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			PingBtn = new ButtonConfig
			{
				Name = "Ping",
				Config = PingKey,
				Hint = "Ping where you are looking, and pin useful resources"
			};
			PingEverythingBtn = new ButtonConfig
			{
				Name = "PinEverything",
				Config = PinEverythingKey,
				Hint = "Pin on map everything you're looking at"
			};
			RenameBtn = new ButtonConfig
			{
				Name = "Rename",
				ShortcutConfig = RenameKey
			};
			InputManager.Instance.AddButton("com.atopy.plugins.quickping", RenameBtn);
			InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingBtn);
			InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingEverythingBtn);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.atopy.plugins.quickping";

		public const string PLUGIN_NAME = "QuickPing";

		public const string PLUGIN_VERSION = "1.0.4";
	}
}
namespace QuickPing.Utilities
{
	internal static class DataManager
	{
		public static Dictionary<ZDOID, PinData> PinnedObjects = new Dictionary<ZDOID, PinData>();

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

		public static bool Save(World world, PlayerProfile playerProfile)
		{
			SavePinnedObjects(world, playerProfile);
			SaveCustomNames(world, playerProfile);
			return true;
		}

		public static void Load(World world, PlayerProfile playerProfile)
		{
			LoadPinnedObjects(world, playerProfile);
			LoadCustomNames(world, playerProfile);
		}

		private static string GetSafePath(World world, PlayerProfile playerProfile, string extension)
		{
			string text = Path.Combine(Paths.ConfigPath, "QuickPing");
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			return Path.Combine(text, world.m_name + "_" + playerProfile.m_playerName + "." + extension + ".dat");
		}

		private static bool SavePinnedObjects(World world, PlayerProfile playerProfile)
		{
			try
			{
				ZPackage val = PackPinnedObjects();
				string safePath = GetSafePath(world, playerProfile, "pinned");
				File.WriteAllBytes(safePath, val.GetArray());
				return true;
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("Failed to save pinned objects: " + ex.Message));
				return false;
			}
		}

		private static void LoadPinnedObjects(World world, PlayerProfile playerProfile)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			PinnedObjects.Clear();
			string safePath = GetSafePath(world, playerProfile, "pinned");
			if (!File.Exists(safePath))
			{
				return;
			}
			try
			{
				byte[] array = File.ReadAllBytes(safePath);
				ZPackage z = new ZPackage(array);
				UnpackPinnedObjects(z);
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("Failed to load pinned objects: " + ex.Message));
			}
		}

		private static bool SaveCustomNames(World world, PlayerProfile playerProfile)
		{
			try
			{
				ZPackage val = PackCustomNames();
				string safePath = GetSafePath(world, playerProfile, "customNames");
				File.WriteAllBytes(safePath, val.GetArray());
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static void LoadCustomNames(World world, PlayerProfile playerProfile)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			CustomNames.Clear();
			string safePath = GetSafePath(world, playerProfile, "customNames");
			if (!File.Exists(safePath))
			{
				return;
			}
			try
			{
				byte[] array = File.ReadAllBytes(safePath);
				ZPackage z = new ZPackage(array);
				UnpackCustomNames(z);
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("Failed to load custom names: " + ex.Message));
			}
		}

		private static ZPackage PackPinnedObjects()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			ZPackage val = new ZPackage();
			foreach (KeyValuePair<ZDOID, PinData> pinnedObject in PinnedObjects)
			{
				val.Write(pinnedObject.Key);
				val.Write(pinnedObject.Value);
			}
			return val;
		}

		private static ZPackage PackCustomNames()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			foreach (KeyValuePair<string, string> customName in CustomNames)
			{
				val.Write(customName.Key);
				val.Write(customName.Value);
			}
			return val;
		}

		private static void UnpackCustomNames(ZPackage z)
		{
			CustomNames.Clear();
			while (z.GetPos() < z.Size())
			{
				CustomNames.Add(z.ReadString(), z.ReadString());
			}
		}

		private static void UnpackPinnedObjects(ZPackage z)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ZDOID, PinData> dictionary = new Dictionary<ZDOID, PinData>();
			while (z.GetPos() < z.Size())
			{
				dictionary.Add(z.ReadZDOID(), z.ReadPinData());
			}
			PinnedObjects = dictionary;
		}

		private static void Write(this ZPackage z, PinData p)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			z.Write(p.m_name);
			z.Write(((object)Unsafe.As<PinType, PinType>(ref p.m_type)/*cast due to .constrained prefix*/).ToString());
			z.Write(p.m_pos);
		}

		private static PinData ReadPinData(this ZPackage z)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0029: 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_0035: 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)
			PinData val = new PinData();
			val.m_name = z.ReadString();
			val.m_type = (PinType)Enum.Parse(typeof(PinType), z.ReadString());
			val.m_pos = z.ReadVector3();
			return val;
		}
	}
	internal static class GO_Ext
	{
		public static IDestructible GetRecursiveComponentInParents<IDestructible>(Transform root)
		{
			if ((Object)(object)root.parent == (Object)null)
			{
				return default(IDestructible);
			}
			IDestructible componentInParent = ((Component)root).GetComponentInParent<IDestructible>();
			if (componentInParent != null)
			{
				return componentInParent;
			}
			return GetRecursiveComponentInParents<IDestructible>(root.parent);
		}

		public static GameObject GetRecursiveParentWithComponent<T>(Transform root)
		{
			if (!Object.op_Implicit((Object)(object)root.parent))
			{
				return null;
			}
			T val = default(T);
			if (((Component)root.parent).gameObject.TryGetComponent<T>(ref val))
			{
				return ((Component)root.parent).gameObject;
			}
			return GetRecursiveParentWithComponent<T>(root.parent);
		}
	}
	internal static class DataUtils
	{
		public static byte[] ReadAllBytes(this BinaryReader reader)
		{
			using MemoryStream memoryStream = new MemoryStream();
			byte[] array = new byte[4096];
			int count;
			while ((count = reader.Read(array, 0, array.Length)) != 0)
			{
				memoryStream.Write(array, 0, count);
			}
			return memoryStream.ToArray();
		}

		public static bool Compare(this PinData x, PinData y)
		{
			//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)
			return x.m_pos == y.m_pos && x.m_name == y.m_name;
		}
	}
}
namespace QuickPing.Patches
{
	public class ChatPing_Patch
	{
		public class PingHost : MonoBehaviour
		{
		}

		private const float ScalePerMeter = 0.22f;

		private const float MinScale = 0.6f;

		private const float MaxScale = 120f;

		private const float Lifetime = 5f;

		private const float BeamLifetime = 2.5f;

		private const float BeamHeight = 150f;

		private const float BeamWidth = 0.3f;

		private static MonoBehaviour _host;

		private static Vector3 _lastTextPos;

		private static string _lastText = "";

		private static float _lastTextTime = -1f;

		private const string RPC_NAME = "QuickPingNet";

		private static bool _rpcRegistered;

		private static Vector3 _lastLocalPinPos;

		private static float _lastLocalPinTime = -1f;

		private static TMP_FontAsset _cachedFont;

		private static bool _fontSearched;

		private static MonoBehaviour Host
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				if ((Object)(object)_host == (Object)null)
				{
					GameObject val = new GameObject("QuickPingHost");
					((Object)val).hideFlags = (HideFlags)61;
					Object.DontDestroyOnLoad((Object)(object)val);
					_host = (MonoBehaviour)(object)val.AddComponent<PingHost>();
				}
				return _host;
			}
		}

		public static void ShowWorldText(Vector3 position, string text)
		{
			//IL_0020: 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_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)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.time - _lastTextTime < 0.3f) || !(_lastText == text) || !(Vector3.Distance(_lastTextPos, position) < 1f))
			{
				_lastTextPos = position;
				_lastText = text;
				_lastTextTime = Time.time;
				string text2 = CleanDisplayName(text);
				Host.StartCoroutine(TextRoutine(position, text2));
				Host.StartCoroutine(BeamRoutine(position));
			}
		}

		[HarmonyPatch(typeof(Minimap), "Awake")]
		[HarmonyPostfix]
		public static void MinimapAwakeRegisterRpc()
		{
			RegisterRpc();
		}

		public static void RegisterRpc()
		{
			if (!_rpcRegistered && ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.Register<ZPackage>("QuickPingNet", (Action<long, ZPackage>)RpcReceived);
				_rpcRegistered = true;
			}
		}

		public static void BroadcastPing(Vector3 textPos, Vector3 pinPos, string displayText, string pinId)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_002b: 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)
			RegisterRpc();
			if (ZRoutedRpc.instance != null)
			{
				_lastLocalPinPos = pinPos;
				_lastLocalPinTime = Time.time;
				ZPackage val = new ZPackage();
				val.Write(textPos);
				val.Write(pinPos);
				val.Write(displayText);
				val.Write(pinId);
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "QuickPingNet", new object[1] { val });
			}
		}

		public static void RpcReceived(long sender, ZPackage pkg)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			Vector3 position = pkg.ReadVector3();
			Vector3 val = pkg.ReadVector3();
			string text = pkg.ReadString();
			string strID = pkg.ReadString();
			if (!(Time.time - _lastLocalPinTime < 0.5f) || !(Vector3.Distance(_lastLocalPinPos, val) < 1f))
			{
				ShowWorldText(position, text);
				Minimap_Patch.AddPin(null, null, strID, val);
			}
		}

		private static string CleanDisplayName(string rawName)
		{
			if (string.IsNullOrEmpty(rawName))
			{
				return rawName;
			}
			string text = rawName.Trim();
			if (text.StartsWith("$"))
			{
				text = text.Substring(1);
			}
			text = text.Replace("(Clone)", "");
			string[] array = new string[7] { "object_", "item_", "piece_", "Rock_", "Tree_", "Pickable_", "destructible_" };
			string[] array2 = array;
			foreach (string text2 in array2)
			{
				if (text.StartsWith(text2, StringComparison.OrdinalIgnoreCase))
				{
					text = text.Substring(text2.Length);
					break;
				}
			}
			text = text.Replace("_", " ");
			text = Regex.Replace(text, "([a-zA-Z])([0-9])", "$1 $2");
			text = Regex.Replace(text, "[^a-zA-Z0-9\\s]", "");
			text = Regex.Replace(text, "\\s+", " ").Trim();
			if (text.Length > 0)
			{
				text = text.ToLower();
				text = CultureInfo.InvariantCulture.TextInfo.ToTitleCase(text);
			}
			if (string.IsNullOrEmpty(text))
			{
				return rawName;
			}
			return text;
		}

		private static Camera GetCamera()
		{
			if ((Object)(object)GameCamera.instance != (Object)null)
			{
				return ((Component)GameCamera.instance).GetComponent<Camera>();
			}
			return Camera.main;
		}

		private static TMP_FontAsset FindFontAsset()
		{
			if (_fontSearched)
			{
				return _cachedFont;
			}
			_fontSearched = true;
			try
			{
				if ((Object)(object)Chat.instance != (Object)null && (Object)(object)Chat.instance.m_worldTextBase != (Object)null)
				{
					Component[] componentsInChildren = Chat.instance.m_worldTextBase.GetComponentsInChildren<Component>(true);
					string text = "";
					Component[] array = componentsInChildren;
					foreach (Component val in array)
					{
						text = text + (((Object)(object)val != (Object)null) ? ((object)val).GetType().Name : "null") + ",";
					}
					QuickPingPlugin.Log.LogInfo((object)("[QP] font: m_worldTextBase components: " + text));
					TMP_Text componentInChildren = Chat.instance.m_worldTextBase.GetComponentInChildren<TMP_Text>(true);
					if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.font != (Object)null)
					{
						_cachedFont = componentInChildren.font;
						QuickPingPlugin.Log.LogInfo((object)("[QP] font: using game world-text font (" + ((Object)_cachedFont).name + ")"));
						return _cachedFont;
					}
				}
				TMP_Text[] array2 = Resources.FindObjectsOfTypeAll<TMP_Text>();
				if (array2 != null)
				{
					TMP_Text[] array3 = array2;
					foreach (TMP_Text val2 in array3)
					{
						if ((Object)(object)val2 != (Object)null && (Object)(object)val2.font != (Object)null)
						{
							_cachedFont = val2.font;
							QuickPingPlugin.Log.LogInfo((object)("[QP] font: using loaded TMP_Text font (" + ((Object)_cachedFont).name + ")"));
							return _cachedFont;
						}
					}
				}
				TMP_FontAsset[] array4 = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
				if (array4 != null && array4.Length != 0 && (Object)(object)array4[0] != (Object)null)
				{
					_cachedFont = array4[0];
					QuickPingPlugin.Log.LogInfo((object)("[QP] font: using first loaded font asset (" + ((Object)_cachedFont).name + ")"));
					return _cachedFont;
				}
				QuickPingPlugin.Log.LogWarning((object)"[QP] font: NO TMP font found in game - floating text disabled, beam still works");
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogWarning((object)("[QP] font: lookup failed: " + ex.Message));
			}
			return null;
		}

		private static IEnumerator TextRoutine(Vector3 position, string text)
		{
			//IL_0007: 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)
			TMP_FontAsset font = FindFontAsset();
			if ((Object)(object)font == (Object)null)
			{
				yield break;
			}
			GameObject go = new GameObject("QuickPingWorldText");
			go.SetActive(false);
			go.transform.position = position + Vector3.up * 2f;
			TextMeshPro tmp = go.AddComponent<TextMeshPro>();
			((TMP_Text)tmp).font = font;
			((TMP_Text)tmp).text = text;
			((TMP_Text)tmp).fontSize = 2f;
			((TMP_Text)tmp).alignment = (TextAlignmentOptions)514;
			((Graphic)tmp).color = new Color(1f, 0.9f, 0f, 1f);
			if ((Object)(object)((TMP_Text)tmp).fontSharedMaterial != (Object)null)
			{
				Material mat = new Material(((TMP_Text)tmp).fontSharedMaterial);
				mat.EnableKeyword("OUTLINE_ON");
				mat.SetColor(Shader.PropertyToID("_OutlineColor"), Color.black);
				mat.SetFloat(Shader.PropertyToID("_OutlineWidth"), 0.05f);
				((TMP_Text)tmp).fontSharedMaterial = mat;
			}
			go.SetActive(true);
			float textLife = 5f;
			while (textLife > 0f && (Object)(object)go != (Object)null)
			{
				Camera cam = GetCamera();
				if ((Object)(object)cam != (Object)null)
				{
					Vector3 camPos = ((Component)cam).transform.position;
					go.transform.rotation = Quaternion.LookRotation(go.transform.position - camPos);
					float dist = Vector3.Distance(go.transform.position, camPos);
					float scale = Mathf.Clamp(dist * 0.22f, 0.6f, 120f);
					go.transform.localScale = Vector3.one * scale;
				}
				textLife -= Time.deltaTime;
				yield return null;
			}
			if ((Object)(object)go != (Object)null)
			{
				Object.Destroy((Object)(object)go);
			}
		}

		private static IEnumerator BeamRoutine(Vector3 position)
		{
			//IL_0007: 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)
			Shader beamShader = Shader.Find("Sprites/Default");
			if ((Object)(object)beamShader == (Object)null)
			{
				beamShader = Shader.Find("Unlit/Color");
			}
			if ((Object)(object)beamShader == (Object)null)
			{
				beamShader = Shader.Find("UI/Default");
			}
			if ((Object)(object)beamShader == (Object)null)
			{
				beamShader = Shader.Find("Particles/Standard Unlit");
			}
			if ((Object)(object)beamShader == (Object)null)
			{
				yield break;
			}
			GameObject beamGo = new GameObject("QuickPingBeam");
			beamGo.transform.position = position;
			LineRenderer lr = beamGo.AddComponent<LineRenderer>();
			lr.useWorldSpace = true;
			lr.positionCount = 2;
			lr.SetPosition(0, position);
			lr.SetPosition(1, position + Vector3.up * 150f);
			lr.startWidth = 0.3f;
			lr.endWidth = 0.3f;
			((Renderer)lr).material = new Material(beamShader);
			((Renderer)lr).material.color = new Color(1f, 1f, 1f, 1f);
			lr.startColor = new Color(1f, 1f, 1f, 0.9f);
			lr.endColor = new Color(1f, 1f, 1f, 0.1f);
			float beamLife = 2.5f;
			while (beamLife > 0f && (Object)(object)beamGo != (Object)null)
			{
				beamLife -= Time.deltaTime;
				float alpha = Mathf.Clamp01(beamLife / 2.5f);
				if ((Object)(object)lr != (Object)null && (Object)(object)((Renderer)lr).material != (Object)null)
				{
					((Renderer)lr).material.color = new Color(1f, 1f, 1f, alpha);
				}
				yield return null;
			}
			if ((Object)(object)beamGo != (Object)null)
			{
				Object.Destroy((Object)(object)beamGo);
			}
		}
	}
	public static class Localization_Patch
	{
		public static string Localize(Location location)
		{
			return FriendlyLocationName(((Object)location).name.Replace("(Clone)", "").Trim());
		}

		public static string LocalizeName(string locationName)
		{
			return FriendlyLocationName(locationName.Replace("(Clone)", "").Trim());
		}

		private static string FriendlyLocationName(string n)
		{
			if (n.StartsWith("SunkenCrypt"))
			{
				return "Sunken Crypt";
			}
			if (n.StartsWith("Crypt"))
			{
				return "Burial Chambers";
			}
			if (n.StartsWith("TrollCave") || n.StartsWith("ForestCave"))
			{
				return "Troll Cave";
			}
			if (n.StartsWith("MountainCave"))
			{
				return "Frost Cave";
			}
			if (n.StartsWith("Mistlands_DvergrBossEntrance"))
			{
				return "Infested Mine";
			}
			if (n.StartsWith("Mistlands_DvergrTownEntrance"))
			{
				return "Dvergr Town";
			}
			if (n.StartsWith("MorkBorg") || n.StartsWith("Morkhalla"))
			{
				return "Morkhalla";
			}
			if (n.StartsWith("MorgenHole"))
			{
				return "Putrid Hole";
			}
			if (n.StartsWith("WindingTunnel"))
			{
				return "Winding Tunnels";
			}
			if (n.StartsWith("Hildir_cave"))
			{
				return "Hildir's Cave";
			}
			if (n.StartsWith("Hildir_crypt"))
			{
				return "Hildir's Crypt";
			}
			if (n.StartsWith("Hildir_plainsfortress"))
			{
				return "Hildir's Fortress";
			}
			if (n.StartsWith("Hildir_camp"))
			{
				return "Hildir's Camp";
			}
			if (n.StartsWith("TarPit"))
			{
				return "Tar Pit";
			}
			if (n.StartsWith("Eikthyrnir"))
			{
				return "Eikthyr's Den";
			}
			if (n.StartsWith("Aspect_Elder"))
			{
				return "The Elder's Shrine";
			}
			if (n.StartsWith("Bonemass"))
			{
				return "Bonemass Altar";
			}
			if (n.StartsWith("Moder"))
			{
				return "Moder's Altar";
			}
			if (n.StartsWith("Yagluth"))
			{
				return "Yagluth's Lair";
			}
			if (n.StartsWith("Dragonqueen"))
			{
				return "The Queen's Lair";
			}
			if (n.StartsWith("FaderLocation") || n.StartsWith("Ashlands_Altar"))
			{
				return "Fader's Coliseum";
			}
			if (n.StartsWith("DN_Bossroom"))
			{
				return "Kall Fimbulbringer's Lair";
			}
			if (n.StartsWith("CharredFortress") || n.StartsWith("AshlandRuins"))
			{
				return "Charred Fortress";
			}
			if (n.StartsWith("BearCave"))
			{
				return "Bear Cave";
			}
			if (n.StartsWith("Mistlands_GuardTower"))
			{
				return "Dvergr Guard Tower";
			}
			if (n.StartsWith("Mistlands_Lighthouse"))
			{
				return "Dvergr Lighthouse";
			}
			if (n.StartsWith("FulingTower"))
			{
				return "Fuling Tower";
			}
			if (n.StartsWith("AbandonedHomestead"))
			{
				return "Abandoned Homestead";
			}
			if (n.StartsWith("Grausten"))
			{
				return "Grausten Ruins";
			}
			if (n.StartsWith("Dolmen"))
			{
				return "Stone Circle";
			}
			if (n.StartsWith("StatueTower"))
			{
				return "Stone Tower Ruins";
			}
			if (n.StartsWith("SwampHut"))
			{
				return "Swamp Hut";
			}
			if (n.StartsWith("ShipWreck"))
			{
				return "Shipwreck";
			}
			if (n.StartsWith("TarPit"))
			{
				return "Tar Pit";
			}
			if (n.StartsWith("Pickable_DvergrStein"))
			{
				return "Dvergr Component Crate";
			}
			if (n.StartsWith("FlametalRockstand"))
			{
				return "Flametal Ore";
			}
			if (n.StartsWith("GoblinKing"))
			{
				return "Yagluth's Lair";
			}
			if (n.StartsWith("GoblinCamp") || n.StartsWith("FulingCamp"))
			{
				return "Fuling Camp";
			}
			if (n.StartsWith("Ruin"))
			{
				return "Ruins";
			}
			if (n.StartsWith("StoneTower"))
			{
				return "Stone Tower Ruins";
			}
			if (n.StartsWith("WoodVillage"))
			{
				return "Abandoned Village";
			}
			if (n.StartsWith("StoneHenge"))
			{
				return "Stone Henge";
			}
			if (n.StartsWith("SwampWell"))
			{
				return "Swamp Well";
			}
			if (n.StartsWith("InfestedTree"))
			{
				return "Guck Sac";
			}
			if (n.StartsWith("AbandonedLogCabin"))
			{
				return "Abandoned Log Cabin";
			}
			if (n.StartsWith("DrakeNest"))
			{
				return "Drake Nest";
			}
			return n;
		}

		public static string GetBaseTranslation(string str)
		{
			if (str == "")
			{
				return "noStr";
			}
			Dictionary<string, string> translations = Localization.instance.m_translations;
			string key = translations.FirstOrDefault((KeyValuePair<string, string> x) => x.Value == str).Key;
			return "$" + key;
		}
	}
	[HarmonyPatch(typeof(MineRock5))]
	internal static class MineRock5_Patch
	{
		[HarmonyPatch(typeof(MineRock5), "AllDestroyed")]
		[HarmonyPostfix]
		public static void AllDestroyed(MineRock5 __instance, bool __result)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			if (__result && Object.op_Implicit((Object)(object)__instance.m_nview))
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
				}
			}
		}
	}
	[HarmonyPatch(typeof(WearNTear))]
	internal static class WearNTear_Patch
	{
		[HarmonyPatch(typeof(WearNTear), "Destroy")]
		[HarmonyPrefix]
		public static void Destroy(WearNTear __instance)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.GetZDO() != null)
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Destructible))]
	internal static class Destructible_Patch
	{
		[HarmonyPatch(typeof(Destructible), "Destroy")]
		[HarmonyPrefix]
		public static void DestroyPrefix(Destructible __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.GetZDO() != null)
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
					DataManager.PinnedObjects.Remove(uid);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character))]
	internal static class Character_Patch
	{
		[HarmonyPatch(typeof(Character), "OnDeath")]
		[HarmonyPrefix]
		public static void OnDeath(Character __instance)
		{
			//IL_001c: 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_0027: 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)
			if (Object.op_Implicit((Object)(object)__instance.m_nview))
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
				}
			}
		}
	}
	internal static class Minimap_Patch
	{
		private static GameObject panel;

		private static GameObject nameInput;

		public static bool IsNaming = false;

		private static string tempOriginalText;

		private static IDestructible tempDestructible;

		private static bool _iconsDiagDone;

		private static GameObject toggleDefault;

		private static readonly Dictionary<PinType, Outline> iconOutlines = new Dictionary<PinType, Outline>();

		private static PinType selectedIcon = (PinType)3;

		private static PinData tempPin;

		private static FieldInfo _minimapIconsField;

		private static bool _iconsFieldSearched;

		private static bool _fieldDumpDone;

		private static readonly PinType[] EditorIcons;

		public static PinType IsPinable(string strID)
		{
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_053f: Unknown result type (might be due to invalid IL or missing references)
			//IL_054f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			string text = (strID.StartsWith("$") ? strID.Substring(1) : strID);
			string baseTranslation = Localization_Patch.GetBaseTranslation(text);
			Dictionary<PinType, List<string>> dictionary = new Dictionary<PinType, List<string>>
			{
				{
					(PinType)0,
					new List<string> { "$piece_firepit", "$piece_bonfire", "$piece_fire", "$piece_goblincamp", "Goblin Camp", "Bonfire", "Campfire", "Hearth" }
				},
				{
					(PinType)1,
					new List<string> { "Base", "Home", "Portal" }
				},
				{
					(PinType)2,
					new List<string>
					{
						"$piece_deposit_copper", "Copper Deposit", "Copper", "$piece_deposit_silver", "Silver Deposit", "Silver", "Silvervein", "$piece_deposit_silvervein", "$piece_deposit_tin", "Tin Deposit",
						"Tin", "$piece_mudpile", "Muddy scrap pile", "Mud pile", "$piece_giant_brain", "Giant brain", "Tar Pit", "Dvergr Component Crate", "Flametal Ore"
					}
				},
				{
					(PinType)3,
					new List<string>
					{
						"$item_raspberries", "Raspberries", "$item_blueberries", "Blueberries", "$item_cloudberries", "Cloudberries", "$item_dragonegg", "Dragon egg", "$item_dandelion", "Dandelion",
						"$item_mushroomcommon", "Mushroom", "$item_magecap", "Magecap", "$item_mushroomblue", "Blue mushroom", "$item_thistle", "Thistle", "$item_jotunpuffs", "Jotun puffs",
						"$item_ancientroot", "Ancient root", "$peRaspberryBushName", "$peBlueberryBushName", "$peCloudberryBushName", "$pePickableMushroomName", "$pePickableYellowMushroomName", "$pePickableBlueMushroomName", "$pePickableThistleName", "$pePickableDandelionName",
						"$pePickableJotunpuffsName"
					}
				},
				{
					(PinType)6,
					new List<string>
					{
						"$location_forestcave", "Troll Cave", "$location_forestcrypt", "Burial Chambers", "$location_sunkencrypt", "Sunken Crypt", "$location_mountaincave", "Frost Cave", "$location_dvergrtown", "Dvergr Town",
						"Infested Mine", "Morkhalla", "Putrid Hole", "Winding Tunnels", "Hildir's Cave", "Hildir's Crypt", "Hildir's Fortress", "Hildir's Camp", "$piece_portal", "Portal",
						"Stone Henge", "Charred Fortress", "Bear Cave", "Fuling Camp", "Goblin Camp", "Draugr Village", "Goblin Tower", "Fuling Tower", "Dvergr Guard Tower", "Dvergr Lighthouse"
					}
				},
				{
					(PinType)9,
					new List<string> { "Eikthyr's Den", "The Elder's Shrine", "Bonemass's Altar", "Moder's Altar", "Yagluth's Lair", "The Queen's Lair", "Fader's Coliseum", "Kall Fimbulbringer's Lair", "Bonemass Altar" }
				}
			};
			foreach (PinType key in dictionary.Keys)
			{
				if (dictionary[key].Contains(strID) || dictionary[key].Contains(text) || dictionary[key].Contains(baseTranslation))
				{
					return key;
				}
			}
			return (PinType)8;
		}

		internal static void RenamePin(HoverObject obj)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: true, rename: true);
		}

		public static void AddPin(HoverObject obj)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center);
		}

		public static void ForceAddPin(HoverObject obj)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: true);
		}

		public unsafe static void AddPin(GameObject hover, IDestructible idestructible, string strID, Vector3 pos, bool force = false, bool rename = false)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Invalid comparison between Unknown and I4
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Invalid comparison between Unknown and I4
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Invalid comparison between Unknown and I4
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			if ((!Settings.AddPin.Value && !force) || (!force && !rename && strID != null && strID.Contains("item_tar")))
			{
				return;
			}
			if ((Object)(object)hover != (Object)null && !rename)
			{
				ZNetView componentInParent = hover.GetComponentInParent<ZNetView>();
				if ((Object)(object)componentInParent != (Object)null && componentInParent.GetZDO() != null && DataManager.PinnedObjects.ContainsKey(componentInParent.GetZDO().m_uid))
				{
					return;
				}
			}
			bool flag = strID == "$piece_portal" || strID == "Portal";
			if (!rename && !flag)
			{
				string text = (DataManager.CustomNames.ContainsKey(strID) ? DataManager.CustomNames[strID] : Localization.instance.Localize(strID));
				if (string.IsNullOrEmpty(text))
				{
					text = "PING !";
				}
				foreach (PinData pin in Minimap.instance.m_pins)
				{
					if (pin == null || !(pin.m_name == text) || !(Vector3.Distance(pin.m_pos, pos) <= Settings.PinExclusionRange.Value))
					{
						continue;
					}
					return;
				}
			}
			ManualLogSource log = QuickPingPlugin.Log;
			string[] obj = new string[8] { "[QP] AddPin enter: name=", strID, " pos=", null, null, null, null, null };
			Vector3 val = pos;
			obj[3] = ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString();
			obj[4] = " force=";
			obj[5] = force.ToString();
			obj[6] = " rename=";
			obj[7] = rename.ToString();
			log.LogInfo((object)string.Concat(obj));
			bool flag2 = false;
			PinData val2 = new PinData
			{
				m_type = IsPinable(strID)
			};
			if (Object.op_Implicit((Object)(object)hover) && Object.op_Implicit((Object)(object)hover.GetComponent<ItemDrop>()))
			{
				val2.m_type = (PinType)8;
			}
			PinData closestPin = Minimap.instance.GetClosestPin(pos, Settings.ClosestPinRange.Value, true);
			if (strID == "$piece_portal" || strID == "Portal")
			{
				Hoverable hoverable = default(Hoverable);
				if (hover.TryGetComponent<Hoverable>(ref hoverable))
				{
					val2.m_name = GetPortalTag(hoverable);
					if (closestPin != null)
					{
						Minimap.instance.RemovePin(closestPin);
					}
					val2.m_pos = pos;
					val2 = Minimap.instance.AddPin(val2.m_pos, val2.m_type, val2.m_name, true, false, 0L, default(PlatformUserID));
					flag2 = true;
				}
			}
			else if (closestPin == null || rename)
			{
				PinData val3 = val2;
				if (val3.m_name == null)
				{
					val3.m_name = Localization.instance.Localize(strID);
				}
				bool flag3 = DataManager.CustomNames.ContainsKey(strID);
				if (flag3)
				{
					val2.m_name = DataManager.CustomNames[strID];
				}
				val2.m_pos = pos;
				if (val2.m_name == null || (val2.m_name == "" && !flag3))
				{
					val2.m_name = "PING !";
				}
				if (rename && (int)val2.m_type == 8)
				{
					val2.m_type = Settings.DefaultPinType.Value;
				}
				if (force && val2.m_name == "PING !" && !string.IsNullOrEmpty(Settings.DefaultPinName.Value))
				{
					val2.m_name = Settings.DefaultPinName.Value;
				}
				if ((int)val2.m_type == 8 && force)
				{
					val2.m_type = Settings.DefaultPinType.Value;
					val2 = Minimap.instance.AddPin(val2.m_pos, val2.m_type, val2.m_name, true, false, 0L, default(PlatformUserID));
					flag2 = true;
				}
				else if ((int)val2.m_type != 8)
				{
					if (closestPin == null && !rename)
					{
						val2 = Minimap.instance.AddPin(val2.m_pos, val2.m_type, val2.m_name, true, false, 0L, default(PlatformUserID));
						flag2 = true;
					}
					if (rename)
					{
						GUIManager.BlockInput(true);
						tempOriginalText = strID;
						tempPin = val2;
						tempDestructible = idestructible;
						InitNameInput();
					}
				}
			}
			if (flag2)
			{
				ManualLogSource log2 = QuickPingPlugin.Log;
				string name = val2.m_name;
				val = val2.m_pos;
				log2.LogInfo((object)("[QP] Pin added: " + name + " @ " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString()));
			}
			if (!(idestructible != null && flag2))
			{
				return;
			}
			FieldInfo field = ((object)idestructible).GetType().GetField("m_nview", BindingFlags.Instance | BindingFlags.NonPublic);
			if (!(field == null))
			{
				object? value = field.GetValue(idestructible);
				ZNetView val4 = (ZNetView)((value is ZNetView) ? value : null);
				ZDOID uid = val4.GetZDO().m_uid;
				bool flag4 = false;
				if (!DataManager.PinnedObjects.ContainsKey(uid))
				{
					DataManager.PinnedObjects[uid] = val2;
				}
			}
		}

		public static void UpdateNameInput()
		{
			try
			{
				if ((Object)(object)Minimap.instance == (Object)null)
				{
					return;
				}
				if (Input.GetKeyDown((KeyCode)27))
				{
					CancelNameInput();
					return;
				}
				if ((Object)(object)nameInput != (Object)null && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)))
				{
					InputField component = nameInput.GetComponent<InputField>();
					Toggle val = (((Object)(object)toggleDefault != (Object)null) ? toggleDefault.GetComponent<Toggle>() : null);
					ValidateNameInput(component, (Object)(object)val != (Object)null && val.isOn);
					return;
				}
				if ((Object)(object)panel != (Object)null)
				{
					panel.SetActive(true);
				}
				if ((Object)(object)nameInput != (Object)null)
				{
					nameInput.SetActive(true);
				}
				if ((Object)(object)toggleDefault != (Object)null)
				{
					toggleDefault.SetActive(true);
				}
				InputField val2 = (((Object)(object)nameInput != (Object)null) ? nameInput.GetComponent<InputField>() : null);
				if ((Object)(object)val2 != (Object)null && !val2.isFocused && (Object)(object)EventSystem.current != (Object)null)
				{
					EventSystem.current.SetSelectedGameObject(nameInput);
				}
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("[QP] UpdateNameInput failed: " + ex.Message));
				CancelNameInput();
			}
		}

		private static void CancelNameInput()
		{
			IsNaming = false;
			tempOriginalText = null;
			tempPin = null;
			tempDestructible = null;
			try
			{
				GUIManager.BlockInput(false);
			}
			catch
			{
			}
			DestroyGUI();
		}

		private static void DestroyGUI()
		{
			try
			{
				if ((Object)(object)nameInput != (Object)null)
				{
					Object.Destroy((Object)(object)nameInput);
				}
				if ((Object)(object)toggleDefault != (Object)null)
				{
					Object.Destroy((Object)(object)toggleDefault);
				}
				if ((Object)(object)panel != (Object)null)
				{
					Object.Destroy((Object)(object)panel);
				}
			}
			catch
			{
			}
			iconOutlines.Clear();
			panel = null;
			nameInput = null;
			toggleDefault = null;
		}

		private static void ConfirmEditor()
		{
			try
			{
				InputField inputField = (((Object)(object)nameInput != (Object)null) ? nameInput.GetComponent<InputField>() : null);
				Toggle val = (((Object)(object)toggleDefault != (Object)null) ? toggleDefault.GetComponent<Toggle>() : null);
				ValidateNameInput(inputField, (Object)(object)val != (Object)null && val.isOn);
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("[QP] Confirm failed: " + ex.Message));
				CancelNameInput();
			}
		}

		private unsafe static void ValidateNameInput(InputField inputField, bool useAsDefault)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = (((Object)(object)inputField != (Object)null) ? inputField.text.Replace('$', ' ').Replace('<', ' ').Replace('>', ' ') : "");
				string text2 = tempOriginalText;
				PinData val = tempPin;
				if (val != null && (Object)(object)Minimap.instance != (Object)null)
				{
					val.m_name = text;
					val.m_type = selectedIcon;
					PinData val2 = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, default(PlatformUserID));
					if (val2 != null)
					{
						val = val2;
						ManualLogSource log = QuickPingPlugin.Log;
						string name = val.m_name;
						Vector3 pos = val.m_pos;
						log.LogInfo((object)("[QP] Pin added (via editor): " + name + " @ " + ((object)(*(Vector3*)(&pos))/*cast due to .constrained prefix*/).ToString()));
						if (tempDestructible != null)
						{
							try
							{
								FieldInfo field = ((object)tempDestructible).GetType().GetField("m_nview", BindingFlags.Instance | BindingFlags.NonPublic);
								if (field != null)
								{
									object? value = field.GetValue(tempDestructible);
									ZNetView val3 = (ZNetView)((value is ZNetView) ? value : null);
									if ((Object)(object)val3 != (Object)null && val3.GetZDO() != null)
									{
										ZDOID uid = val3.GetZDO().m_uid;
										if (!DataManager.PinnedObjects.ContainsKey(uid))
										{
											DataManager.PinnedObjects[uid] = val;
										}
									}
								}
							}
							catch
							{
							}
						}
					}
				}
				if (string.IsNullOrEmpty(text))
				{
					if (!string.IsNullOrEmpty(text2) && DataManager.CustomNames.ContainsKey(text2))
					{
						DataManager.CustomNames.Remove(text2);
					}
				}
				else
				{
					SaveName(text, text2);
				}
				if (useAsDefault)
				{
					Settings.DefaultPinType.Value = selectedIcon;
					Settings.DefaultPinName.Value = text;
				}
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("[QP] ValidateNameInput failed: " + ex.Message));
			}
			IsNaming = false;
			tempOriginalText = null;
			tempPin = null;
			tempDestructible = null;
			try
			{
				GUIManager.BlockInput(false);
			}
			catch
			{
			}
			DestroyGUI();
		}

		private static void SaveName(string m_name, string originalName)
		{
			if (!string.IsNullOrEmpty(originalName))
			{
				if (DataManager.CustomNames.ContainsKey(originalName))
				{
					DataManager.CustomNames[originalName] = m_name;
				}
				else
				{
					DataManager.CustomNames.Add(originalName, m_name);
				}
			}
		}

		private static Sprite GetPinSprite(PinType type)
		{
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Invalid comparison between I4 and Unknown
			try
			{
				if ((Object)(object)Minimap.instance == (Object)null)
				{
					return null;
				}
				if (!_iconsFieldSearched)
				{
					_iconsFieldSearched = true;
					_minimapIconsField = typeof(Minimap).GetField("m_icons", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if (_minimapIconsField != null)
				{
					object value = _minimapIconsField.GetValue(Minimap.instance);
					if (value is IEnumerable enumerable)
					{
						int num = 0;
						foreach (object item in enumerable)
						{
							num++;
							if (item == null)
							{
								continue;
							}
							Type type2 = item.GetType();
							FieldInfo field = type2.GetField("m_name", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							FieldInfo field2 = type2.GetField("m_icon", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
							if (field == null || field2 == null)
							{
								continue;
							}
							object value2 = field.GetValue(item);
							if (value2 == null)
							{
								continue;
							}
							bool flag = false;
							if (value2 is PinType val)
							{
								flag = val == type;
							}
							else
							{
								try
								{
									flag = Convert.ToInt32(value2) == (int)type;
								}
								catch
								{
								}
							}
							if (flag)
							{
								object? value3 = field2.GetValue(item);
								return (Sprite)((value3 is Sprite) ? value3 : null);
							}
						}
						if (!_iconsDiagDone)
						{
							_iconsDiagDone = true;
							QuickPingPlugin.Log.LogInfo((object)("[QP] m_icons found, entry count: " + num));
						}
					}
				}
				else if (!_iconsDiagDone)
				{
					_iconsDiagDone = true;
					QuickPingPlugin.Log.LogWarning((object)"[QP] m_icons field NOT found on Minimap");
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		private static void DumpMinimapFieldsOnce()
		{
			if (!_fieldDumpDone && !((Object)(object)Minimap.instance == (Object)null))
			{
				_fieldDumpDone = true;
				QuickPingPlugin.Log.LogInfo((object)"[QP] m_icons field not found on Minimap; dumping all instance fields:");
				FieldInfo[] fields = typeof(Minimap).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					QuickPingPlugin.Log.LogInfo((object)("[QP] Minimap field: " + fieldInfo.Name + " : " + fieldInfo.FieldType.Name));
				}
			}
		}

		private unsafe static string ShortLabel(PinType type)
		{
			//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_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected I4, but got Unknown
			PinType val = type;
			PinType val2 = val;
			return (int)val2 switch
			{
				0 => "Fire", 
				1 => "Home", 
				2 => "Hammer", 
				3 => "Berry", 
				6 => "Dungeon", 
				4 => "Death", 
				5 => "Bed", 
				9 => "Boss", 
				10 => "Player", 
				7 => "Shout", 
				12 => "Ping", 
				11 => "!", 
				_ => ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString(), 
			};
		}

		private static void SelectIcon(PinType type)
		{
			//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_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)
			selectedIcon = type;
			foreach (KeyValuePair<PinType, Outline> iconOutline in iconOutlines)
			{
				if ((Object)(object)iconOutline.Value != (Object)null)
				{
					((Behaviour)iconOutline.Value).enabled = iconOutline.Key == selectedIcon;
				}
			}
		}

		private unsafe static GameObject CreateIconButton(PinType type, Transform parent, Vector2 anchoredPos)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			try
			{
				GameObject val = new GameObject("PinIcon_" + ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString());
				val.transform.SetParent(parent, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.sizeDelta = new Vector2(48f, 48f);
				val2.anchoredPosition = anchoredPos;
				Image val3 = val.AddComponent<Image>();
				((Graphic)val3).color = new Color(0f, 0f, 0f, 0.4f);
				Outline val4 = val.AddComponent<Outline>();
				((Shadow)val4).effectColor = new Color(1f, 0.85f, 0f, 1f);
				((Shadow)val4).effectDistance = new Vector2(3f, 3f);
				((Behaviour)val4).enabled = false;
				Sprite pinSprite = GetPinSprite(type);
				if ((Object)(object)pinSprite != (Object)null)
				{
					GameObject val5 = new GameObject("Icon");
					val5.transform.SetParent(val.transform, false);
					RectTransform val6 = val5.AddComponent<RectTransform>();
					val6.sizeDelta = new Vector2(34f, 34f);
					val6.anchoredPosition = Vector2.zero;
					Image val7 = val5.AddComponent<Image>();
					val7.sprite = pinSprite;
					((Graphic)val7).color = Color.white;
				}
				else
				{
					GameObject val8 = new GameObject("Label");
					val8.transform.SetParent(val.transform, false);
					RectTransform val9 = val8.AddComponent<RectTransform>();
					val9.anchorMin = Vector2.zero;
					val9.anchorMax = Vector2.one;
					val9.offsetMin = Vector2.zero;
					val9.offsetMax = Vector2.zero;
					Text val10 = val8.AddComponent<Text>();
					val10.text = ShortLabel(type);
					((Graphic)val10).color = Color.white;
					val10.alignment = (TextAnchor)4;
					val10.fontSize = 12;
					val10.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				}
				Button val11 = val.AddComponent<Button>();
				((Selectable)val11).targetGraphic = (Graphic)(object)val3;
				PinType captured = type;
				((UnityEvent)val11.onClick).AddListener((UnityAction)delegate
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					SelectIcon(captured);
				});
				return val;
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("[QP] CreateIconButton failed for " + ((object)(*(PinType*)(&type))/*cast due to .constrained prefix*/).ToString() + ": " + ex.Message));
				return null;
			}
		}

		private static GameObject CreateTextButton(string label, Transform parent, Vector2 anchoredPos, Vector2 size, Color bgColor, Action onClick)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0077: 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_0091: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			try
			{
				GameObject val = new GameObject(label);
				val.transform.SetParent(parent, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.sizeDelta = size;
				val2.anchoredPosition = anchoredPos;
				Image val3 = val.AddComponent<Image>();
				((Graphic)val3).color = bgColor;
				GameObject val4 = new GameObject("Text");
				val4.transform.SetParent(val.transform, false);
				RectTransform val5 = val4.AddComponent<RectTransform>();
				val5.anchorMin = Vector2.zero;
				val5.anchorMax = Vector2.one;
				val5.offsetMin = Vector2.zero;
				val5.offsetMax = Vector2.zero;
				Text val6 = val4.AddComponent<Text>();
				val6.text = label;
				((Graphic)val6).color = Color.white;
				val6.alignment = (TextAnchor)4;
				val6.fontSize = 16;
				val6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				Button val7 = val.AddComponent<Button>();
				((Selectable)val7).targetGraphic = (Graphic)(object)val3;
				((UnityEvent)val7.onClick).AddListener((UnityAction)delegate
				{
					onClick();
				});
				return val;
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("[QP] CreateTextButton failed for " + label + ": " + ex.Message));
				return null;
			}
		}

		private static void InitNameInput()
		{
			//IL_0049: 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_0042: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Expected O, but got Unknown
			//IL_039f: 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_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (GUIManager.Instance == null || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
				{
					return;
				}
				DestroyGUI();
				IsNaming = true;
				selectedIcon = ((tempPin != null && (int)tempPin.m_type != 8) ? tempPin.m_type : Settings.DefaultPinType.Value);
				panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 380f, 320f, true);
				GameObject val = new GameObject("Title");
				val.transform.SetParent(panel.transform, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.sizeDelta = new Vector2(320f, 24f);
				val2.anchoredPosition = new Vector2(0f, 132f);
				Text val3 = val.AddComponent<Text>();
				val3.text = "Pin Editor";
				((Graphic)val3).color = Color.white;
				val3.alignment = (TextAnchor)4;
				val3.fontSize = 18;
				val3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				iconOutlines.Clear();
				Vector2 anchoredPos = default(Vector2);
				for (int i = 0; i < EditorIcons.Length; i++)
				{
					PinType val4 = EditorIcons[i];
					((Vector2)(ref anchoredPos))..ctor(-125f + (float)(i % 6) * 50f, 80f - (float)(i / 6) * 54f);
					GameObject val5 = CreateIconButton(val4, panel.transform, anchoredPos);
					if ((Object)(object)val5 != (Object)null)
					{
						Outline component = val5.GetComponent<Outline>();
						if ((Object)(object)component != (Object)null)
						{
							iconOutlines[val4] = component;
						}
					}
				}
				SelectIcon(selectedIcon);
				nameInput = GUIManager.Instance.CreateInputField(panel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, -20f), (ContentType)0, "Pin Name (blank = icon only)", 16, 280f, 32f);
				InputField val6 = (((Object)(object)nameInput != (Object)null) ? nameInput.GetComponent<InputField>() : null);
				if ((Object)(object)val6 != (Object)null)
				{
					val6.text = ((tempPin != null) ? (tempPin.m_name ?? "") : "");
				}
				if ((Object)(object)nameInput != (Object)null)
				{
					nameInput.SetActive(true);
				}
				toggleDefault = GUIManager.Instance.CreateToggle(panel.transform, 20f, 20f);
				if ((Object)(object)toggleDefault != (Object)null)
				{
					RectTransform component2 = toggleDefault.GetComponent<RectTransform>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.anchorMin = new Vector2(0.5f, 0.5f);
						component2.anchorMax = new Vector2(0.5f, 0.5f);
						component2.anchoredPosition = new Vector2(-135f, -62f);
					}
					toggleDefault.SetActive(true);
				}
				GameObject val7 = new GameObject("ToggleLabel");
				val7.transform.SetParent(panel.transform, false);
				RectTransform val8 = val7.AddComponent<RectTransform>();
				val8.anchorMin = new Vector2(0.5f, 0.5f);
				val8.anchorMax = new Vector2(0.5f, 0.5f);
				val8.sizeDelta = new Vector2(230f, 20f);
				val8.anchoredPosition = new Vector2(-10f, -62f);
				Text val9 = val7.AddComponent<Text>();
				val9.text = "Use as default for future pins";
				((Graphic)val9).color = Color.white;
				val9.alignment = (TextAnchor)3;
				val9.fontSize = 13;
				val9.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				CreateTextButton("Confirm", panel.transform, new Vector2(-75f, -115f), new Vector2(140f, 34f), new Color(0.3f, 0.45f, 0.25f, 1f), ConfirmEditor);
				CreateTextButton("Cancel", panel.transform, new Vector2(75f, -115f), new Vector2(140f, 34f), new Color(0.45f, 0.3f, 0.25f, 1f), CancelNameInput);
			}
			catch (Exception ex)
			{
				QuickPingPlugin.Log.LogError((object)("[QP] InitNameInput failed: " + ex));
				IsNaming = false;
				try
				{
					GUIManager.BlockInput(false);
				}
				catch
				{
				}
				try
				{
					if ((Object)(object)Minimap.instance != (Object)null)
					{
						Minimap.instance.m_namePin = null;
					}
				}
				catch
				{
				}
				DestroyGUI();
			}
		}

		private static string GetPortalTag(Hoverable hoverable)
		{
			return hoverable.GetHoverText().Split(new char[1] { '"' })[1];
		}

		[HarmonyPatch(typeof(Minimap), "RemovePin", new Type[] { typeof(PinData) })]
		[HarmonyPostfix]
		public static void RemovePin_Postfix(Minimap __instance, PinData pin)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			if (pin == null)
			{
				return;
			}
			foreach (KeyValuePair<ZDOID, PinData> pinnedObject in DataManager.PinnedObjects)
			{
				if (pinnedObject.Value.m_name == pin.m_name && pinnedObject.Value.m_pos == pin.m_pos)
				{
					DataManager.PinnedObjects.Remove(pinnedObject.Key);
					break;
				}
			}
		}

		static Minimap_Patch()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			PinType[] array = new PinType[12];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			EditorIcons = (PinType[])(object)array;
		}
	}
	internal static class Player_Patch
	{
		public static UnityEvent<HoverObject> OnPlayerPing = new UnityEvent<HoverObject>();

		public static UnityEvent<HoverObject> OnPlayerForcePing = new UnityEvent<HoverObject>();

		public static UnityEvent<HoverObject> OnPlayerRename = new UnityEvent<HoverObject>();

		private static float LastPingStamp = -1f;

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPostfix]
		private static void Player_Update(Player __instance)
		{
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			if (ZInput.instance == null || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)Player.m_localPlayer != (Object)(object)__instance || (!Settings.PingWhereLooking.Value && !Settings.AddPin.Value))
			{
				return;
			}
			if (Minimap_Patch.IsNaming)
			{
				Minimap_Patch.UpdateNameInput();
			}
			bool flag = true;
			MethodInfo method = typeof(Player).GetMethod("TakeInput", new Type[1] { typeof(float) });
			flag = ((method != null) ? ((bool)method.Invoke(Player.m_localPlayer, new object[1] { 0f })) : ((!(typeof(Player).GetMethod("TakeInput", Type.EmptyTypes) != null)) ? (!((Character)Player.m_localPlayer).IsDead() && !((Character)Player.m_localPlayer).InBed() && !((Character)Player.m_localPlayer).InCutscene()) : ((bool)typeof(Player).GetMethod("TakeInput", Type.EmptyTypes).Invoke(Player.m_localPlayer, null))));
			if (flag && (int)Settings.PingKey.Value != 0 && Time.time - LastPingStamp >= 0.25f)
			{
				KeyboardShortcut value = Settings.RenameKey.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					HoverObject hoverObject = FindHoverObject(500f);
					TarDetector.UpgradeToTar(hoverObject, 500f);
					hoverObject.Name = GetHoverName(hoverObject.Name, hoverObject.Hover, hoverObject.type);
					OnPlayerRename.Invoke(hoverObject);
					LastPingStamp = Time.time;
				}
				else if (ZInput.GetButtonDown(Settings.PingBtn.Name))
				{
					HoverObject hoverObject2 = FindHoverObject(500f);
					TarDetector.UpgradeToTar(hoverObject2, 500f);
					hoverObject2.Name = GetHoverName(hoverObject2.Name, hoverObject2.Hover, hoverObject2.type);
					OnPlayerPing.Invoke(hoverObject2);
					LastPingStamp = Time.time;
				}
				else if (ZInput.GetButtonDown(Settings.PingEverythingBtn.Name))
				{
					HoverObject hoverObject3 = FindHoverObject(500f);
					TarDetector.UpgradeToTar(hoverObject3, 500f);
					hoverObject3.Name = GetHoverName(hoverObject3.Name, hoverObject3.Hover, hoverObject3.type);
					OnPlayerForcePing.Invoke(hoverObject3);
					LastPingStamp = Time.time;
				}
			}
		}

		private static string GetHoverName(string pingText, GameObject hover, HoverType type)
		{
			switch (type)
			{
			case HoverType.Hoverable:
			{
				Hoverable val = default(Hoverable);
				hover.TryGetComponent<Hoverable>(ref val);
				pingText = ((!val.GetHoverName().StartsWith("$")) ? Localization_Patch.GetBaseTranslation(val.GetHoverName()) : val.GetHoverName());
				if (pingText == "$")
				{
					pingText = val.GetHoverName();
				}
				if (pingText == "noStr")
				{
					pingText = val.GetHoverName();
				}
				if (((object)val).ToString().Contains("ReadMap") || ((object)val).ToString().Contains("WriteMap") || ((object)val).ToString().Contains("add_ore") || ((object)val).ToString().Contains("add_wood") || (((object)val).ToString().Contains("door") && Object.op_Implicit((Object)(object)hover.transform.parent) && Object.op_Implicit((Object)(object)((Component)hover.transform).GetComponentInParent<Piece>())))
				{
					pingText = hover.GetComponentInParent<Piece>().m_name;
				}
				break;
			}
			case HoverType.Piece:
			{
				Piece component3 = hover.GetComponent<Piece>();
				pingText = component3.m_name;
				break;
			}
			case HoverType.Location:
			{
				Location component2 = hover.GetComponent<Location>();
				pingText = (((Object)(object)component2 != (Object)null) ? Localization_Patch.Localize(component2) : Localization_Patch.LocalizeName(((Object)hover).name));
				break;
			}
			case HoverType.Character:
			{
				Character component = hover.GetComponent<Character>();
				pingText = component.m_name;
				break;
			}
			}
			return pingText;
		}

		public static HoverObject FindHoverObject(float range)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_085d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0862: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Invalid comparison between Unknown and I4
			//IL_0816: Unknown result type (might be due to invalid IL or missing references)
			//IL_081b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0709: Unknown result type (might be due to invalid IL or missing references)
			//IL_070e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0751: Invalid comparison between Unknown and I4
			HoverObject hoverObject = new HoverObject
			{
				type = HoverType.GameObject,
				pos = ((Character)Player.m_localPlayer).GetHeadPoint(),
				center = ((Character)Player.m_localPlayer).GetHeadPoint(),
				Name = "PING !"
			};
			LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[12]
			{
				"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "character_noenv",
				"vehicle", "item"
			}));
			RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, range + 10f, LayerMask.op_Implicit(val));
			RaycastHit[] array2 = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, range + 10f, LayerMask.GetMask(new string[1] { "Water" }), (QueryTriggerInteraction)2);
			if (array2.Length != 0)
			{
				RaycastHit[] array3 = (RaycastHit[])(object)new RaycastHit[array.Length + array2.Length];
				array.CopyTo(array3, 0);
				array2.CopyTo(array3, array.Length);
				array = array3;
			}
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			RaycastHit[] array4 = array;
			if (array4.Length == 0)
			{
				Ray val2 = default(Ray);
				((Ray)(ref val2))..ctor(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward);
				hoverObject.pos = ((Ray)(ref val2)).GetPoint(range);
				hoverObject.center = hoverObject.pos;
				return hoverObject;
			}
			for (int num = 0; num < array4.Length; num++)
			{
				hoverObject.pos = ((RaycastHit)(ref array4[num])).point;
				RaycastHit raycastHit = array4[num];
				if (OverlappingPlayer(ref raycastHit))
				{
					continue;
				}
				if (!(Vector3.Distance(((Character)Player.m_localPlayer).GetEyePoint(), ((RaycastHit)(ref raycastHit)).point) < range))
				{
					break;
				}
				Character val3 = (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody) ? ((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).GetComponent<Character>() : ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponent<Character>());
				if ((Object)(object)val3 != (Object)null && (!Object.op_Implicit((Object)(object)val3.GetBaseAI()) || !val3.GetBaseAI().IsSleeping()))
				{
					hoverObject.type = HoverType.Character;
					hoverObject.Hover = ((Component)val3).gameObject;
					hoverObject.center = ((Component)val3).transform.position;
				}
				else if ((hoverObject.type = CheckType(((Component)((RaycastHit)(ref raycastHit)).collider).transform, out hoverObject.Destructible)) != HoverType.GameObject)
				{
					hoverObject.Hover = ((Component)((Component)((RaycastHit)(ref raycastHit)).collider).transform).gameObject;
					hoverObject.center = hoverObject.Hover.transform.position;
					QuickPingPlugin.Log.LogWarning((object)"Root");
				}
				else if ((Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentInChildren<GameObject>() != (Object)null)
				{
					GameObject[] componentsInChildren = ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentsInChildren<GameObject>();
					GameObject[] array5 = componentsInChildren;
					foreach (GameObject val4 in array5)
					{
						if ((hoverObject.type = CheckType(val4.transform, out hoverObject.Destructible)) != HoverType.GameObject)
						{
							hoverObject.Hover = ((Component)val4.transform).gameObject;
							hoverObject.center = hoverObject.Hover.transform.position;
							QuickPingPlugin.Log.LogWarning((object)"Child");
						}
					}
					if ((Object)(object)hoverObject.Hover == (Object)null && (Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).transform.parent != (Object)null)
					{
						hoverObject.Destructible = GO_Ext.GetRecursiveComponentInParents<IDestructible>(((Component)((RaycastHit)(ref raycastHit)).collider).transform);
						if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Location>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
						{
							hoverObject.type = HoverType.Location;
						}
						else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Piece>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
						{
							hoverObject.type = HoverType.Piece;
						}
						else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Hoverable>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
						{
							hoverObject.type = HoverType.Hoverable;
						}
					}
				}
				else if ((Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).transform.parent != (Object)null)
				{
					hoverObject.Destructible = GO_Ext.GetRecursiveComponentInParents<IDestructible>(((Component)((RaycastHit)(ref raycastHit)).collider).transform);
					if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Location>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
					{
						hoverObject.type = HoverType.Location;
					}
					else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Piece>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
					{
						hoverObject.type = HoverType.Piece;
					}
					else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Hoverable>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
					{
						hoverObject.type = HoverType.Hoverable;
					}
				}
				if (hoverObject.type == HoverType.Character || hoverObject.type == HoverType.Location)
				{
					break;
				}
				Location val5 = null;
				float num3 = ((Settings.LocationProximityRange != null) ? Settings.LocationProximityRange.Value : 10f);
				Transform val6 = (((Object)(object)hoverObject.Hover != (Object)null) ? hoverObject.Hover.transform : null);
				int num4 = 0;
				while ((Object)(object)val6 != (Object)null && num4 < 20)
				{
					Location component = ((Component)val6).GetComponent<Location>();
					if ((Object)(object)component != (Object)null)
					{
						string strID = Localization_Patch.Localize(component);
						if ((int)Minimap_Patch.IsPinable(strID) != 8)
						{
							val5 = component;
							num3 = 0f;
							break;
						}
					}
					val6 = val6.parent;
					num4++;
				}
				if ((Object)(object)val5 == (Object)null)
				{
					Location[] array6 = Object.FindObjectsByType<Location>((FindObjectsSortMode)0);
					Location val7 = null;
					float num5 = float.MaxValue;
					float num6 = ((Settings.LocationProximityRange != null) ? Settings.LocationProximityRange.Value : 10f);
					Location[] array7 = array6;
					foreach (Location val8 in array7)
					{
						if ((Object)(object)val8 == (Object)null)
						{
							continue;
						}
						float num8 = Vector3.Distance(hoverObject.pos, ((Component)val8).transform.position);
						if (num8 < num5)
						{
							num5 = num8;
							val7 = val8;
						}
						if (num8 < num6)
						{
							string text = Localization_Patch.Localize(val8);
							PinType val9 = Minimap_Patch.IsPinable(text);
							QuickPingPlugin.Log.LogWarning((object)$"[QP-LOCDBG] Proximity check: '{((Object)val8).name}' -> '{text}' -> {val9} (dist: {num8:F1}m)");
							if ((int)val9 != 8 && num8 < num3)
							{
								num3 = num8;
								val5 = val8;
							}
						}
					}
					if ((Object)(object)val5 == (Object)null && (Object)(object)val7 != (Object)null && num5 < 100f)
					{
						QuickPingPlugin.Log.LogWarning((object)$"[QP-LOCDBG] No pinable location within {num6}m. Nearest overall: '{((Object)val7).name}' ({Localization_Patch.Localize(val7)}) at {num5:F1}m");
					}
				}
				if ((Object)(object)val5 != (Object)null)
				{
					hoverObject.type = HoverType.Location;
					hoverObject.Hover = ((Component)val5).gameObject;
					hoverObject.center = ((Component)val5).transform.position;
				}
				break;
			}
			if (Object.op_Implicit((Object)(object)hoverObject.Hover))
			{
				hoverObject.center = hoverObject.Hover.transform.position;
				switch (hoverObject.type)
				{
				case HoverType.GameObject:
					QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {hoverObject.Hover} (GameObject)");
					break;
				case HoverType.Hoverable:
				{
					Hoverable val12 = default(Hoverable);
					if (hoverObject.Hover.TryGetComponent<Hoverable>(ref val12))
					{
						QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val12} (Hoverable) -> Name: {val12.GetHoverName()}");
					}
					break;
				}
				case HoverType.Piece:
				{
					Piece val13 = default(Piece);
					if (hoverObject.Hover.TryGetComponent<Piece>(ref val13))
					{
						QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val13} (Piece) -> Name: {((Object)val13).name} -> Trad: {Localization.instance.Localize(((Object)val13).name)}");
					}
					break;
				}
				case HoverType.Location:
				{
					Location val11 = default(Location);
					if (hoverObject.Hover.TryGetComponent<Location>(ref val11))
					{
						QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val11} (Location) -> Name: {((Object)val11).name} -> Trad: {Localization.instance.Localize(((Object)val11).name)}");
					}
					break;
				}
				case HoverType.Character:
				{
					Character val10 = default(Character);
					if (hoverObject.Hover.TryGetComponent<Character>(ref val10))
					{
						QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {val10} (Character) ->  Name: {val10.m_name} -> Trad: {val10.GetHoverName()}");
					}
					break;
				}
				}
				if (hoverObject.Destructible != null)
				{
					QuickPingPlugin.Log.LogWarning((object)$"Ping ! : {hoverObject.Destructible} (Destructible) -> Type: {hoverObject.Destructible.GetDestructibleType()}");
				}
			}
			else
			{
				hoverObject.center = hoverObject.pos;
			}
			return hoverObject;
		}

		private static HoverType CheckType(Transform root, out IDestructible destructible)
		{
			destructible = ((Component)root).GetComponent<IDestructible>();
			if (((Component)root).GetComponent<Hoverable>() != null)
			{
				return HoverType.Hoverable;
			}
			if ((Object)(object)((Component)root).GetComponent<Location>() != (Object)null)
			{
				return HoverType.Location;
			}
			if (Object.op_Implicit((Object)(object)((Component)root).GetComponent<Piece>()))
			{
				return HoverType.Piece;
			}
			return HoverType.GameObject;
		}

		private static bool OverlappingPlayer(ref RaycastHit raycastHit)
		{
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody) && (Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject)
			{
				return true;
			}
			Player componentInParent = ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentInParent<Player>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent == (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			Character componentInParent2 = ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentInParent<Character>();
			if ((Object)(object)componentInParent2 != (Object)null && (Object)(object)componentInParent2 == (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			return false;
		}

		internal static void SendRename(HoverObject ping)
		{
			SendPing(ping);
		}

		public static void SendPing(HoverObject ping)
		{
			//IL_0002: 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)
			SendPing(ping.pos, Localization.instance.Localize(ping.Name), ping.Name, ping.center);
		}

		internal static void SendPing(Vector3 position, string text, string pinId = null, Vector3 pinCenter = default(Vector3), bool local = false)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer) && Settings.PingWhereLooking.Value)
			{
				ChatPing_Patch.ShowWorldText(position, text);
				ChatPing_Patch.BroadcastPing(position, (pinCenter == Vector3.zero) ? position : pinCenter, text, string.IsNullOrEmpty(pinId) ? text : pinId);
			}
		}
	}
	internal static class TarDetector
	{
		private static MethodInfo _getSurfaceMethod;

		private static bool _getSurfaceSearched;

		public static void UpgradeToTar(HoverObject ping, float range)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (ping == null || (Object)(object)GameCamera.instance == (Object)null || ping.type != HoverType.GameObject || (Object)(object)ping.Hover != (Object)null)
				{
					return;
				}
				Vector3 position = ((Component)GameCamera.instance).transform.position;
				Vector3 pos = ping.pos;
				LiquidVolume val = null;
				float num = float.MaxValue;
				LiquidVolume[] array = Object.FindObjectsByType<LiquidVolume>((FindObjectsSortMode)0);
				LiquidVolume[] array2 = array;
				foreach (LiquidVolume val2 in array2)
				{
					if ((Object)(object)val2 == (Object)null || (int)val2.m_liquidType != 1)
					{
						continue;
					}
					Vector3 position2 = ((Component)val2).transform.position;
					float num2 = Mathf.Max(4f, (float)val2.m_width * val2.m_scale * 0.5f) + 2f;
					float num3 = pos.x - position2.x;
					float num4 = pos.z - position2.z;
					if (num3 * num3 + num4 * num4 > num2 * num2)
					{
						continue;
					}
					float surfaceHeight = GetSurfaceHeight(val2, pos);
					if (float.IsNaN(surfaceHeight) || float.IsInfinity(surfaceHeight) ||