Decompiled source of HeimTracker v1.0.0

BepInEx/plugins/HeimTracker/HeimTracker.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HeimTracker.Core;
using HeimTracker.Core.PinManagers;
using HeimTracker.Core.Tracking;
using HeimTracker.Models;
using HeimTracker.UI;
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.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HeimTracker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HeimTracker")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8e0d6812-c80a-4f2c-a0a3-1a47b8270a86")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
internal class ResourcePinModel
{
	internal ZDOID ZdoId { get; }

	internal TrackedResourceDefinition ResourceDefinition { get; }

	internal string IconItemPrefabName { get; }

	internal Vector3 Position { get; }

	internal PinData Pin { get; set; }

	internal RectTransform LastSizedUiElement { get; set; }

	internal float LastAppliedSize { get; set; } = -1f;

	internal ResourcePinModel(ZDOID zdoId, TrackedResourceDefinition resourceDefinition, string iconItemPrefabName, Vector3 position)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0029: Unknown result type (might be due to invalid IL or missing references)
		ZdoId = zdoId;
		ResourceDefinition = resourceDefinition;
		IconItemPrefabName = iconItemPrefabName;
		Position = position;
	}
}
namespace HeimTracker
{
	internal class DungeonPinModel
	{
		internal Theme Theme { get; }

		internal string LocationPrefabName { get; }

		internal Vector3 Position { get; }

		internal bool IsChecked { get; set; }

		internal PinData Pin { get; set; }

		internal DungeonPinModel(Theme theme, string locationPrefabName, 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)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Theme = theme;
			LocationPrefabName = locationPrefabName;
			Position = position;
		}
	}
	[BepInPlugin("HeimTracker.Valheim", "HeimTracker", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PluginGuid = "HeimTracker.Valheim\0\0\0\0";

		private const string PluginName = "HeimTracker\0\0\0\0\0\0\0";

		private const string PluginVersion = "1.0.0";

		private Harmony _harmonyInstance;

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private void Awake()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			PluginConfig.Initialize(((BaseUnityPlugin)this).Config);
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmonyInstance = new Harmony("HeimTracker.Valheim");
			_harmonyInstance.PatchAll(executingAssembly);
			Log.LogInfo((object)"HeimTracker v1.0.0 loaded.");
		}

		private void OnDestroy()
		{
			Log.LogInfo((object)"HeimTracker v1.0.0 unloaded.");
			Harmony harmonyInstance = _harmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
			_harmonyInstance = null;
			Instance = null;
			Log = null;
		}
	}
	internal static class PluginConfig
	{
		private sealed class ConfigurationManagerAttributes
		{
			public int? Order;
		}

		private const string GeneralSection = "General";

		private const string ResourcesSection = "Resources To Track";

		private const string DungeonsSection = "Dungeons To Track";

		private const string TrackingModeSection = "Tracking Mode";

		private const string DungeonLabelsSection = "Dungeon Labels";

		private const string DepositLabelsSection = "Deposit Labels";

		private const int HideLabelOrder = 1000;

		private const int LabelOrder = 900;

		internal static readonly Dictionary<string, ConfigEntry<bool>> ResourceConfigs = new Dictionary<string, ConfigEntry<bool>>();

		internal static readonly Dictionary<Theme, ConfigEntry<bool>> DungeonConfigs = new Dictionary<Theme, ConfigEntry<bool>>();

		internal static readonly Dictionary<string, ConfigEntry<string>> DepositLabelConfigs = new Dictionary<string, ConfigEntry<string>>();

		internal static readonly Dictionary<Theme, ConfigEntry<string>> DungeonLabelConfigs = new Dictionary<Theme, ConfigEntry<string>>();

		internal static ConfigEntry<bool> IsModEnabled { get; private set; }

		internal static ConfigEntry<float> TrackingRange { get; private set; }

		internal static ConfigEntry<TrackingModeEnum> TrackingMode { get; private set; }

		internal static ConfigEntry<bool> HideDungeonLabels { get; private set; }

		internal static ConfigEntry<bool> HideDepositLabels { get; private set; }

		internal static void Initialize(ConfigFile config)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected O, but got Unknown
			IsModEnabled = config.Bind<bool>("General", "Enable", true, "Enable or disable the HeimTracker mod.");
			TrackingMode = config.Bind<TrackingModeEnum>("Tracking Mode", "Tracking Mode", TrackingModeEnum.ZoneBased, "Choose zone or range tracking.");
			TrackingMode.SettingChanged += delegate
			{
				MapTrackingScanner.HandleTrackingModeChanged();
			};
			TrackingRange = config.Bind<float>("Tracking Mode", "Tracking Range", 50f, new ConfigDescription("Maximum distance in meters from the player to track resources and dungeons when using RangeScanner mode.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 2000f), Array.Empty<object>()));
			TrackingRange.SettingChanged += delegate
			{
				MapTrackingScanner.ForceRescan();
			};
			HideDungeonLabels = config.Bind<bool>("Dungeon Labels", "Hide Dungeon Labels", false, new ConfigDescription("Hide labels on tracked dungeon pins.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1000
				}
			}));
			HideDungeonLabels.SettingChanged += delegate
			{
				DungeonPinManager.UpdateDungeonLabels();
			};
			BindDungeonLabel(config, (Theme)8, "Burial Chamber");
			BindDungeonLabel(config, (Theme)2, "Sunken Crypt");
			BindDungeonLabel(config, (Theme)4, "Frost Cave");
			BindDungeonLabel(config, (Theme)128, "Infested Mine");
			BindDungeonLabel(config, (Theme)131072, "Morkhalla");
			BindDungeonLabel(config, (Theme)16384, "Winding Tunnel");
			HideDepositLabels = config.Bind<bool>("Deposit Labels", "Hide Deposit Labels", false, new ConfigDescription("Hide labels on tracked deposit pins.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 1000
				}
			}));
			HideDepositLabels.SettingChanged += delegate
			{
				ResourcePinManager.UpdateDepositLabels();
			};
			foreach (TrackedResourceDefinition item in TrackedResources.AllTrackedResources.OrderBy((TrackedResourceDefinition resource) => resource.SortOrder))
			{
				BindResource(config, item.ResourcePrefabName, item.DisplayName);
				if (item.ResourceType == TrackedResourceTypeEnum.Deposit)
				{
					BindDepositLabel(config, item);
				}
			}
			BindDungeon(config, (Theme)8, "Burial Chambers");
			BindDungeon(config, (Theme)2, "Sunken Crypts");
			BindDungeon(config, (Theme)4, "Frost Caves");
			BindDungeon(config, (Theme)128, "Infested Mines");
			BindDungeon(config, (Theme)131072, "Morkhalla");
			BindDungeon(config, (Theme)16384, "Winding Tunnel");
			BindDungeonLabel(config, (Theme)536870912, "Charred Fortress");
			BindDungeonLabel(config, (Theme)1073741824, "Putrid Hole");
			BindDungeon(config, (Theme)536870912, "Charred Fortresses");
			BindDungeon(config, (Theme)1073741824, "Putrid Holes");
		}

		internal static bool IsResourceTrackingEnabled(string prefabName)
		{
			if (IsModEnabled.Value && ResourceConfigs.TryGetValue(prefabName, out var value))
			{
				return value.Value;
			}
			return false;
		}

		internal static bool IsDungeonTrackingEnabled(Theme theme)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (IsModEnabled.Value && DungeonConfigs.TryGetValue(theme, out var value))
			{
				return value.Value;
			}
			return false;
		}

		internal static string GetDepositLabel(string prefabName)
		{
			if (HideDepositLabels.Value)
			{
				return string.Empty;
			}
			if (!DepositLabelConfigs.TryGetValue(prefabName, out var value))
			{
				return string.Empty;
			}
			return value.Value;
		}

		internal static string GetDungeonLabel(Theme theme)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (HideDungeonLabels.Value)
			{
				return string.Empty;
			}
			if (!DungeonLabelConfigs.TryGetValue(theme, out var value))
			{
				return string.Empty;
			}
			return value.Value;
		}

		private static void BindResource(ConfigFile config, string prefabName, string displayName)
		{
			ConfigEntry<bool> entry = config.Bind<bool>("Resources To Track", "Track " + displayName, true, "Enable or disable tracking for " + displayName + ".");
			entry.SettingChanged += delegate
			{
				HeimTrackerMapOverlay.HandleResourceTrackingChanged(prefabName, entry.Value);
				PickableResourcePinService.HandleResourceTrackingChanged(prefabName, entry.Value);
				OreResourcePinService.HandleResourceTrackingChanged(prefabName, entry.Value);
				ContainerResourcePinService.HandleResourceTrackingChanged(prefabName, entry.Value);
			};
			ResourceConfigs[prefabName] = entry;
		}

		private static void BindDepositLabel(ConfigFile config, TrackedResourceDefinition resource)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			ConfigEntry<string> val = config.Bind<string>("Deposit Labels", resource.DisplayName + " Label", resource.DisplayName, new ConfigDescription("Label displayed for " + resource.DisplayName + " deposits.", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 900
				}
			}));
			val.SettingChanged += delegate
			{
				ResourcePinManager.UpdateDepositLabels();
			};
			DepositLabelConfigs[resource.ResourcePrefabName] = val;
		}

		private static void BindDungeonLabel(ConfigFile config, Theme theme, string displayName)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<string> val = config.Bind<string>("Dungeon Labels", displayName + " Label", displayName, new ConfigDescription("Label displayed for " + displayName + ".", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Order = 900
				}
			}));
			val.SettingChanged += delegate
			{
				DungeonPinManager.UpdateDungeonLabels();
			};
			DungeonLabelConfigs[theme] = val;
		}

		private static void BindDungeon(ConfigFile config, Theme theme, string displayName)
		{
			//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)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<bool> entry = config.Bind<bool>("Dungeons To Track", "Track " + displayName, true, "Enable or disable tracking for " + displayName + ".");
			entry.SettingChanged += delegate
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				HeimTrackerMapOverlay.HandleDungeonTrackingChanged(theme, entry.Value);
				DungeonPinManager.HandleDungeonTrackingChanged(theme, entry.Value);
			};
			DungeonConfigs[theme] = entry;
		}
	}
}
namespace HeimTracker.UI
{
	internal class HeimTrackerDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler
	{
		private RectTransform _rectTransform;

		private Vector2 _startPanelPosition;

		private Vector2 _startMousePosition;

		private void Awake()
		{
			ref RectTransform rectTransform = ref _rectTransform;
			Transform parent = ((Component)this).transform.parent;
			rectTransform = (RectTransform)(object)((parent is RectTransform) ? parent : null);
		}

		public void OnBeginDrag(PointerEventData eventData)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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)
			if (!((Object)(object)_rectTransform == (Object)null))
			{
				_startPanelPosition = _rectTransform.anchoredPosition;
				_startMousePosition = eventData.position;
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_002d: 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)
			if (!((Object)(object)_rectTransform == (Object)null))
			{
				Vector2 val = eventData.position - _startMousePosition;
				_rectTransform.anchoredPosition = _startPanelPosition + val;
			}
		}
	}
	internal static class HeimTrackerMapOverlay
	{
		private static GameObject _panel;

		private static readonly Dictionary<string, Toggle> ResourceToggles = new Dictionary<string, Toggle>();

		private static readonly Dictionary<Theme, Toggle> DungeonToggles = new Dictionary<Theme, Toggle>();

		internal static void Create()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_panel != (Object)null) && !((Object)(object)Minimap.instance == (Object)null) && !((Object)(object)Minimap.instance.m_largeRoot == (Object)null))
			{
				_panel = new GameObject("HeimTrackerOverlay");
				_panel.transform.SetParent(Minimap.instance.m_largeRoot.transform, false);
				RectTransform obj = _panel.AddComponent<RectTransform>();
				obj.anchorMin = new Vector2(1f, 1f);
				obj.anchorMax = new Vector2(1f, 1f);
				obj.pivot = new Vector2(1f, 1f);
				obj.anchoredPosition = new Vector2(-20f, -50f);
				obj.sizeDelta = new Vector2(180f, 885f);
				((Graphic)_panel.AddComponent<Image>()).color = new Color(0.22f, 0.16f, 0.1f, 0.75f);
				AddTitle();
				AddSectionHeader("Resources", -32f);
				AddResourceToggle("Pickable_Mushroom", "Mushrooms", -60f);
				AddResourceToggle("Pickable_Dandelion", "Dandelions", -85f);
				AddResourceToggle("RaspberryBush", "Raspberries", -110f);
				AddResourceToggle("BlueberryBush", "Blueberries", -135f);
				AddResourceToggle("Pickable_Thistle", "Thistle", -160f);
				AddResourceToggle("Pickable_SeedCarrot", "Carrot Seeds", -185f);
				AddResourceToggle("Pickable_SeedTurnip", "Turnip Seeds", -210f);
				AddResourceToggle("Pickable_DragonEgg", "Dragon Eggs", -235f);
				AddResourceToggle("OnionSeeds", "Onion Seeds", -260f);
				AddResourceToggle("Pickable_Flax_Wild", "Flax", -285f);
				AddResourceToggle("Pickable_Barley_Wild", "Barley", -310f);
				AddResourceToggle("CloudberryBush", "Cloudberries", -335f);
				AddResourceToggle("Pickable_Mushroom_JotunPuffs", "Jotun Puffs", -360f);
				AddResourceToggle("Pickable_Mushroom_Magecap", "Magecap", -385f);
				AddResourceToggle("VineAsh", "Vineberries", -410f);
				AddResourceToggle("Pickable_SmokePuff", "Smoke Puffs", -435f);
				AddResourceToggle("Pickable_Fiddlehead", "Fiddleheads", -460f);
				AddResourceToggle("LingonberryBush", "Lingonberries", -485f);
				AddResourceToggle("Pickable_SeedKale", "Kale Seeds", -510f);
				AddSectionHeader("Deposits", -540f);
				AddResourceToggle("rock4_copper", "Copper", -568f);
				AddResourceToggle("silvervein", "Silver", -593f);
				AddResourceToggle("giant_skull", "Giant Skull", -618f);
				AddResourceToggle("LeviathanLava", "Flametal", -643f);
				AddSectionHeader("Dungeons", -673f);
				AddDungeonToggle((Theme)8, "Burial Chambers", -701f);
				AddDungeonToggle((Theme)2, "Sunken Crypts", -726f);
				AddDungeonToggle((Theme)4, "Frost Caves", -751f);
				AddDungeonToggle((Theme)128, "Infested Mines", -776f);
				AddDungeonToggle((Theme)131072, "Morkhalla", -801f);
				AddDungeonToggle((Theme)16384, "Winding Tunnels", -826f);
			}
		}

		internal static void HandleResourceTrackingChanged(string prefabName, bool isEnabled)
		{
			if (!string.IsNullOrWhiteSpace(prefabName) && ResourceToggles.TryGetValue(prefabName, out var value) && (Object)(object)value != (Object)null)
			{
				value.SetIsOnWithoutNotify(isEnabled);
			}
		}

		internal static void HandleDungeonTrackingChanged(Theme theme, bool isEnabled)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (DungeonToggles.TryGetValue(theme, out var value) && (Object)(object)value != (Object)null)
			{
				value.SetIsOnWithoutNotify(isEnabled);
			}
		}

		private static void AddTitle()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Title");
			val.transform.SetParent(_panel.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.anchoredPosition = Vector2.zero;
			obj.sizeDelta = new Vector2(0f, 28f);
			Image obj2 = val.AddComponent<Image>();
			((Graphic)obj2).color = new Color(0.1f, 0.07f, 0.04f, 0.95f);
			((Graphic)obj2).raycastTarget = true;
			val.AddComponent<HeimTrackerDragHandler>();
			GameObject val2 = new GameObject("TitleText");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj3 = val2.AddComponent<RectTransform>();
			obj3.anchorMin = Vector2.zero;
			obj3.anchorMax = Vector2.one;
			obj3.offsetMin = Vector2.zero;
			obj3.offsetMax = Vector2.zero;
			TextMeshProUGUI obj4 = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj4).font = Minimap.instance.m_biomeNameLarge.font;
			((TMP_Text)obj4).text = "Map Tracking";
			((TMP_Text)obj4).fontSize = 12f;
			((TMP_Text)obj4).alignment = (TextAlignmentOptions)514;
			((Graphic)obj4).color = Color.white;
			AddSeparator(val);
		}

		private static void AddSectionHeader(string text, float yPosition)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0038: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(text + "Header");
			val.transform.SetParent(_panel.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.anchoredPosition = new Vector2(0f, yPosition);
			obj.sizeDelta = new Vector2(0f, 24f);
			Image obj2 = val.AddComponent<Image>();
			((Graphic)obj2).color = new Color(0.14f, 0.1f, 0.06f, 0.9f);
			((Graphic)obj2).raycastTarget = false;
			GameObject val2 = new GameObject("Text");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj3 = val2.AddComponent<RectTransform>();
			obj3.anchorMin = Vector2.zero;
			obj3.anchorMax = Vector2.one;
			obj3.offsetMin = Vector2.zero;
			obj3.offsetMax = Vector2.zero;
			TextMeshProUGUI obj4 = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj4).font = Minimap.instance.m_biomeNameLarge.font;
			((TMP_Text)obj4).text = text;
			((TMP_Text)obj4).fontSize = 12f;
			((TMP_Text)obj4).alignment = (TextAlignmentOptions)514;
			((Graphic)obj4).color = Color.white;
			AddSeparator(val);
		}

		private static void AddSeparator(GameObject parent)
		{
			//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)
			//IL_001c: 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_0042: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Separator");
			val.transform.SetParent(parent.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(1f, 0f);
			obj.pivot = new Vector2(0.5f, 0f);
			obj.sizeDelta = new Vector2(0f, 2f);
			Image obj2 = val.AddComponent<Image>();
			((Graphic)obj2).color = new Color(0.6f, 0.5f, 0.3f, 0.8f);
			((Graphic)obj2).raycastTarget = false;
		}

		private static void AddResourceToggle(string prefabName, string displayName, float yPosition)
		{
			Toggle val = CreateToggle(prefabName + "_Toggle", displayName, yPosition);
			bool value = PluginConfig.ResourceConfigs[prefabName].Value;
			val.SetIsOnWithoutNotify(value);
			ResourceToggles[prefabName] = val;
			((UnityEvent<bool>)(object)val.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value2)
			{
				PluginConfig.ResourceConfigs[prefabName].Value = value2;
			});
		}

		private static void AddDungeonToggle(Theme theme, string displayName, float yPosition)
		{
			//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)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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)
			Toggle val = CreateToggle($"{theme}_Toggle", displayName, yPosition);
			bool value = PluginConfig.DungeonConfigs[theme].Value;
			val.SetIsOnWithoutNotify(value);
			DungeonToggles[theme] = val;
			((UnityEvent<bool>)(object)val.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value2)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				PluginConfig.DungeonConfigs[theme].Value = value2;
			});
		}

		private static Toggle CreateToggle(string objectName, string displayName, float yPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_010e: 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_012f: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(objectName);
			val.transform.SetParent(_panel.transform, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.anchoredPosition = new Vector2(0f, yPosition);
			obj.sizeDelta = new Vector2(0f, 24f);
			Toggle obj2 = val.AddComponent<Toggle>();
			GameObject val2 = new GameObject("Background");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj3 = val2.AddComponent<RectTransform>();
			obj3.anchorMin = new Vector2(0f, 0.5f);
			obj3.anchorMax = new Vector2(0f, 0.5f);
			obj3.pivot = new Vector2(0f, 0.5f);
			obj3.anchoredPosition = new Vector2(12f, 0f);
			obj3.sizeDelta = new Vector2(14f, 14f);
			Image val3 = val2.AddComponent<Image>();
			((Graphic)val3).color = Color.white;
			GameObject val4 = new GameObject("Checkmark");
			val4.transform.SetParent(val2.transform, false);
			RectTransform obj4 = val4.AddComponent<RectTransform>();
			obj4.anchorMin = Vector2.zero;
			obj4.anchorMax = Vector2.one;
			obj4.offsetMin = new Vector2(3f, 3f);
			obj4.offsetMax = new Vector2(-3f, -3f);
			Image val5 = val4.AddComponent<Image>();
			((Graphic)val5).color = Color.green;
			((Selectable)obj2).targetGraphic = (Graphic)(object)val3;
			obj2.graphic = (Graphic)(object)val5;
			GameObject val6 = new GameObject("Label");
			val6.transform.SetParent(val.transform, false);
			RectTransform obj5 = val6.AddComponent<RectTransform>();
			obj5.anchorMin = Vector2.zero;
			obj5.anchorMax = Vector2.one;
			obj5.offsetMin = new Vector2(34f, 0f);
			obj5.offsetMax = new Vector2(-10f, 0f);
			TextMeshProUGUI obj6 = val6.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj6).font = Minimap.instance.m_biomeNameLarge.font;
			((TMP_Text)obj6).text = displayName;
			((TMP_Text)obj6).fontSize = 14f;
			((TMP_Text)obj6).alignment = (TextAlignmentOptions)513;
			((Graphic)obj6).color = Color.white;
			return obj2;
		}
	}
}
namespace HeimTracker.Patches
{
	[HarmonyPatch(typeof(Container), "Awake")]
	internal static class PatchContainerAwake
	{
		private const string MountainChestPrefabName = "TreasureChest_mountains";

		private static void Postfix(Container __instance)
		{
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null) && !(((Object)((Component)__instance).gameObject).name.Replace("(Clone)", string.Empty).Trim() != "TreasureChest_mountains"))
			{
				TrackedMapObject.TryAdd(((Component)__instance).gameObject, "OnionSeeds");
				TrackedMapObject trackedObject = default(TrackedMapObject);
				if (PluginConfig.TrackingMode.Value == TrackingModeEnum.ZoneBased && ((Component)__instance).gameObject.TryGetComponent<TrackedMapObject>(ref trackedObject))
				{
					ContainerResourcePinService.ReconcileTrackedContainer(trackedObject);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Container), "OnContainerChanged")]
	internal static class PatchContainerOnContainerChanged
	{
		private const string MountainChestPrefabName = "TreasureChest_mountains";

		private static void Postfix(Container __instance)
		{
			TrackedMapObject trackedObject = default(TrackedMapObject);
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null) && !(((Object)((Component)__instance).gameObject).name.Replace("(Clone)", string.Empty).Trim() != "TreasureChest_mountains") && ((Component)__instance).gameObject.TryGetComponent<TrackedMapObject>(ref trackedObject))
			{
				ContainerResourcePinService.ReconcileTrackedContainer(trackedObject);
			}
		}
	}
	[HarmonyPatch(typeof(Destructible), "Awake")]
	internal static class PatchDestructibleAwake
	{
		private static void Postfix(Destructible __instance)
		{
			if (!PluginConfig.IsModEnabled.Value || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			string text = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", string.Empty).Trim();
			if (TrackedResourceDefinitions.DestructibleResourcesByPrefabName.ContainsKey(text))
			{
				TrackedMapObject.TryAdd(((Component)__instance).gameObject, text);
				if (PluginConfig.TrackingMode.Value != TrackingModeEnum.RangeScanner)
				{
					OreResourcePinService.TryAddResourcePinFromDestructibleOre(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Destructible), "Destroy")]
	internal static class PatchDestructibleDestroy
	{
		private static void Prefix(Destructible __instance)
		{
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null))
			{
				OreResourcePinService.TryRemoveResourcePinFromDestructibleOre(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Location), "Awake")]
	internal static class PatchLocationAwake
	{
		private static void Postfix(Location __instance)
		{
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null))
			{
				TrackedDungeonLocation.TryAdd(__instance);
				if (PluginConfig.TrackingMode.Value != TrackingModeEnum.RangeScanner)
				{
					DungeonPinManager.TryAddDungeonPin(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(MineRock), "AllDestroyed")]
	internal static class PatchMineRockAllDestroyed
	{
		private static void Postfix(MineRock __instance, bool __result)
		{
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null) && __result)
			{
				OreResourcePinService.TryRemoveResourcePinFromMineRock(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(MineRock), "Start")]
	internal static class PatchMineRockStart
	{
		private static void Postfix(MineRock __instance)
		{
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null) && TrackedResourceDefinitions.MineRockResourcesByName.TryGetValue(__instance.m_name, out var value))
			{
				TrackedMapObject.TryAdd(((Component)__instance).gameObject, value.ResourcePrefabName);
				if (PluginConfig.TrackingMode.Value != TrackingModeEnum.RangeScanner)
				{
					OreResourcePinService.TryAddResourcePinFromMineRock(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Minimap), "OnMapLeftClick")]
	internal static class PatchMinimapOnMapLeftClick
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			DungeonPinManager.UpdateCheckedStates();
		}
	}
	[HarmonyPatch(typeof(Minimap), "RemovePin", new Type[]
	{
		typeof(Vector3),
		typeof(float)
	})]
	internal static class PatchMinimapRemovePin
	{
		private static bool Prefix(Vector3 pos, float radius, ref bool __result)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginConfig.IsModEnabled.Value)
			{
				return true;
			}
			if (ResourcePinManager.RemoveClosestResourcePin(pos, radius))
			{
				__result = true;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Minimap), "Start")]
	internal static class PatchMinimapStart
	{
		private static void Postfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				HeimTrackerMapOverlay.Create();
			}
		}
	}
	[HarmonyPatch(typeof(Pickable), "SetPicked")]
	internal static class PatchPickableSetPicked
	{
		private static void Prefix(Pickable __instance, bool picked, ref ZDOID __state)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginConfig.IsModEnabled.Value)
			{
				return;
			}
			__state = ZDOID.None;
			if (!picked || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null))
			{
				ZDO zDO = component.GetZDO();
				if (zDO != null)
				{
					__state = zDO.m_uid;
				}
			}
		}

		private static void Postfix(Pickable __instance, bool picked, ZDOID __state)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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)
			if (!PluginConfig.IsModEnabled.Value)
			{
				return;
			}
			if (picked)
			{
				if (!(__state == ZDOID.None))
				{
					ResourcePinManager.RemoveResourcePin(__state);
				}
			}
			else if (PluginConfig.TrackingMode.Value != TrackingModeEnum.RangeScanner)
			{
				PickableResourcePinService.TryAddResourcePinFromPickable(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Pickable), "Awake")]
	internal static class PatchPickableAwake
	{
		private static void Postfix(Pickable __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				string text = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", string.Empty).Trim();
				if (PluginConfig.ResourceConfigs.ContainsKey(text))
				{
					TrackedMapObject.TryAdd(((Component)__instance).gameObject, text);
				}
				if (PluginConfig.TrackingMode.Value != TrackingModeEnum.RangeScanner)
				{
					PickableResourcePinService.TryAddResourcePinFromPickable(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetLocalPlayer")]
	internal static class PatchPlayerSetLocalPlayer
	{
		private static void Postfix()
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				MapTrackingScanner.HandleTrackingModeChanged();
			}
		}
	}
	[HarmonyPatch(typeof(Minimap), "UpdatePins")]
	internal static class PatchMinimapUpdatePins
	{
		private static void Postfix(Minimap __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				ResourcePinManager.UpdateResourcePinVisuals(__instance);
			}
		}
	}
}
namespace HeimTracker.Models
{
	[Obsolete("Delete this class after refactor")]
	internal class ResourceDefinitionModel
	{
		internal string ResourcePrefabName { get; }

		internal string ItemPrefabName { get; }

		internal ResourceDefinitionModel(string resourcePrefabName, string itemPrefabName)
		{
			ResourcePrefabName = resourcePrefabName;
			ItemPrefabName = itemPrefabName;
		}
	}
	internal sealed class TrackedResourceDefinition
	{
		internal string ResourcePrefabName { get; }

		internal string DisplayName { get; }

		internal int SortOrder { get; }

		internal TrackedResourceTypeEnum ResourceType { get; }

		internal string IconItemPrefabName { get; }

		internal string MineRock5Name { get; }

		internal string MineRockName { get; }

		internal TrackedResourceDefinition(string resourcePrefabName, string displayName, int sortOrder, TrackedResourceTypeEnum resourceType, string iconItemPrefabName = null, string mineRock5Name = null, string mineRockName = null)
		{
			ResourcePrefabName = resourcePrefabName;
			DisplayName = displayName;
			SortOrder = sortOrder;
			ResourceType = resourceType;
			IconItemPrefabName = iconItemPrefabName;
			MineRock5Name = mineRock5Name;
			MineRockName = mineRockName;
		}
	}
	internal enum TrackedResourceTypeEnum
	{
		Pickable,
		Deposit,
		Container
	}
}
namespace HeimTracker.Core
{
	internal static class ContainerResourcePinService
	{
		internal static void ReconcileTrackedContainer(TrackedMapObject trackedObject)
		{
			//IL_0055: 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)
			if ((Object)(object)trackedObject == (Object)null || (Object)(object)trackedObject.Container == (Object)null || (Object)(object)trackedObject.ZNetView == (Object)null)
			{
				return;
			}
			ZDO zDO = trackedObject.ZNetView.GetZDO();
			if (zDO != null)
			{
				if (!TryGetTrackedContainerResource(trackedObject.Container, out var definition, out var iconItemPrefabName) || !PluginConfig.IsResourceTrackingEnabled(definition.ResourcePrefabName))
				{
					ResourcePinManager.RemoveResourcePin(zDO.m_uid);
				}
				else
				{
					ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, definition, iconItemPrefabName, ((Component)trackedObject).transform.position));
				}
			}
		}

		internal static void HandleResourceTrackingChanged(string prefabName, bool isEnabled)
		{
			if (!TrackedResources.TryGetByPrefabName(prefabName, out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Container)
			{
				return;
			}
			if (!isEnabled)
			{
				ResourcePinManager.RemoveResourcePins(definition.ResourcePrefabName);
				return;
			}
			foreach (TrackedMapObject trackedObject in TrackedMapObject.GetTrackedObjects())
			{
				if (!((Object)(object)trackedObject == (Object)null) && !((Object)(object)trackedObject.Container == (Object)null))
				{
					ReconcileTrackedContainer(trackedObject);
				}
			}
		}

		private static bool TryGetTrackedContainerResource(Container container, out TrackedResourceDefinition definition, out string iconItemPrefabName)
		{
			Inventory inventory = container.GetInventory();
			if (inventory == null)
			{
				definition = null;
				iconItemPrefabName = null;
				return false;
			}
			foreach (ItemData allItem in inventory.GetAllItems())
			{
				if (!((Object)(object)allItem.m_dropPrefab == (Object)null))
				{
					string name = ((Object)allItem.m_dropPrefab).name;
					if (TrackedResources.TryGetByPrefabName(name, out definition) && definition.ResourceType == TrackedResourceTypeEnum.Container)
					{
						iconItemPrefabName = name;
						return true;
					}
				}
			}
			definition = null;
			iconItemPrefabName = null;
			return false;
		}
	}
	internal static class OreResourcePinService
	{
		private const float ResourcePinRadius = 35f;

		private static readonly MethodInfo MineRockAllDestroyedMethod = AccessTools.Method(typeof(MineRock), "AllDestroyed", (Type[])null, (Type[])null);

		internal static bool TryAddResourcePinFromDestructibleOre(Destructible destructible)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destructible == (Object)null || (Object)(object)Minimap.instance == (Object)null)
			{
				return false;
			}
			if (!TrackedResources.TryGetByPrefabName(((Object)((Component)destructible).gameObject).name.Replace("(Clone)", string.Empty).Trim(), out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Deposit)
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(definition.ResourcePrefabName))
			{
				return false;
			}
			ZNetView component = ((Component)destructible).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			return ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, definition, definition.IconItemPrefabName, ((Component)destructible).transform.position));
		}

		internal static bool TryAddOrRelinkResourcePinFromMineRock5Ore(MineRock5 mineRock)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mineRock == (Object)null || (Object)(object)Minimap.instance == (Object)null)
			{
				return false;
			}
			if (!TrackedResources.TryGetByMineRock5(mineRock.m_name, out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Deposit)
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(definition.ResourcePrefabName))
			{
				return false;
			}
			ZNetView component = ((Component)mineRock).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			if (ResourcePinManager.HasResourcePin(zDO.m_uid))
			{
				return true;
			}
			ResourcePinManager.RemoveClosestResourcePin(definition.ResourcePrefabName, ((Component)mineRock).transform.position, 35f);
			return ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, definition, definition.IconItemPrefabName, ((Component)mineRock).transform.position));
		}

		internal static bool TryAddResourcePinFromMineRock(MineRock mineRock)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mineRock == (Object)null || (Object)(object)Minimap.instance == (Object)null)
			{
				return false;
			}
			if (!TrackedResources.TryGetByMineRock(mineRock.m_name, out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Deposit)
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(definition.ResourcePrefabName))
			{
				return false;
			}
			ZNetView component = ((Component)mineRock).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			if (IsMineRockFullyDestroyed(mineRock))
			{
				ResourcePinManager.RemoveResourcePin(zDO.m_uid);
				return false;
			}
			return ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, definition, definition.IconItemPrefabName, ((Component)mineRock).transform.position));
		}

		internal static bool TryRemoveResourcePinFromDestructibleOre(Destructible destructible)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destructible == (Object)null)
			{
				return false;
			}
			if (!TrackedResources.TryGetByPrefabName(((Object)((Component)destructible).gameObject).name.Replace("(Clone)", string.Empty).Trim(), out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Deposit)
			{
				return false;
			}
			ZNetView component = ((Component)destructible).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			return ResourcePinManager.RemoveResourcePin(zDO.m_uid);
		}

		internal static bool TryRemoveResourcePinFromMineRock(MineRock mineRock)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mineRock == (Object)null)
			{
				return false;
			}
			if (!TrackedResources.TryGetByMineRock(mineRock.m_name, out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Deposit)
			{
				return false;
			}
			ZNetView component = ((Component)mineRock).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			return ResourcePinManager.RemoveResourcePin(zDO.m_uid);
		}

		internal static void HandleResourceTrackingChanged(string prefabName, bool isEnabled)
		{
			if (!string.IsNullOrWhiteSpace(prefabName) && TrackedResources.TryGetByPrefabName(prefabName, out var definition) && definition.ResourceType == TrackedResourceTypeEnum.Deposit)
			{
				if (!isEnabled)
				{
					ResourcePinManager.RemoveResourcePins(prefabName);
				}
				else if (!((Object)(object)Minimap.instance == (Object)null))
				{
					RescanLoadedDestructibles(prefabName);
					RescanLoadedMineRock5(prefabName);
					RescanLoadedMineRock(prefabName);
				}
			}
		}

		internal static void ReconcileTrackedOre(TrackedMapObject trackedObject)
		{
			//IL_0045: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trackedObject == (Object)null)
			{
				return;
			}
			ZNetView zNetView = trackedObject.ZNetView;
			if ((Object)(object)zNetView == (Object)null || !zNetView.IsValid())
			{
				return;
			}
			ZDO zDO = zNetView.GetZDO();
			if (zDO == null)
			{
				return;
			}
			if ((Object)(object)trackedObject.Destructible != (Object)null)
			{
				if (!trackedObject.IsInTrackingRange)
				{
					ResourcePinManager.RemoveResourcePin(zDO.m_uid);
				}
				else
				{
					TryAddResourcePinFromDestructibleOre(trackedObject.Destructible);
				}
			}
			else if ((Object)(object)trackedObject.MineRock5 != (Object)null)
			{
				if (!trackedObject.IsInTrackingRange)
				{
					ResourcePinManager.RemoveResourcePin(zDO.m_uid);
				}
				else
				{
					TryAddOrRelinkResourcePinFromMineRock5Ore(trackedObject.MineRock5);
				}
			}
			else if ((Object)(object)trackedObject.MineRock != (Object)null)
			{
				if (!trackedObject.IsInTrackingRange)
				{
					ResourcePinManager.RemoveResourcePin(zDO.m_uid);
				}
				else
				{
					TryAddResourcePinFromMineRock(trackedObject.MineRock);
				}
			}
		}

		private static void RescanLoadedDestructibles(string prefabName)
		{
			Destructible[] array = Object.FindObjectsByType<Destructible>((FindObjectsSortMode)0);
			foreach (Destructible val in array)
			{
				if (!((Object)(object)val == (Object)null) && !(((Object)((Component)val).gameObject).name.Replace("(Clone)", string.Empty).Trim() != prefabName))
				{
					TryAddResourcePinFromDestructibleOre(val);
				}
			}
		}

		private static void RescanLoadedMineRock5(string prefabName)
		{
			MineRock5[] array = Object.FindObjectsByType<MineRock5>((FindObjectsSortMode)0);
			foreach (MineRock5 val in array)
			{
				if (!((Object)(object)val == (Object)null) && TrackedResources.TryGetByMineRock5(val.m_name, out var definition) && !(definition.ResourcePrefabName != prefabName))
				{
					TryAddOrRelinkResourcePinFromMineRock5Ore(val);
				}
			}
		}

		private static void RescanLoadedMineRock(string prefabName)
		{
			MineRock[] array = Object.FindObjectsByType<MineRock>((FindObjectsSortMode)0);
			foreach (MineRock val in array)
			{
				if (!((Object)(object)val == (Object)null) && TrackedResources.TryGetByMineRock(val.m_name, out var definition) && !(definition.ResourcePrefabName != prefabName))
				{
					TryAddResourcePinFromMineRock(val);
				}
			}
		}

		private static bool IsMineRockFullyDestroyed(MineRock mineRock)
		{
			if ((Object)(object)mineRock == (Object)null || MineRockAllDestroyedMethod == null)
			{
				return false;
			}
			object obj = MineRockAllDestroyedMethod.Invoke(mineRock, null);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
		}
	}
	internal static class PickableResourcePinService
	{
		internal static bool TryAddResourcePinFromPickable(Pickable pickable)
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pickable == (Object)null || (Object)(object)Minimap.instance == (Object)null || (Object)(object)pickable.m_itemPrefab == (Object)null)
			{
				return false;
			}
			ZNetView component = ((Component)pickable).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			if (!pickable.CanBePicked())
			{
				return false;
			}
			if (!TrackedResources.TryGetByPrefabName(((Object)((Component)pickable).gameObject).name.Replace("(Clone)", string.Empty).Trim(), out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Pickable)
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(definition.ResourcePrefabName))
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			return ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, definition, ((Object)pickable.m_itemPrefab).name, ((Component)pickable).transform.position));
		}

		internal static void HandleResourceTrackingChanged(string prefabName, bool isEnabled)
		{
			if (string.IsNullOrWhiteSpace(prefabName) || !TrackedResources.TryGetByPrefabName(prefabName, out var definition) || definition.ResourceType != TrackedResourceTypeEnum.Pickable)
			{
				return;
			}
			if (!isEnabled)
			{
				ResourcePinManager.RemoveResourcePins(definition.ResourcePrefabName);
			}
			else
			{
				if ((Object)(object)Minimap.instance == (Object)null)
				{
					return;
				}
				Pickable[] array = Object.FindObjectsByType<Pickable>((FindObjectsSortMode)0);
				foreach (Pickable val in array)
				{
					if (!((Object)(object)val == (Object)null) && !(((Object)((Component)val).gameObject).name.Replace("(Clone)", string.Empty).Trim() != definition.ResourcePrefabName))
					{
						TryAddResourcePinFromPickable(val);
					}
				}
			}
		}

		internal static void ReconcileTrackedPickable(TrackedMapObject trackedObject)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trackedObject == (Object)null || (Object)(object)trackedObject.Pickable == (Object)null)
			{
				return;
			}
			ZNetView zNetView = trackedObject.ZNetView;
			if ((Object)(object)zNetView == (Object)null || !zNetView.IsValid())
			{
				return;
			}
			ZDO zDO = zNetView.GetZDO();
			if (zDO != null)
			{
				if (!trackedObject.IsInTrackingRange)
				{
					ResourcePinManager.RemoveResourcePin(zDO.m_uid);
				}
				else
				{
					TryAddResourcePinFromPickable(trackedObject.Pickable);
				}
			}
		}
	}
	internal static class TrackedResources
	{
		internal static readonly List<TrackedResourceDefinition> AllTrackedResources;

		private static readonly Dictionary<string, TrackedResourceDefinition> ByPrefabName;

		private static readonly Dictionary<string, TrackedResourceDefinition> ByMineRock5Name;

		private static readonly Dictionary<string, TrackedResourceDefinition> ByMineRockName;

		static TrackedResources()
		{
			AllTrackedResources = new List<TrackedResourceDefinition>
			{
				new TrackedResourceDefinition("Pickable_Mushroom", "Mushrooms", 100, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_Dandelion", "Dandelions", 110, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("RaspberryBush", "Raspberries", 120, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("BlueberryBush", "Blueberries", 200, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_Thistle", "Thistle", 210, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_SeedCarrot", "Carrot Seeds", 220, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("rock4_copper", "Copper", 230, TrackedResourceTypeEnum.Deposit, "CopperOre", "$piece_deposit_copper"),
				new TrackedResourceDefinition("Pickable_SeedTurnip", "Turnip Seeds", 300, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_DragonEgg", "Dragon Eggs", 400, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("OnionSeeds", "Onion Seeds", 410, TrackedResourceTypeEnum.Container),
				new TrackedResourceDefinition("silvervein", "Silver", 420, TrackedResourceTypeEnum.Deposit, "SilverOre", "$piece_deposit_silvervein"),
				new TrackedResourceDefinition("Pickable_Flax_Wild", "Flax", 500, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_Barley_Wild", "Barley", 510, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("CloudberryBush", "Cloudberries", 520, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_Mushroom_JotunPuffs", "Jotun Puffs", 600, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_Mushroom_Magecap", "Magecap", 610, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("giant_skull", "Giant Skull", 620, TrackedResourceTypeEnum.Deposit, "Softtissue", "$piece_giant_bone"),
				new TrackedResourceDefinition("VineAsh", "Vineberries", 700, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_SmokePuff", "Smoke Puffs", 710, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_Fiddlehead", "Fiddleheads", 720, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("LeviathanLava", "Flametal", 730, TrackedResourceTypeEnum.Deposit, "FlametalOreNew", null, "$item_flametalore"),
				new TrackedResourceDefinition("LingonberryBush", "Lingonberries", 800, TrackedResourceTypeEnum.Pickable),
				new TrackedResourceDefinition("Pickable_SeedKale", "Kale Seeds", 810, TrackedResourceTypeEnum.Pickable)
			};
			ByPrefabName = new Dictionary<string, TrackedResourceDefinition>();
			ByMineRock5Name = new Dictionary<string, TrackedResourceDefinition>();
			ByMineRockName = new Dictionary<string, TrackedResourceDefinition>();
			BuildResourceLookups();
		}

		internal static bool TryGetByPrefabName(string prefabName, out TrackedResourceDefinition definition)
		{
			return ByPrefabName.TryGetValue(prefabName, out definition);
		}

		internal static bool TryGetByMineRock5(string mineRockName, out TrackedResourceDefinition definition)
		{
			return ByMineRock5Name.TryGetValue(mineRockName, out definition);
		}

		internal static bool TryGetByMineRock(string mineRockName, out TrackedResourceDefinition definition)
		{
			return ByMineRockName.TryGetValue(mineRockName, out definition);
		}

		private static void BuildResourceLookups()
		{
			foreach (TrackedResourceDefinition allTrackedResource in AllTrackedResources)
			{
				ByPrefabName[allTrackedResource.ResourcePrefabName] = allTrackedResource;
				if (!string.IsNullOrWhiteSpace(allTrackedResource.MineRock5Name))
				{
					ByMineRock5Name[allTrackedResource.MineRock5Name] = allTrackedResource;
				}
				if (!string.IsNullOrWhiteSpace(allTrackedResource.MineRockName))
				{
					ByMineRockName[allTrackedResource.MineRockName] = allTrackedResource;
				}
			}
		}
	}
	internal sealed class MapTrackingScanner : MonoBehaviour
	{
		private const float RescanDistance = 25f;

		private const float RescanDistanceSquared = 625f;

		private Vector3 _lastScanPosition;

		private bool _hasScanned;

		private void Update()
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.IsModEnabled.Value)
			{
				Vector3 position = ((Component)this).transform.position;
				if (!_hasScanned || HasMovedEnough(position))
				{
					Scan(position);
				}
			}
		}

		private bool HasMovedEnough(Vector3 currentPosition)
		{
			//IL_0000: 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)
			float num = currentPosition.x - _lastScanPosition.x;
			float num2 = currentPosition.z - _lastScanPosition.z;
			return num * num + num2 * num2 >= 625f;
		}

		private void Scan(Vector3 currentPosition)
		{
			//IL_0033: 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_003e: 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_00bc: 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)
			float value = PluginConfig.TrackingRange.Value;
			float num = value * value;
			foreach (TrackedMapObject trackedObject in TrackedMapObject.GetTrackedObjects())
			{
				if (!((Object)(object)trackedObject == (Object)null))
				{
					Vector3 position = ((Component)trackedObject).transform.position;
					float num2 = position.x - currentPosition.x;
					float num3 = position.z - currentPosition.z;
					bool isInTrackingRange = num2 * num2 + num3 * num3 <= num;
					trackedObject.IsInTrackingRange = isInTrackingRange;
					if ((Object)(object)trackedObject.Container != (Object)null)
					{
						ContainerResourcePinService.ReconcileTrackedContainer(trackedObject);
					}
					else if ((Object)(object)trackedObject.Pickable != (Object)null)
					{
						PickableResourcePinService.ReconcileTrackedPickable(trackedObject);
					}
					else
					{
						OreResourcePinService.ReconcileTrackedOre(trackedObject);
					}
				}
			}
			DungeonPinManager.ReconcileTrackingRange();
			_lastScanPosition = currentPosition;
			_hasScanned = true;
		}

		internal static void HandleTrackingModeChanged()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			if (PluginConfig.TrackingMode.Value == TrackingModeEnum.RangeScanner)
			{
				MapTrackingScanner mapTrackingScanner = default(MapTrackingScanner);
				if (!((Component)localPlayer).TryGetComponent<MapTrackingScanner>(ref mapTrackingScanner))
				{
					mapTrackingScanner = ((Component)localPlayer).gameObject.AddComponent<MapTrackingScanner>();
				}
				mapTrackingScanner.ForceScan();
			}
			else
			{
				MapTrackingScanner mapTrackingScanner2 = default(MapTrackingScanner);
				if (((Component)localPlayer).TryGetComponent<MapTrackingScanner>(ref mapTrackingScanner2))
				{
					Object.Destroy((Object)(object)mapTrackingScanner2);
				}
				RescanZoneBasedObjects();
			}
		}

		internal static void ForceRescan()
		{
			if (PluginConfig.TrackingMode.Value == TrackingModeEnum.RangeScanner)
			{
				Player localPlayer = Player.m_localPlayer;
				MapTrackingScanner mapTrackingScanner = default(MapTrackingScanner);
				if (!((Object)(object)localPlayer == (Object)null) && ((Component)localPlayer).TryGetComponent<MapTrackingScanner>(ref mapTrackingScanner))
				{
					mapTrackingScanner.ForceScan();
				}
			}
		}

		private void ForceScan()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			_hasScanned = false;
			Scan(((Component)this).transform.position);
		}

		private static void RescanZoneBasedObjects()
		{
			foreach (TrackedMapObject trackedObject in TrackedMapObject.GetTrackedObjects())
			{
				if (!((Object)(object)trackedObject == (Object)null))
				{
					if ((Object)(object)trackedObject.Container != (Object)null)
					{
						ContainerResourcePinService.ReconcileTrackedContainer(trackedObject);
					}
					else if ((Object)(object)trackedObject.Pickable != (Object)null)
					{
						PickableResourcePinService.TryAddResourcePinFromPickable(trackedObject.Pickable);
					}
					else if ((Object)(object)trackedObject.Destructible != (Object)null)
					{
						OreResourcePinService.TryAddResourcePinFromDestructibleOre(trackedObject.Destructible);
					}
					else if ((Object)(object)trackedObject.MineRock5 != (Object)null)
					{
						OreResourcePinService.TryAddOrRelinkResourcePinFromMineRock5Ore(trackedObject.MineRock5);
					}
					else if ((Object)(object)trackedObject.MineRock != (Object)null)
					{
						OreResourcePinService.TryAddResourcePinFromMineRock(trackedObject.MineRock);
					}
				}
			}
			DungeonPinManager.AddLoadedDungeonPins();
		}
	}
	[Obsolete("Delete this class after refactor")]
	internal static class TrackedResourceDefinitions
	{
		internal static readonly Dictionary<string, ResourceDefinitionModel> DestructibleResourcesByPrefabName = new Dictionary<string, ResourceDefinitionModel>
		{
			{
				"rock4_copper",
				new ResourceDefinitionModel("rock4_copper", "CopperOre")
			},
			{
				"silvervein",
				new ResourceDefinitionModel("silvervein", "SilverOre")
			},
			{
				"giant_skull",
				new ResourceDefinitionModel("giant_skull", "Softtissue")
			}
		};

		internal static readonly Dictionary<string, ResourceDefinitionModel> MineRock5ResourcesByName = new Dictionary<string, ResourceDefinitionModel>
		{
			{
				"$piece_deposit_copper",
				new ResourceDefinitionModel("rock4_copper", "CopperOre")
			},
			{
				"$piece_deposit_silvervein",
				new ResourceDefinitionModel("silvervein", "SilverOre")
			},
			{
				"$piece_giant_bone",
				new ResourceDefinitionModel("giant_skull", "Softtissue")
			}
		};

		internal static readonly Dictionary<string, ResourceDefinitionModel> MineRockResourcesByName = new Dictionary<string, ResourceDefinitionModel> { 
		{
			"$item_flametalore",
			new ResourceDefinitionModel("LeviathanLava", "FlametalOreNew")
		} };
	}
}
namespace HeimTracker.Core.Tracking
{
	internal sealed class TrackedDungeonLocation : MonoBehaviour
	{
		private static readonly HashSet<TrackedDungeonLocation> TrackedLocations = new HashSet<TrackedDungeonLocation>();

		internal Location Location { get; private set; }

		internal static IReadOnlyCollection<TrackedDungeonLocation> GetTrackedLocations()
		{
			return TrackedLocations;
		}

		internal void Initialize(Location location)
		{
			Location = location;
			TrackedLocations.Add(this);
		}

		private void OnDestroy()
		{
			TrackedLocations.Remove(this);
		}

		internal static void TryAdd(Location location)
		{
			TrackedDungeonLocation trackedDungeonLocation = default(TrackedDungeonLocation);
			if (!((Object)(object)location == (Object)null) && DungeonPinManager.TryGetSupportedDungeonTheme(location, out var _) && !((Component)location).TryGetComponent<TrackedDungeonLocation>(ref trackedDungeonLocation))
			{
				trackedDungeonLocation = ((Component)location).gameObject.AddComponent<TrackedDungeonLocation>();
				trackedDungeonLocation.Initialize(location);
			}
		}
	}
	internal sealed class TrackedMapObject : MonoBehaviour
	{
		private static readonly HashSet<TrackedMapObject> TrackedObjects = new HashSet<TrackedMapObject>();

		internal string PrefabName { get; private set; }

		internal bool IsInTrackingRange { get; set; }

		internal Pickable Pickable { get; private set; }

		internal Destructible Destructible { get; private set; }

		internal MineRock5 MineRock5 { get; private set; }

		internal MineRock MineRock { get; private set; }

		internal ZNetView ZNetView { get; private set; }

		internal Container Container { get; private set; }

		internal static IReadOnlyCollection<TrackedMapObject> GetTrackedObjects()
		{
			return TrackedObjects;
		}

		internal void Initialize(string prefabName)
		{
			PrefabName = prefabName;
			Pickable pickable = default(Pickable);
			((Component)this).TryGetComponent<Pickable>(ref pickable);
			Destructible destructible = default(Destructible);
			((Component)this).TryGetComponent<Destructible>(ref destructible);
			MineRock5 mineRock = default(MineRock5);
			((Component)this).TryGetComponent<MineRock5>(ref mineRock);
			MineRock mineRock2 = default(MineRock);
			((Component)this).TryGetComponent<MineRock>(ref mineRock2);
			ZNetView zNetView = default(ZNetView);
			((Component)this).TryGetComponent<ZNetView>(ref zNetView);
			Container container = default(Container);
			((Component)this).TryGetComponent<Container>(ref container);
			Pickable = pickable;
			Destructible = destructible;
			MineRock5 = mineRock;
			MineRock = mineRock2;
			ZNetView = zNetView;
			Container = container;
			TrackedObjects.Add(this);
		}

		private void OnDestroy()
		{
			TrackedObjects.Remove(this);
		}

		internal static void TryAdd(GameObject gameObject, string prefabName)
		{
			TrackedMapObject trackedMapObject = default(TrackedMapObject);
			if (!((Object)(object)gameObject == (Object)null) && !string.IsNullOrWhiteSpace(prefabName) && !gameObject.TryGetComponent<TrackedMapObject>(ref trackedMapObject))
			{
				trackedMapObject = gameObject.AddComponent<TrackedMapObject>();
				trackedMapObject.Initialize(prefabName);
			}
		}
	}
	internal static class TrackingRangeService
	{
		internal static bool IsWithinTrackingRange(Vector3 position)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			if (PluginConfig.TrackingMode.Value == TrackingModeEnum.ZoneBased)
			{
				return true;
			}
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return false;
			}
			float value = PluginConfig.TrackingRange.Value;
			Vector3 position2 = ((Component)Player.m_localPlayer).transform.position;
			float num = position2.x - position.x;
			float num2 = position2.z - position.z;
			return num * num + num2 * num2 <= value * value;
		}
	}
	internal enum TrackingModeEnum
	{
		ZoneBased,
		RangeScanner
	}
}
namespace HeimTracker.Core.PinManagers
{
	internal static class DungeonPinManager
	{
		private const float DuplicateRadius = 5f;

		private const float ExistingPinMatchRadius = 0.1f;

		private static readonly List<DungeonPinModel> DungeonPins = new List<DungeonPinModel>();

		private static readonly FieldRef<Minimap, List<PinData>> MinimapPins = AccessTools.FieldRefAccess<Minimap, List<PinData>>("m_pins");

		private static readonly FieldInfo MinimapPinUpdateRequiredField = AccessTools.Field(typeof(Minimap), "m_pinUpdateRequired");

		private static Minimap _trackedMinimap;

		private static readonly Dictionary<Theme, string> SupportedDungeons = new Dictionary<Theme, string>
		{
			{
				(Theme)8,
				"Burial Chamber"
			},
			{
				(Theme)2,
				"Sunken Crypt"
			},
			{
				(Theme)4,
				"Frost Cave"
			},
			{
				(Theme)128,
				"Infested Mine"
			},
			{
				(Theme)131072,
				"Morkhalla"
			},
			{
				(Theme)16384,
				"Winding Tunnel"
			},
			{
				(Theme)536870912,
				"Charred Fortress"
			},
			{
				(Theme)1073741824,
				"Putrid Hole"
			}
		};

		internal static bool TryAddDungeonPin(Location location)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)location == (Object)null)
			{
				return false;
			}
			EnsureMinimapState();
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return false;
			}
			if (!TryGetSupportedDungeonTheme(location, out var theme))
			{
				return false;
			}
			string prefabName = Utils.GetPrefabName(((Component)location).gameObject);
			Vector3 position = ((Component)location).transform.position;
			if (!PluginConfig.IsDungeonTrackingEnabled(theme))
			{
				return false;
			}
			if (!TrackingRangeService.IsWithinTrackingRange(position))
			{
				return false;
			}
			if (HasDungeonPin(theme, position))
			{
				return false;
			}
			DungeonPinModel dungeonPinModel = new DungeonPinModel(theme, prefabName, position);
			PinData val = FindExistingDungeonPin(position);
			if (val != null)
			{
				dungeonPinModel.Pin = val;
				dungeonPinModel.IsChecked = val.m_checked;
			}
			else if (!CreatePin(dungeonPinModel))
			{
				return false;
			}
			DungeonPins.Add(dungeonPinModel);
			return true;
		}

		internal static void HandleDungeonTrackingChanged(Theme theme, bool isEnabled)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			EnsureMinimapState();
			RemoveExistingDungeonPins(theme);
			if (isEnabled)
			{
				AddLoadedDungeonPins(theme);
			}
		}

		internal static void UpdateCheckedStates()
		{
			EnsureMinimapState();
			foreach (DungeonPinModel dungeonPin in DungeonPins)
			{
				if (dungeonPin.Pin != null && dungeonPin.IsChecked != dungeonPin.Pin.m_checked)
				{
					dungeonPin.IsChecked = dungeonPin.Pin.m_checked;
				}
			}
		}

		internal static void RedrawDungeonPins()
		{
			EnsureMinimapState();
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			foreach (DungeonPinModel dungeonPin in DungeonPins)
			{
				if (dungeonPin.Pin != null)
				{
					Minimap.instance.RemovePin(dungeonPin.Pin);
					dungeonPin.Pin = null;
				}
				CreatePin(dungeonPin);
			}
		}

		internal static void ReconcileTrackingRange()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			EnsureMinimapState();
			if ((Object)(object)Minimap.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			for (int num = DungeonPins.Count - 1; num >= 0; num--)
			{
				DungeonPinModel dungeonPinModel = DungeonPins[num];
				if (!TrackingRangeService.IsWithinTrackingRange(dungeonPinModel.Position))
				{
					if (dungeonPinModel.Pin != null)
					{
						Minimap.instance.RemovePin(dungeonPinModel.Pin);
						dungeonPinModel.Pin = null;
					}
					DungeonPins.RemoveAt(num);
				}
			}
			foreach (TrackedDungeonLocation trackedLocation in TrackedDungeonLocation.GetTrackedLocations())
			{
				if (!((Object)(object)trackedLocation == (Object)null) && !((Object)(object)trackedLocation.Location == (Object)null))
				{
					TryAddDungeonPin(trackedLocation.Location);
				}
			}
		}

		internal static void AddLoadedDungeonPins()
		{
			EnsureMinimapState();
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			foreach (TrackedDungeonLocation trackedLocation in TrackedDungeonLocation.GetTrackedLocations())
			{
				if (!((Object)(object)trackedLocation == (Object)null) && !((Object)(object)trackedLocation.Location == (Object)null))
				{
					TryAddDungeonPin(trackedLocation.Location);
				}
			}
		}

		internal static bool TryGetSupportedDungeonTheme(Location location, out Theme theme)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected I4, but got Unknown
			theme = (Theme)0;
			if ((Object)(object)location == (Object)null)
			{
				return false;
			}
			if (Utils.GetPrefabName(((Component)location).gameObject) == "CharredFortress")
			{
				theme = (Theme)536870912;
				return true;
			}
			if (Utils.GetPrefabName(((Component)location).gameObject) == "MorgenHole1")
			{
				theme = (Theme)1073741824;
				return true;
			}
			if (Utils.GetPrefabName(((Component)location).gameObject) == "MorgenHole2")
			{
				theme = (Theme)1073741824;
				return true;
			}
			if (Utils.GetPrefabName(((Component)location).gameObject) == "MorgenHole3")
			{
				theme = (Theme)1073741824;
				return true;
			}
			if (!location.m_hasInterior)
			{
				return false;
			}
			DungeonGenerator componentInChildren = ((Component)location).GetComponentInChildren<DungeonGenerator>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			if ((int)componentInChildren.m_algorithm != 0)
			{
				return false;
			}
			theme = (Theme)(int)componentInChildren.m_themes;
			return SupportedDungeons.ContainsKey(theme);
		}

		internal static void UpdateDungeonLabels()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			EnsureMinimapState();
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			foreach (DungeonPinModel dungeonPin in DungeonPins)
			{
				if (dungeonPin.Pin != null)
				{
					string dungeonLabel = PluginConfig.GetDungeonLabel(dungeonPin.Theme);
					dungeonPin.Pin.m_name = dungeonLabel;
					if (dungeonPin.Pin.m_NamePinData != null && (Object)(object)dungeonPin.Pin.m_NamePinData.PinNameText != (Object)null)
					{
						dungeonPin.Pin.m_NamePinData.PinNameText.text = dungeonLabel;
					}
					dungeonPin.Pin.m_NamePinData = (PinNameData)(string.IsNullOrEmpty(dungeonLabel) ? null : (((object)dungeonPin.Pin.m_NamePinData) ?? ((object)new PinNameData(dungeonPin.Pin))));
				}
			}
			MinimapPinUpdateRequiredField.SetValue(Minimap.instance, true);
		}

		private static bool CreatePin(DungeonPinModel model)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (model == null || (Object)(object)Minimap.instance == (Object)null)
			{
				return false;
			}
			PinData val = Minimap.instance.AddPin(model.Position, (PinType)2, PluginConfig.GetDungeonLabel(model.Theme), true, model.IsChecked, 0L, default(PlatformUserID));
			if (val == null)
			{
				return false;
			}
			model.Pin = val;
			return true;
		}

		private static void AddLoadedDungeonPins(Theme theme)
		{
			//IL_004a: 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)
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			foreach (TrackedDungeonLocation trackedLocation in TrackedDungeonLocation.GetTrackedLocations())
			{
				if (!((Object)(object)trackedLocation == (Object)null) && !((Object)(object)trackedLocation.Location == (Object)null))
				{
					Location location = trackedLocation.Location;
					if (TryGetSupportedDungeonTheme(location, out var theme2) && theme2 == theme)
					{
						TryAddDungeonPin(location);
					}
				}
			}
		}

		private static bool HasDungeonPin(Theme theme, Vector3 position)
		{
			//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_0025: 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)
			float radiusSqr = 25f;
			foreach (DungeonPinModel dungeonPin in DungeonPins)
			{
				if (dungeonPin.Theme == theme && IsWithinRadius(dungeonPin.Position, position, radiusSqr))
				{
					return true;
				}
			}
			return false;
		}

		private static PinData FindExistingDungeonPin(Vector3 position)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return null;
			}
			List<PinData> list = MinimapPins.Invoke(Minimap.instance);
			if (list == null)
			{
				return null;
			}
			float radiusSqr = 0.010000001f;
			foreach (PinData item in list)
			{
				if (item != null && ((int)item.m_type == 2 || (int)item.m_type == 3) && IsWithinRadius(item.m_pos, position, radiusSqr))
				{
					return item;
				}
			}
			return null;
		}

		private static bool IsWithinRadius(Vector3 firstPosition, Vector3 secondPosition, float radiusSqr)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			float num = firstPosition.x - secondPosition.x;
			float num2 = firstPosition.z - secondPosition.z;
			return num * num + num2 * num2 <= radiusSqr;
		}

		private static void RemoveExistingDungeonPins(Theme theme)
		{
			//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_00a8: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			for (int num = DungeonPins.Count - 1; num >= 0; num--)
			{
				DungeonPinModel dungeonPinModel = DungeonPins[num];
				if (dungeonPinModel.Theme == theme)
				{
					if (dungeonPinModel.Pin != null && (Object)(object)Minimap.instance != (Object)null)
					{
						Minimap.instance.RemovePin(dungeonPinModel.Pin);
					}
					DungeonPins.RemoveAt(num);
				}
			}
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			foreach (TrackedDungeonLocation trackedLocation in TrackedDungeonLocation.GetTrackedLocations())
			{
				if ((Object)(object)trackedLocation == (Object)null || (Object)(object)trackedLocation.Location == (Object)null)
				{
					continue;
				}
				Location location = trackedLocation.Location;
				if (TryGetSupportedDungeonTheme(location, out var theme2) && theme2 == theme)
				{
					PinData val = FindExistingDungeonPin(((Component)location).transform.position);
					if (val != null)
					{
						Minimap.instance.RemovePin(val);
					}
				}
			}
		}

		private static void EnsureMinimapState()
		{
			if (!((Object)(object)_trackedMinimap == (Object)(object)Minimap.instance))
			{
				DungeonPins.Clear();
				_trackedMinimap = Minimap.instance;
			}
		}
	}
	internal static class ResourcePinManager
	{
		private const float ResourcePinSize = 20f;

		private const float ClusterRadius = 25f;

		private const float OnionSeedsBorderPadding = -16f;

		private const string OnionSeedsPrefabName = "OnionSeeds";

		private const string OnionSeedsBorderName = "OnionSeedsBorder";

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

		private static readonly Dictionary<string, Sprite> ResourceSprites = new Dictionary<string, Sprite>();

		private static readonly Dictionary<ZDOID, ResourcePinModel> ResourcePinByZdoId = new Dictionary<ZDOID, ResourcePinModel>();

		private static readonly FieldInfo MPinUpdateRequired = AccessTools.Field(typeof(Minimap), "m_pinUpdateRequired");

		private static readonly Dictionary<string, float> ResourceIconSizeOverrides = new Dictionary<string, float>
		{
			{ "TurnipSeeds", 32f },
			{ "CarrotSeeds", 32f },
			{ "Dandelion", 32f },
			{ "CopperOre", 32f },
			{ "SilverOre", 32f },
			{ "Softtissue", 32f },
			{ "OnionSeeds", 32f }
		};

		internal static bool TryAddResourcePin(ResourcePinModel model)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_006b: 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_007e: 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)
			if (model == null || model.ResourceDefinition == null || (Object)(object)Minimap.instance == (Object)null || model.ZdoId == ZDOID.None)
			{
				return false;
			}
			if (!TrackingRangeService.IsWithinTrackingRange(model.Position))
			{
				return false;
			}
			if (ResourcePinByZdoId.ContainsKey(model.ZdoId))
			{
				return false;
			}
			if (HasNearbyResourcePin(model))
			{
				return false;
			}
			string resourcePinLabel = GetResourcePinLabel(model.ResourceDefinition);
			PinData val = Minimap.instance.AddPin(model.Position, (PinType)8, resourcePinLabel, false, false, 0L, default(PlatformUserID));
			Sprite sprite = GetSprite(model.IconItemPrefabName);
			if ((Object)(object)sprite != (Object)null)
			{
				val.m_icon = sprite;
			}
			model.Pin = val;
			ResourcePinByZdoId[model.ZdoId] = model;
			SetPinUpdateRequired();
			return true;
		}

		internal static void UpdateResourcePinVisuals(Minimap minimap)
		{
			if ((Object)(object)minimap == (Object)null)
			{
				return;
			}
			foreach (ResourcePinModel value in ResourcePinByZdoId.Values)
			{
				PinData pin = value.Pin;
				if (pin == null || (Object)(object)pin.m_uiElement == (Object)null)
				{
					value.LastSizedUiElement = null;
					continue;
				}
				float resourcePinSize = GetResourcePinSize(value.IconItemPrefabName);
				if (!((Object)(object)value.LastSizedUiElement == (Object)(object)pin.m_uiElement) || value.LastAppliedSize != resourcePinSize)
				{
					pin.m_uiElement.SetSizeWithCurrentAnchors((Axis)0, resourcePinSize);
					pin.m_uiElement.SetSizeWithCurrentAnchors((Axis)1, resourcePinSize);
					if (value.ResourceDefinition.ResourcePrefabName == "OnionSeeds")
					{
						AddOnionSeedsBorder(pin.m_uiElement, resourcePinSize);
					}
					value.LastSizedUiElement = pin.m_uiElement;
					value.LastAppliedSize = resourcePinSize;
				}
			}
		}

		internal static bool RemoveResourcePin(ZDOID zdoId)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (zdoId == ZDOID.None)
			{
				return false;
			}
			if (!ResourcePinByZdoId.TryGetValue(zdoId, out var value))
			{
				return false;
			}
			if (value.Pin != null && (Object)(object)Minimap.instance != (Object)null)
			{
				Minimap.instance.RemovePin(value.Pin);
			}
			ResourcePinByZdoId.Remove(zdoId);
			SetPinUpdateRequired();
			return true;
		}

		internal static void RemoveResourcePins(string prefabName)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(prefabName))
			{
				return;
			}
			List<ZDOID> list = new List<ZDOID>();
			foreach (KeyValuePair<ZDOID, ResourcePinModel> item in ResourcePinByZdoId)
			{
				if (item.Value.ResourceDefinition.ResourcePrefabName == prefabName)
				{
					list.Add(item.Key);
				}
			}
			foreach (ZDOID item2 in list)
			{
				RemoveResourcePin(item2);
			}
		}

		internal static bool RemoveClosestResourcePin(Vector3 position, float radius)
		{
			//IL_0021: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			ResourcePinModel resourcePinModel = null;
			float num = radius * radius;
			foreach (ResourcePinModel value in ResourcePinByZdoId.Values)
			{
				float num2 = value.Position.x - position.x;
				float num3 = value.Position.z - position.z;
				float num4 = num2 * num2 + num3 * num3;
				if (num4 <= num)
				{
					num = num4;
					resourcePinModel = value;
				}
			}
			if (resourcePinModel == null)
			{
				return false;
			}
			return RemoveResourcePin(resourcePinModel.ZdoId);
		}

		internal static bool RemoveClosestResourcePin(string prefabName, Vector3 position, float radius)
		{
			//IL_0034: 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_0048: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			ResourcePinModel resourcePinModel = null;
			float num = radius * radius;
			foreach (ResourcePinModel value in ResourcePinByZdoId.Values)
			{
				if (!(value.ResourceDefinition.ResourcePrefabName != prefabName))
				{
					float num2 = value.Position.x - position.x;
					float num3 = value.Position.z - position.z;
					float num4 = num2 * num2 + num3 * num3;
					if (num4 <= num)
					{
						num = num4;
						resourcePinModel = value;
					}
				}
			}
			if (resourcePinModel == null)
			{
				return false;
			}
			return RemoveResourcePin(resourcePinModel.ZdoId);
		}

		internal static bool HasResourcePin(ZDOID zdoId)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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)
			if (zdoId != ZDOID.None)
			{
				return ResourcePinByZdoId.ContainsKey(zdoId);
			}
			return false;
		}

		internal static void UpdateDepositLabels()
		{
			foreach (ResourcePinModel value in ResourcePinByZdoId.Values)
			{
				if (value.ResourceDefinition.ResourceType == TrackedResourceTypeEnum.Deposit && value.Pin != null)
				{
					value.Pin.m_name = PluginConfig.GetDepositLabel(value.ResourceDefinition.ResourcePrefabName);
				}
			}
			SetPinUpdateRequired();
		}

		private static bool HasNearbyResourcePin(ResourcePinModel model)
		{
			//IL_003e: 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_0056: 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)
			float num = 625f;
			foreach (ResourcePinModel value in ResourcePinByZdoId.Values)
			{
				if (!(value.ResourceDefinition.ResourcePrefabName != model.ResourceDefinition.ResourcePrefabName))
				{
					float num2 = value.Position.x - model.Position.x;
					float num3 = value.Position.z - model.Position.z;
					if (num2 * num2 + num3 * num3 <= num)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static Sprite GetSprite(string prefabName)
		{
			if (string.IsNullOrWhiteSpace(prefabName))
			{
				return null;
			}
			if (ResourceSprites.TryGetValue(prefabName, out var value))
			{
				return value;
			}
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				return null;
			}
			ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component == (Object)null)
			{
				return null;
			}
			Sprite icon = component.m_itemData.GetIcon();
			ResourceSprites[prefabName] = icon;
			return icon;
		}

		private static float GetResourcePinSize(string iconItemPrefabName)
		{
			if (!string.IsNullOrWhiteSpace(iconItemPrefabName) && ResourceIconSizeOverrides.TryGetValue(iconItemPrefabName, out var value))
			{
				return value;
			}
			return 20f;
		}

		private static void AddOnionSeedsBorder(RectTransform pinUiElement, float iconSize)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			//IL_005b: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: 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)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_019c: 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)
			if (!((Object)(object)((Transform)pinUiElement).Find("OnionSeedsBorder") != (Object)null))
			{
				GameObject val = new GameObject("OnionSeedsBorder");
				val.transform.SetParent((Transform)(object)pinUiElement, false);
				val.transform.SetAsFirstSibling();
				RectTransform obj = val.AddComponent<RectTransform>();
				obj.anchorMin = new Vector2(0.5f, 0.5f);
				obj.anchorMax = new Vector2(0.5f, 0.5f);
				obj.pivot = new Vector2(0.5f, 0.5f);
				obj.anchoredPosition = Vector2.zero;
				float num = iconSize + -16f;
				obj.sizeDelta = new Vector2(num, num);
				AddBorderEdge(obj, "Top", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(0f, -2f), new Vector2(0f, 2f));
				AddBorderEdge(obj, "Bottom", new Vector2(0f, 0f), new Vector2(1f, 0f), new Vector2(0f, 0f), new Vector2(0f, 2f));
				AddBorderEdge(obj, "Left", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(0f, 0f), new Vector2(2f, 0f));
				AddBorderEdge(obj, "Right", new Vector2(1f, 0f), new Vector2(1f, 1f), new Vector2(-2f, 0f), new Vector2(2f, 0f));
			}
		}

		private static void AddBorderEdge(RectTransform parent, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 anchoredPosition, Vector2 sizeDelta)
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent((Transform)(object)parent, false);
			RectTransform obj = val.AddComponent<RectTransform>();
			obj.anchorMin = anchorMin;
			obj.anchorMax = anchorMax;
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.anchoredPosition = anchoredPosition;
			obj.sizeDelta = sizeDelta;
			Image obj2 = val.AddComponent<Image>();
			((Graphic)obj2).color = OnionSeedsBorderColor;
			((Graphic)obj2).raycastTarget = false;
		}

		private static void SetPinUpdateRequired()
		{
			if (!((Object)(object)Minimap.instance == (Object)null))
			{
				MPinUpdateRequired.SetValue(Minimap.instance, true);
			}
		}

		private static string GetResourcePinLabel(TrackedResourceDefinition definition)
		{
			if (definition.ResourceType != TrackedResourceTypeEnum.Deposit)
			{
				return string.Empty;
			}
			return PluginConfig.GetDepositLabel(definition.ResourcePrefabName);
		}
	}
}