Decompiled source of DroppedEquipmentFinder v1.3.0

DroppedEquipmentFinder.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DroppedEquipmentFinder.Core;
using DroppedEquipmentFinder.Patches;
using DroppedEquipmentFinder.UI;
using HarmonyLib;
using Splatform;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DroppedEquipmentFinder")]
[assembly: AssemblyDescription("Helps players locate dropped equipment in the loaded zone.")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DroppedEquipmentFinder")]
[assembly: AssemblyCopyright("")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DroppedEquipmentFinder
{
	[BepInPlugin("com.yourname.droppedequipmentfinder", "Dropped Equipment Finder", "1.3.0")]
	public class EquipmentFinderPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.yourname.droppedequipmentfinder";

		public const string PluginName = "Dropped Equipment Finder";

		public const string PluginVersion = "1.3.0";

		public static ManualLogSource Log;

		public static ConfigEntry<KeyboardShortcut> LocateHotkey;

		public static ConfigEntry<float> MaxSearchRadius;

		public static ConfigEntry<bool> ShowHUDArrow;

		public static ConfigEntry<bool> AutoRemovePinOnPickup;

		private readonly Harmony _harmony = new Harmony("com.yourname.droppedequipmentfinder");

		private void Awake()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			LocateHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "LocateHotkey", new KeyboardShortcut((KeyCode)108, Array.Empty<KeyCode>()), "Hotkey to open the Lost Items panel (while inventory is open)");
			MaxSearchRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxSearchRadius", 150f, "Max distance (metres) to scan for dropped items");
			ShowHUDArrow = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "ShowHUDArrow", true, "Show directional arrow on screen while tracking an item");
			AutoRemovePinOnPickup = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoRemovePinOnPickup", true, "Automatically remove the minimap pin when you pick the item up");
			TryPatch(typeof(Patch_PlayerDropItem));
			TryPatch(typeof(Patch_GameCameraUpdateCamera));
			TryPatch(typeof(Patch_GameCameraMouseCapture));
			TryPatch(typeof(Patch_PlayerTakeInput));
			TryPatch(typeof(Patch_HumanoidStartAttack));
			TryPatch(typeof(Patch_PlayerFixedUpdate));
			TryPatch(typeof(Patch_HumanoidUpdateEquipment));
			TryPatch(typeof(Patch_PlayerUpdate));
			TryPatch(typeof(Patch_HudAwake));
			Assets.Load();
			Log.LogInfo((object)"Dropped Equipment Finder 1.3.0 loaded.");
		}

		private void TryPatch(Type patchType)
		{
			try
			{
				_harmony.CreateClassProcessor(patchType).Patch();
				Log.LogInfo((object)("Patched " + patchType.Name));
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to patch " + patchType.Name + ": " + ex.Message));
			}
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}
	}
}
namespace DroppedEquipmentFinder.Patches
{
	[HarmonyPatch(typeof(Humanoid), "DropItem")]
	public static class Patch_PlayerDropItem
	{
		[HarmonyPostfix]
		public static void Postfix(Humanoid __instance, Inventory inventory, ItemData item, int amount)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			ItemDrop[] array = Object.FindObjectsOfType<ItemDrop>();
			float num = float.MaxValue;
			ItemDrop val = null;
			ItemDrop[] array2 = array;
			foreach (ItemDrop val2 in array2)
			{
				if (!(val2?.m_itemData?.m_shared?.m_name != item?.m_shared?.m_name))
				{
					float num2 = Vector3.Distance(((Component)val2).transform.position, ((Component)__instance).transform.position);
					if (num2 < num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				ItemScanner.TagDroppedItem(val);
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	public static class Patch_GameCameraUpdateCamera
	{
		private static bool s_wasBlocking = false;

		public static int SkipFrames = 0;

		private static readonly FieldInfo s_yawField = typeof(Player).GetField("m_lookYaw", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly FieldInfo s_pitchField = typeof(Player).GetField("m_lookPitch", BindingFlags.Instance | BindingFlags.NonPublic);

		private static Quaternion s_savedYaw;

		private static float s_savedPitch;

		[HarmonyPrefix]
		public static bool Prefix(GameCamera __instance)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				if (!s_wasBlocking && (Object)(object)Player.m_localPlayer != (Object)null)
				{
					s_savedYaw = (Quaternion)s_yawField.GetValue(Player.m_localPlayer);
					s_savedPitch = (float)s_pitchField.GetValue(Player.m_localPlayer);
				}
				s_wasBlocking = true;
				return false;
			}
			if (s_wasBlocking)
			{
				s_wasBlocking = false;
				SkipFrames = 2;
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					s_yawField.SetValue(Player.m_localPlayer, s_savedYaw);
					s_pitchField.SetValue(Player.m_localPlayer, s_savedPitch);
				}
			}
			if (SkipFrames > 0)
			{
				SkipFrames--;
				Input.ResetInputAxes();
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	public static class Patch_PlayerUpdate
	{
		private static bool s_logged;

		[HarmonyPrefix]
		public static bool Prefix(Player __instance)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if (!s_logged)
			{
				s_logged = true;
				BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
				FieldInfo[] fields = typeof(Player).GetFields(bindingAttr);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (fieldInfo.FieldType == typeof(float) || fieldInfo.FieldType == typeof(Quaternion))
					{
						EquipmentFinderPlugin.Log.LogInfo((object)("PF " + fieldInfo.FieldType.Name + " " + fieldInfo.Name));
					}
				}
				FieldInfo[] fields2 = typeof(Character).GetFields(bindingAttr);
				foreach (FieldInfo fieldInfo2 in fields2)
				{
					if (fieldInfo2.FieldType == typeof(float) || fieldInfo2.FieldType == typeof(Quaternion))
					{
						EquipmentFinderPlugin.Log.LogInfo((object)("CF " + fieldInfo2.FieldType.Name + " " + fieldInfo2.Name));
					}
				}
			}
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "TakeInput")]
	public static class Patch_PlayerTakeInput
	{
		[HarmonyPrefix]
		public static bool Prefix(Player __instance)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	public static class Patch_HumanoidStartAttack
	{
		[HarmonyPrefix]
		public static bool Prefix(Humanoid __instance, ref bool __result)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Humanoid), "UpdateEquipment")]
	public static class Patch_HumanoidUpdateEquipment
	{
		[HarmonyPrefix]
		public static bool Prefix(Humanoid __instance)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	public static class Patch_GameCameraMouseCapture
	{
		[HarmonyPrefix]
		public static bool Prefix()
		{
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				return false;
			}
			if (Patch_GameCameraUpdateCamera.SkipFrames > 0)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "FixedUpdate")]
	public static class Patch_PlayerFixedUpdate
	{
		[HarmonyPrefix]
		public static bool Prefix(Player __instance)
		{
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if ((Object)(object)LostItemsPanel.Instance != (Object)null && LostItemsPanel.Instance.IsBlockingInput)
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Hud), "Awake")]
	public static class Patch_HudAwake
	{
		[HarmonyPostfix]
		public static void Postfix(Hud __instance)
		{
			((Component)__instance).gameObject.AddComponent<HUDTracker>();
			((Component)__instance).gameObject.AddComponent<LostItemsPanel>();
			EquipmentFinderPlugin.Log.LogInfo((object)"EquipmentFinder UI attached to HUD.");
		}
	}
}
namespace DroppedEquipmentFinder.UI
{
	public class HUDTracker : MonoBehaviour
	{
		private GUIStyle _nameStyle;

		private GUIStyle _distStyle;

		private GUIStyle _nameShadow;

		private GUIStyle _distShadow;

		private static readonly Color C_Gold = new Color(1f, 0.847f, 0.51f, 1f);

		private static readonly Color C_GoldDim = new Color(0.784f, 0.62f, 0.353f, 1f);

		private static readonly Color C_Shadow = new Color(0f, 0f, 0f, 0.85f);

		private float _reacquireTimer = 0f;

		private const float ReacquireInterval = 2f;

		public static HUDTracker Instance { get; private set; }

		public TrackedItem ActiveTarget { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void OnEnable()
		{
			//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_0010: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_008c: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			GUIStyle val = new GUIStyle
			{
				fontSize = 17,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val.normal.background = null;
			val.normal.textColor = C_Gold;
			_nameStyle = val;
			GUIStyle val2 = new GUIStyle
			{
				fontSize = 14,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val2.normal.background = null;
			val2.normal.textColor = C_GoldDim;
			_distStyle = val2;
			GUIStyle val3 = new GUIStyle(_nameStyle);
			val3.normal.background = null;
			val3.normal.textColor = C_Shadow;
			_nameShadow = val3;
			GUIStyle val4 = new GUIStyle(_distStyle);
			val4.normal.background = null;
			val4.normal.textColor = C_Shadow;
			_distShadow = val4;
		}

		public void SetTarget(TrackedItem item)
		{
			ActiveTarget = item;
		}

		public void ClearTarget()
		{
			ActiveTarget = null;
		}

		private void Update()
		{
			if (ActiveTarget != null && !((Object)(object)ActiveTarget.Source != (Object)null))
			{
				_reacquireTimer -= Time.deltaTime;
				if (!(_reacquireTimer > 0f))
				{
					_reacquireTimer = 2f;
					TryReacquireSource();
				}
			}
		}

		private void TryReacquireSource()
		{
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			if (ActiveTarget == null)
			{
				return;
			}
			string localPlayerID = ItemScanner.GetLocalPlayerID();
			if (string.IsNullOrEmpty(localPlayerID) || localPlayerID == "unknown")
			{
				return;
			}
			ItemDrop[] array = Object.FindObjectsOfType<ItemDrop>();
			ItemDrop[] array2 = array;
			foreach (ItemDrop val in array2)
			{
				if ((Object)(object)val == (Object)null || val.m_itemData?.m_shared?.m_name == null)
				{
					continue;
				}
				string text = ((Object)((Component)val).gameObject).name.Replace("(Clone)", "").Trim();
				if (text != ActiveTarget.ItemName)
				{
					continue;
				}
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid())
				{
					string @string = component.GetZDO().GetString("equipmentfinder_owner", string.Empty);
					if (!(@string != localPlayerID))
					{
						ActiveTarget.Source = val;
						ActiveTarget.WorldPos = ((Component)val).transform.position;
						break;
					}
				}
			}
		}

		private void OnGUI()
		{
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00aa: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			if (!EquipmentFinderPlugin.ShowHUDArrow.Value || ActiveTarget == null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				bool flag = (Object)(object)ActiveTarget.Source != (Object)null;
				float num = (float)Screen.width * 0.5f;
				float num2 = 32f;
				if (flag)
				{
					Vector3 position = ((Component)ActiveTarget.Source).transform.position;
					Vector3 toItem = position - ((Component)localPlayer).transform.position;
					float magnitude = ((Vector3)(ref toItem)).magnitude;
					float compassAngle = GetCompassAngle(localPlayer, toItem);
					DrawArrow(num, num2, compassAngle);
					float num3 = num2 + 52f;
					string displayName = ActiveTarget.DisplayName;
					GUI.Label(new Rect(num - 121f, num3 + 1f, 242f, 24f), displayName, _nameShadow);
					GUI.Label(new Rect(num - 120f, num3, 242f, 24f), displayName, _nameStyle);
					string text = ((magnitude < 1000f) ? $"{Mathf.RoundToInt(magnitude)}m" : $"{magnitude / 1000f:F1}km");
					float num4 = num3 + 26f;
					GUI.Label(new Rect(num - 121f, num4 + 1f, 242f, 20f), text, _distShadow);
					GUI.Label(new Rect(num - 120f, num4, 242f, 20f), text, _distStyle);
				}
				else
				{
					float num5 = num2 + 16f;
					string displayName2 = ActiveTarget.DisplayName;
					GUI.Label(new Rect(num - 121f, num5 + 1f, 242f, 24f), displayName2, _nameShadow);
					GUI.Label(new Rect(num - 120f, num5, 242f, 24f), displayName2, _nameStyle);
					GUIStyle val = new GUIStyle(_distStyle);
					val.normal.textColor = new Color(0.8f, 0.5f, 0.2f, 0.8f);
					GUI.Label(new Rect(num - 120f, num5 + 26f, 242f, 20f), "out of range — move closer", val);
				}
			}
		}

		private static float GetCompassAngle(Player player, Vector3 toItem)
		{
			//IL_0026: 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_0037: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00b2: 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_006a: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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)
			Camera val = Camera.main;
			if ((Object)(object)val == (Object)null)
			{
				GameCamera instance = GameCamera.instance;
				val = ((instance != null) ? ((Component)instance).GetComponent<Camera>() : null);
			}
			Vector3 val2 = new Vector3(toItem.x, 0f, toItem.z);
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			Vector3 normalized2;
			if (!((Object)(object)val != (Object)null))
			{
				val2 = new Vector3(((Component)player).transform.forward.x, 0f, ((Component)player).transform.forward.z);
				normalized2 = ((Vector3)(ref val2)).normalized;
			}
			else
			{
				val2 = new Vector3(((Component)val).transform.forward.x, 0f, ((Component)val).transform.forward.z);
				normalized2 = ((Vector3)(ref val2)).normalized;
			}
			Vector3 val3 = normalized2;
			Vector3 normalized3;
			if (!((Object)(object)val != (Object)null))
			{
				val2 = new Vector3(((Component)player).transform.right.x, 0f, ((Component)player).transform.right.z);
				normalized3 = ((Vector3)(ref val2)).normalized;
			}
			else
			{
				val2 = new Vector3(((Component)val).transform.right.x, 0f, ((Component)val).transform.right.z);
				normalized3 = ((Vector3)(ref val2)).normalized;
			}
			Vector3 val4 = normalized3;
			float num = Vector3.Dot(normalized, val3);
			float num2 = Vector3.Dot(normalized, val4);
			return Mathf.Atan2(num2, num) * 57.29578f;
		}

		private void DrawArrow(float cx, float ty, float angle)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = (Assets.Loaded ? Assets.MapMarker : null);
			Matrix4x4 matrix = GUI.matrix;
			float num = ty + 16f;
			float num2 = 40f;
			GUIUtility.RotateAroundPivot(angle, new Vector2(cx, num));
			if ((Object)(object)val != (Object)null)
			{
				GUI.color = new Color(1f, 1f, 1f, 0.25f);
				GUI.DrawTexture(new Rect(cx - num2 * 0.5f + 1f, num - num2 * 0.5f + 1f, num2, num2), (Texture)(object)val);
				GUI.color = C_Gold;
				GUI.DrawTexture(new Rect(cx - num2 * 0.5f, num - num2 * 0.5f, num2, num2), (Texture)(object)val);
				GUI.color = Color.white;
			}
			else
			{
				GUIStyle val2 = new GUIStyle
				{
					fontSize = 40,
					alignment = (TextAnchor)4
				};
				val2.normal.background = null;
				val2.normal.textColor = C_Gold;
				GUIStyle val3 = val2;
				GUI.Label(new Rect(cx - 24f, num - 24f, 48f, 48f), "▲", val3);
			}
			GUI.matrix = matrix;
		}

		private static void Fill(float x, float y, float w, float h, Color c)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(new Rect(x, y, w, h), (Texture)(object)MakeTex(c));
		}

		private static Texture2D MakeTex(Color c)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, c);
			val.Apply();
			return val;
		}
	}
	public class LostItemsPanel : MonoBehaviour
	{
		private struct POINT
		{
			public int X;

			public int Y;
		}

		private bool _visible = false;

		private List<TrackedItem> _results = new List<TrackedItem>();

		private Vector2 _scrollPos = Vector2.zero;

		private bool _pendingClose = false;

		private float _closedAt = -10f;

		private const float CloseCooldown = 0.05f;

		private const float PanelW = 370f;

		private const float PanelH = 430f;

		private const float TitleH = 44f;

		private const float FootH = 44f;

		private const float RowH = 54f;

		private const float Pad = 18f;

		private static readonly Color C_White = new Color(1f, 1f, 1f, 1f);

		private static readonly Color C_Yellow = new Color(1f, 0.85f, 0.35f, 1f);

		private static readonly Color C_YellowDim = new Color(0.78f, 0.62f, 0.2f, 1f);

		private static readonly Color C_SubText = new Color(0.75f, 0.75f, 0.75f, 1f);

		private static readonly Color C_Shadow = new Color(0f, 0f, 0f, 0.8f);

		private static readonly Color C_DarkBox = new Color(0.06f, 0.04f, 0.02f, 0.88f);

		private static readonly Color C_RowSelect = new Color(0.8f, 0.55f, 0.05f, 0.35f);

		private static readonly Color C_RowHover = new Color(1f, 0.75f, 0.2f, 0.12f);

		private static readonly Color C_RowLine = new Color(1f, 0.85f, 0.35f, 0.08f);

		private static readonly Color C_BtnNorm = new Color(0.15f, 0.11f, 0.04f, 0.95f);

		private static readonly Color C_BtnHover = new Color(0.3f, 0.22f, 0.06f, 1f);

		private static readonly Color C_BtnBorder = new Color(0.55f, 0.42f, 0.12f, 1f);

		private GUIStyle _titleStyle;

		private GUIStyle _countStyle;

		private GUIStyle _itemNameStyle;

		private GUIStyle _itemSubStyle;

		private GUIStyle _btnStyle;

		private GUIStyle _btnActiveStyle;

		private GUIStyle _emptyStyle;

		private bool _stylesBuilt = false;

		private bool _fontFound = false;

		public static LostItemsPanel Instance { get; private set; }

		public bool IsVisible => _visible;

		public bool IsBlockingInput => _visible || Time.time - _closedAt < 0.05f || (!_visible && Time.time - _closedAt < 0.05f && (Input.GetMouseButton(0) || Input.GetMouseButton(1)));

		[DllImport("user32.dll")]
		private static extern bool SetCursorPos(int x, int y);

		[DllImport("user32.dll")]
		private static extern bool GetCursorPos(out POINT p);

		private static void WarpCursor()
		{
			if (GetCursorPos(out var p))
			{
				SetCursorPos(p.X, p.Y);
			}
		}

		private void Awake()
		{
			Instance = this;
		}

		private void BuildStyles()
		{
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Expected O, but got Unknown
			//IL_029e: Expected O, but got Unknown
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Expected O, but got Unknown
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: 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_036b: 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_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Expected O, but got Unknown
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Expected O, but got Unknown
			//IL_03d4: Expected O, but got Unknown
			//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_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Expected O, but got Unknown
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Expected O, but got Unknown
			if ((_stylesBuilt && _fontFound) || !Assets.Loaded)
			{
				return;
			}
			_stylesBuilt = false;
			Font val = null;
			try
			{
				Type type = Type.GetType("TMPro.TMP_Text, Unity.TextMeshPro") ?? Type.GetType("TMPro.TMP_Text, TextMeshPro");
				if (type != null)
				{
					Object[] array = Object.FindObjectsOfType(type);
					PropertyInfo property = type.GetProperty("font");
					HashSet<string> hashSet = new HashSet<string>();
					Object[] array2 = array;
					foreach (Object obj in array2)
					{
						object obj2 = property?.GetValue(obj);
						if (obj2 == null)
						{
							continue;
						}
						object? obj3 = obj2.GetType().GetProperty("sourceFontFile")?.GetValue(obj2);
						Font val2 = (Font)((obj3 is Font) ? obj3 : null);
						string text = obj2.GetType().GetProperty("name")?.GetValue(obj2)?.ToString() ?? "";
						if (hashSet.Add(text))
						{
							EquipmentFinderPlugin.Log.LogInfo((object)("TMP font asset: " + text + (((Object)(object)val2 != (Object)null) ? (" -> " + ((Object)val2).name) : " (no source font)")));
						}
						if ((Object)(object)val2 != (Object)null)
						{
							if (text.ToLower().Contains("serif"))
							{
								val = val2;
							}
							else if ((Object)(object)val == (Object)null)
							{
								val = val2;
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				EquipmentFinderPlugin.Log.LogWarning((object)("Font search error: " + ex.Message));
			}
			if ((Object)(object)val != (Object)null)
			{
				EquipmentFinderPlugin.Log.LogInfo((object)("Using font: " + ((Object)val).name));
			}
			else
			{
				EquipmentFinderPlugin.Log.LogInfo((object)"No TMP source font found, using default");
			}
			GUIStyle val3 = new GUIStyle
			{
				fontSize = 17,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4,
				font = val
			};
			val3.normal.background = null;
			val3.normal.textColor = C_Yellow;
			_titleStyle = val3;
			GUIStyle val4 = new GUIStyle
			{
				fontSize = 11,
				alignment = (TextAnchor)5
			};
			val4.normal.background = null;
			val4.normal.textColor = C_YellowDim;
			val4.padding = new RectOffset(0, 10, 0, 0);
			_countStyle = val4;
			GUIStyle val5 = new GUIStyle
			{
				fontSize = 13,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3,
				font = val
			};
			val5.normal.background = null;
			val5.normal.textColor = C_White;
			_itemNameStyle = val5;
			GUIStyle val6 = new GUIStyle
			{
				fontSize = 11,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3
			};
			val6.normal.background = null;
			val6.normal.textColor = C_SubText;
			_itemSubStyle = val6;
			GUIStyle val7 = new GUIStyle
			{
				fontSize = 11,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			val7.normal.background = Assets.BtnNormal;
			val7.normal.textColor = C_Yellow;
			val7.hover.background = Assets.BtnHover;
			val7.hover.textColor = C_White;
			val7.active.background = Assets.BtnHover;
			val7.active.textColor = C_White;
			val7.border = new RectOffset(6, 6, 6, 6);
			val7.padding = new RectOffset(4, 4, 3, 3);
			_btnStyle = val7;
			GUIStyle val8 = new GUIStyle(_btnStyle);
			val8.normal.background = Assets.BtnHover;
			val8.normal.textColor = C_White;
			_btnActiveStyle = val8;
			GUIStyle val9 = new GUIStyle
			{
				fontSize = 12,
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)2,
				wordWrap = true
			};
			val9.normal.background = null;
			val9.normal.textColor = C_SubText;
			_emptyStyle = val9;
			_fontFound = (Object)(object)val != (Object)null;
			_stylesBuilt = true;
		}

		private void Update()
		{
			//IL_0082: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			KeyboardShortcut value;
			if (_visible)
			{
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				if (_pendingClose && !Input.GetMouseButton(0) && !Input.GetMouseButton(1))
				{
					_pendingClose = false;
					Toggle();
					return;
				}
				if (!Input.GetKeyDown((KeyCode)27))
				{
					value = EquipmentFinderPlugin.LocateHotkey.Value;
					if (!Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey))
					{
						return;
					}
				}
				Toggle();
			}
			else
			{
				value = EquipmentFinderPlugin.LocateHotkey.Value;
				if (Input.GetKeyDown(((KeyboardShortcut)(ref value)).MainKey) && (Object)(object)Player.m_localPlayer != (Object)null && !IsChatOrConsoleOpen())
				{
					Toggle();
				}
			}
		}

		private void OnGUI()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: 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_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Invalid comparison between Unknown and I4
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Invalid comparison between Unknown and I4
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Invalid comparison between Unknown and I4
			if (!_visible)
			{
				return;
			}
			BuildStyles();
			if (!_stylesBuilt)
			{
				return;
			}
			float num = Mathf.Round(((float)Screen.width - 370f) * 0.5f);
			float num2 = Mathf.Round(((float)Screen.height - 430f) * 0.5f);
			GUI.DrawTexture(new Rect(num, num2, 370f, 430f), (Texture)(object)Assets.PanelBg, (ScaleMode)0);
			GUI.DrawTexture(new Rect(num + 4f, num2 + 2f, 362f, 42f), (Texture)(object)Assets.PanelHeader, (ScaleMode)0);
			Fill(num + 4f, num2 + 2f, 362f, 42f, new Color(0f, 0f, 0f, 0.25f));
			ShadowLabel(new Rect(num, num2, 370f, 44f), "Lost Equipment", _titleStyle);
			GUI.Label(new Rect(num, num2, 328f, 44f), string.Format("{0} item{1}", _results.Count, (_results.Count != 1) ? "s" : ""), _countStyle);
			GUI.DrawTexture(new Rect(num, num2 + 44f, 370f, 4f), (Texture)(object)Assets.Separator, (ScaleMode)0);
			if (GUI.Button(new Rect(num + 370f - 34f, num2 + 8f, 26f, 26f), "X", _btnStyle))
			{
				_pendingClose = true;
				return;
			}
			float num3 = num + 18f;
			float num4 = num2 + 44f + 4f + 18f;
			float num5 = 334f;
			float num6 = 302f;
			Fill(num3, num4, num5, num6, C_DarkBox);
			if (_results.Count == 0)
			{
				GUI.Label(new Rect(num3 + 10f, num4 + 10f, num5 - 20f, num6 - 20f), "No tagged equipment found nearby.\n\nItems must be dropped while the mod\nis installed to appear here.", _emptyStyle);
			}
			else
			{
				_scrollPos = GUI.BeginScrollView(new Rect(num3, num4, num5, num6), _scrollPos, new Rect(0f, 0f, num5 - 16f, (float)_results.Count * 54f));
				DrawRows(num5);
				GUI.EndScrollView();
			}
			float num7 = num2 + 430f - 44f;
			GUI.DrawTexture(new Rect(num, num7, 370f, 4f), (Texture)(object)Assets.Separator, (ScaleMode)0);
			GUI.DrawTexture(new Rect(num + 4f, num7 + 2f, 362f, 40f), (Texture)(object)Assets.PanelHeader, (ScaleMode)0);
			Fill(num + 4f, num7 + 2f, 362f, 40f, new Color(0f, 0f, 0f, 0.25f));
			if (GUI.Button(new Rect(num + 12f, num7 + 10f, 100f, 24f), "REFRESH", _btnStyle))
			{
				Refresh();
			}
			EventType type = Event.current.type;
			if ((int)type == 0 || (int)type == 1 || (int)type == 3 || (int)type == 6)
			{
				Event.current.Use();
			}
		}

		private void DrawRows(float bw)
		{
			//IL_0075: 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_0100: 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_00d7: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: 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_02a7: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			for (int i = 0; i < _results.Count; i++)
			{
				TrackedItem trackedItem = _results[i];
				if ((Object)(object)trackedItem.Source == (Object)null)
				{
					continue;
				}
				float num = (float)i * 54f;
				bool flag = (Object)(object)HUDTracker.Instance != (Object)null && HUDTracker.Instance.ActiveTarget == trackedItem;
				if (flag)
				{
					Fill(0f, num, bw - 16f, 54f, C_RowSelect);
				}
				else if (i % 2 == 1)
				{
					Fill(0f, num, bw - 16f, 54f, new Color(1f, 1f, 1f, 0.03f));
				}
				if (flag)
				{
					Fill(0f, num, 3f, 54f, C_Yellow);
				}
				Fill(0f, num + 54f - 1f, bw - 16f, 1f, C_RowLine);
				ShadowLabel(new Rect(11f, num + 7f, 190f, 20f), trackedItem.DisplayName, _itemNameStyle);
				if ((Object)(object)localPlayer != (Object)null && (Object)(object)trackedItem.Source != (Object)null)
				{
					Vector3 d = ((Component)trackedItem.Source).transform.position - ((Component)localPlayer).transform.position;
					float magnitude = ((Vector3)(ref d)).magnitude;
					string arg = Cardinal(d);
					GUI.Label(new Rect(11f, num + 29f, 190f, 18f), $"{Mathf.RoundToInt(magnitude)}m  •  {arg}", _itemSubStyle);
				}
				else if ((Object)(object)trackedItem.Source == (Object)null)
				{
					GUI.Label(new Rect(11f, num + 29f, 190f, 18f), "out of range", _itemSubStyle);
				}
				bool flag2 = PinManager.IsPinned(trackedItem.Source);
				if (GUI.Button(new Rect(bw - 16f - 112f, num + 14f, 50f, 26f), flag2 ? "UNPIN" : "PIN", flag2 ? _btnActiveStyle : _btnStyle))
				{
					if (flag2)
					{
						PinManager.RemovePin(trackedItem.Source);
					}
					else
					{
						PinManager.AddPin(trackedItem);
					}
				}
				if (GUI.Button(new Rect(bw - 16f - 58f, num + 14f, 52f, 26f), flag ? "STOP" : "TRACK", flag ? _btnActiveStyle : _btnStyle) && (Object)(object)HUDTracker.Instance != (Object)null)
				{
					if (flag)
					{
						HUDTracker.Instance.ClearTarget();
					}
					else
					{
						HUDTracker.Instance.SetTarget(trackedItem);
					}
				}
			}
		}

		private static bool IsChatOrConsoleOpen()
		{
			if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())
			{
				return true;
			}
			if ((Object)(object)Console.instance != (Object)null && Console.IsVisible())
			{
				return true;
			}
			return false;
		}

		public void Toggle()
		{
			_visible = !_visible;
			if (_visible)
			{
				Refresh();
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
				WarpCursor();
			}
			else
			{
				_closedAt = Time.time;
				WarpCursor();
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
			}
		}

		public void Refresh()
		{
			//IL_000d: 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)
			_results = ItemScanner.ScanForOwnedItems();
			_scrollPos = Vector2.zero;
		}

		private static string Cardinal(Vector3 d)
		{
			//IL_0001: 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)
			float num = Mathf.Atan2(d.x, d.z) * 57.29578f;
			if (num < 0f)
			{
				num += 360f;
			}
			if (num < 22.5f || num >= 337.5f)
			{
				return "N";
			}
			if (num < 67.5f)
			{
				return "NE";
			}
			if (num < 112.5f)
			{
				return "E";
			}
			if (num < 157.5f)
			{
				return "SE";
			}
			if (num < 202.5f)
			{
				return "S";
			}
			if (num < 247.5f)
			{
				return "SW";
			}
			if (num < 292.5f)
			{
				return "W";
			}
			return "NW";
		}

		private static void ShadowLabel(Rect r, string text, GUIStyle style)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_000e: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(style);
			val.normal.textColor = C_Shadow;
			GUI.Label(new Rect(((Rect)(ref r)).x + 1f, ((Rect)(ref r)).y + 1f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, val);
			GUI.Label(r, text, style);
		}

		private static void DrawBorder(float x, float y, float w, float h, Color c, float t)
		{
			//IL_0006: 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_0025: 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)
			Fill(x, y, w, t, c);
			Fill(x, y + h - t, w, t, c);
			Fill(x, y, t, h, c);
			Fill(x + w - t, y, t, h, c);
		}

		private static void Fill(float x, float y, float w, float h, Color c)
		{
			//IL_0004: 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)
			GUI.DrawTexture(new Rect(x, y, w, h), (Texture)(object)T(c));
		}

		private static Texture2D T(Color c)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, c);
			val.Apply();
			return val;
		}
	}
}
namespace DroppedEquipmentFinder.Core
{
	public static class Assets
	{
		public static Texture2D PanelBg { get; private set; }

		public static Texture2D PanelHeader { get; private set; }

		public static Texture2D BtnNormal { get; private set; }

		public static Texture2D BtnHover { get; private set; }

		public static Texture2D Separator { get; private set; }

		public static Texture2D MapMarker { get; private set; }

		public static Font BodyFont { get; private set; }

		public static bool Loaded { get; private set; }

		public static void Load()
		{
			if (!Loaded)
			{
				PanelBg = LoadTex("woodpanel_crafting.png");
				PanelHeader = LoadTex("woodpanel_flik.png");
				BtnNormal = LoadTex("button_tab.png");
				BtnHover = LoadTex("button_tab_hover.png");
				Separator = LoadTex("panel_separator.png");
				MapMarker = LoadTex("map_marker.png");
				BodyFont = LoadFont("NotoSerif-Regular.ttf");
				Loaded = true;
				EquipmentFinderPlugin.Log.LogInfo((object)"Assets loaded.");
			}
		}

		private static Texture2D LoadTex(string name)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			byte[] array = ReadResource(name);
			if (array == null)
			{
				return Fallback(name);
			}
			Texture2D val = new Texture2D(2, 2);
			try
			{
				Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule");
				if (type != null)
				{
					MethodInfo method = type.GetMethod("LoadImage", new Type[2]
					{
						typeof(Texture2D),
						typeof(byte[])
					});
					if (method != null)
					{
						method.Invoke(null, new object[2] { val, array });
					}
				}
				else
				{
					MethodInfo method2 = typeof(Texture2D).GetMethod("LoadImage", new Type[1] { typeof(byte[]) });
					if (method2 != null)
					{
						method2.Invoke(val, new object[1] { array });
					}
				}
			}
			catch (Exception ex)
			{
				EquipmentFinderPlugin.Log.LogWarning((object)("Failed to decode " + name + ": " + ex.Message));
				return Fallback(name);
			}
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return val;
		}

		private static Font LoadFont(string name)
		{
			return null;
		}

		private static byte[] ReadResource(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = "DroppedEquipmentFinder.Resources." + filename;
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				EquipmentFinderPlugin.Log.LogWarning((object)("Resource not found: " + text));
				return null;
			}
			MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static Texture2D Fallback(string name)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, new Color(0.1f, 0.08f, 0.04f));
			val.Apply();
			return val;
		}
	}
	public class TrackedItem
	{
		public string ItemName { get; set; }

		public string DisplayName { get; set; }

		public Vector3 WorldPos { get; set; }

		public ItemDrop Source { get; set; }

		public PinData Pin { get; set; }
	}
	public static class ItemScanner
	{
		private const string OwnerKey = "equipmentfinder_owner";

		private static readonly Dictionary<string, string> DisplayNames = new Dictionary<string, string>
		{
			{ "ArmorBronzeChest", "Bronze plate cuirass" },
			{ "ArmorBronzeLegs", "Bronze plate leggings" },
			{ "ArmorFenringChest", "Fenris coat" },
			{ "ArmorFenringLegs", "Fenris leggings" },
			{ "ArmorIronChest", "Iron scale mail" },
			{ "ArmorIronLegs", "Iron greaves" },
			{ "ArmorLeatherChest", "Leather tunic" },
			{ "ArmorLeatherLegs", "Leather pants" },
			{ "ArmorPaddedCuirass", "Padded cuirass" },
			{ "ArmorPaddedGreaves", "Padded greaves" },
			{ "ArmorRagsChest", "Rag tunic" },
			{ "ArmorRagsLegs", "Rag pants" },
			{ "ArmorRootChest", "Root harnesk" },
			{ "ArmorRootLegs", "Root leggings" },
			{ "ArmorTrollLeatherChest", "Troll leather tunic" },
			{ "ArmorTrollLeatherLegs", "Troll leather pants" },
			{ "ArmorWolfChest", "Wolf armor chest" },
			{ "ArmorWolfLegs", "Wolf armor legs" },
			{ "HelmetBronze", "Bronze helmet" },
			{ "HelmetDrake", "Drake helmet" },
			{ "HelmetDverger", "Dverger circlet" },
			{ "HelmetFenring", "Fenris hood" },
			{ "HelmetIron", "Iron helmet" },
			{ "HelmetLeather", "Leather helmet" },
			{ "HelmetOdin", "Hood of Odin" },
			{ "HelmetPadded", "Padded helmet" },
			{ "HelmetRoot", "Root mask" },
			{ "HelmetTrollLeather", "Troll leather helmet" },
			{ "HelmetYule", "Yule hat" },
			{ "CapeDeerHide", "Deer hide cape" },
			{ "CapeLinen", "Linen cape" },
			{ "CapeLox", "Lox cape" },
			{ "CapeOdin", "Cape of Odin" },
			{ "CapeTest", "CAPE TEST" },
			{ "CapeTrollHide", "Troll hide cape" },
			{ "CapeWolf", "Wolf fur cape" },
			{ "BeltStrength", "Megingjord" },
			{ "Wishbone", "Wishbone" },
			{ "Demister", "Wisplight" },
			{ "AxeBlackMetal", "Black metal axe" },
			{ "AxeBronze", "Bronze axe" },
			{ "AxeFlint", "Flint axe" },
			{ "AxeIron", "Iron axe" },
			{ "AxeStone", "Stone axe" },
			{ "Battleaxe", "Battleaxe" },
			{ "BattleaxeCrystal", "Crystal battleaxe" },
			{ "AtgeirBlackmetal", "Black metal atgeir" },
			{ "AtgeirBronze", "Bronze atgeir" },
			{ "AtgeirIron", "Iron atgeir" },
			{ "Bow", "Crude bow" },
			{ "BowDraugrFang", "Draugr fang" },
			{ "BowFineWood", "Finewood bow" },
			{ "BowHuntsman", "Huntsman bow" },
			{ "BowSpineSnap", "Spinesnap" },
			{ "KnifeBlackMetal", "Black metal knife" },
			{ "KnifeChitin", "Abyssal razor" },
			{ "KnifeCopper", "Copper knife" },
			{ "KnifeFlint", "Flint knife" },
			{ "KnifeSilver", "Silver knife" },
			{ "MaceBronze", "Bronze mace" },
			{ "MaceIron", "Iron mace" },
			{ "MaceNeedle", "Porcupine" },
			{ "MaceSilver", "Frostner" },
			{ "SledgeIron", "Iron sledge" },
			{ "SledgeStagbreaker", "Stagbreaker" },
			{ "SpearBronze", "Bronze spear" },
			{ "SpearChitin", "Abyssal harpoon" },
			{ "SpearElderbark", "Ancient bark spear" },
			{ "SpearFlint", "Flint spear" },
			{ "SpearWolfFang", "Fang spear" },
			{ "SwordBlackmetal", "Black metal sword" },
			{ "SwordBronze", "Bronze sword" },
			{ "SwordCheat", "Cheat sword" },
			{ "SwordIron", "Iron sword" },
			{ "SwordIronFire", "Dyrnwyn" },
			{ "SwordSilver", "Silver sword" },
			{ "ShieldBanded", "Banded shield" },
			{ "ShieldBlackmetal", "Black metal shield" },
			{ "ShieldBlackmetalTower", "Black metal tower shield" },
			{ "ShieldBoneTower", "Bone tower shield" },
			{ "ShieldBronzeBuckler", "Bronze buckler" },
			{ "ShieldIronBuckler", "Iron buckler" },
			{ "ShieldIronSquare", "Iron shield" },
			{ "ShieldIronTower", "Iron tower shield" },
			{ "ShieldKnight", "Knight shield" },
			{ "ShieldSerpentscale", "Serpent scale shield" },
			{ "ShieldSilver", "Silver shield" },
			{ "ShieldWood", "Wood shield" },
			{ "ShieldWoodTower", "Wood tower shield" },
			{ "FistFenrirClaw", "Flesh Rippers" },
			{ "Cultivator", "Cultivator" },
			{ "FishingRod", "Fishing rod" },
			{ "Hammer", "Hammer" },
			{ "Hoe", "Hoe" },
			{ "PickaxeAntler", "Antler pickaxe" },
			{ "PickaxeBronze", "Bronze pickaxe" },
			{ "PickaxeIron", "Iron pickaxe" },
			{ "PickaxeStone", "Stone pickaxe" },
			{ "Club", "Club" },
			{ "Tankard", "Tankard" },
			{ "TankardOdin", "Mead horn of Odin" },
			{ "Torch", "Torch" }
		};

		public static string GetDisplayName(string prefabName)
		{
			if (DisplayNames.TryGetValue(prefabName, out var value))
			{
				return value;
			}
			StringBuilder stringBuilder = new StringBuilder();
			foreach (char c in prefabName)
			{
				if (char.IsUpper(c) && stringBuilder.Length > 0)
				{
					stringBuilder.Append(' ');
				}
				stringBuilder.Append(c);
			}
			return stringBuilder.ToString();
		}

		public static List<TrackedItem> ScanForOwnedItems()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			List<TrackedItem> list = new List<TrackedItem>();
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return list;
			}
			string localPlayerID = GetLocalPlayerID();
			float value = EquipmentFinderPlugin.MaxSearchRadius.Value;
			Vector3 position = ((Component)localPlayer).transform.position;
			ItemDrop[] array = Object.FindObjectsOfType<ItemDrop>();
			ItemDrop[] array2 = array;
			foreach (ItemDrop val in array2)
			{
				if ((Object)(object)val == (Object)null || val.m_itemData == null)
				{
					continue;
				}
				float num = Vector3.Distance(position, ((Component)val).transform.position);
				if (num > value)
				{
					continue;
				}
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid())
				{
					string @string = component.GetZDO().GetString("equipmentfinder_owner", string.Empty);
					if (!string.IsNullOrEmpty(@string) && !string.IsNullOrEmpty(localPlayerID) && !(localPlayerID == "unknown") && !(@string != localPlayerID))
					{
						string text = ((Object)((Component)val).gameObject).name.Replace("(Clone)", "").Trim();
						list.Add(new TrackedItem
						{
							ItemName = text,
							DisplayName = GetDisplayName(text),
							WorldPos = ((Component)val).transform.position,
							Source = val
						});
					}
				}
			}
			return list;
		}

		public static void TagDroppedItem(ItemDrop drop)
		{
			if (!((Object)(object)drop == (Object)null))
			{
				ZNetView component = ((Component)drop).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid())
				{
					component.GetZDO().Set("equipmentfinder_owner", GetLocalPlayerID());
				}
			}
		}

		public static string GetLocalPlayerID()
		{
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				ZNetView component = ((Component)Player.m_localPlayer).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid())
				{
					return component.GetZDO().GetLong(ZDOVars.s_playerID, 0L).ToString();
				}
			}
			return "unknown";
		}
	}
	public static class PinManager
	{
		private static readonly Dictionary<ItemDrop, PinData> _activePins = new Dictionary<ItemDrop, PinData>();

		public static void AddPin(TrackedItem item)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item.Source == (Object)null || (Object)(object)Minimap.instance == (Object)null || _activePins.ContainsKey(item.Source))
			{
				return;
			}
			PinData val = Minimap.instance.AddPin(item.WorldPos, (PinType)3, item.DisplayName, false, false, 0L, default(PlatformUserID));
			try
			{
				string text = ((Object)((Component)item.Source).gameObject).name.Replace("(Clone)", "").Trim();
				ObjectDB instance = ObjectDB.instance;
				GameObject val2 = ((instance != null) ? instance.GetItemPrefab(text) : null);
				ItemDrop val3 = ((val2 != null) ? val2.GetComponent<ItemDrop>() : null);
				object obj;
				if (val3 == null)
				{
					obj = null;
				}
				else
				{
					ItemData itemData = val3.m_itemData;
					if (itemData == null)
					{
						obj = null;
					}
					else
					{
						SharedData shared = itemData.m_shared;
						if (shared == null)
						{
							obj = null;
						}
						else
						{
							Sprite[] icons = shared.m_icons;
							obj = ((icons != null) ? icons[0] : null);
						}
					}
				}
				Sprite val4 = (Sprite)obj;
				if ((Object)(object)val4 != (Object)null)
				{
					val.m_icon = val4;
				}
			}
			catch
			{
			}
			_activePins[item.Source] = val;
			item.Pin = val;
		}

		public static void RemovePin(ItemDrop drop)
		{
			if (!((Object)(object)drop == (Object)null) && !((Object)(object)Minimap.instance == (Object)null) && _activePins.TryGetValue(drop, out var value))
			{
				Minimap.instance.RemovePin(value);
				_activePins.Remove(drop);
			}
		}

		public static void RemoveAllPins()
		{
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			foreach (KeyValuePair<ItemDrop, PinData> activePin in _activePins)
			{
				Minimap.instance.RemovePin(activePin.Value);
			}
			_activePins.Clear();
		}

		public static bool IsPinned(ItemDrop drop)
		{
			return _activePins.ContainsKey(drop);
		}
	}
}