Decompiled source of HexResourceTracker v1.2.0

Plugins/HexResourceTracker.dll

Decompiled 2 weeks 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 HexResourceTracker.Core;
using HexResourceTracker.Models;
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("HexResourceTracker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HexResourceTracker")]
[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")]
namespace HexResourceTracker
{
	internal static class DungeonPinManager
	{
		private const float DuplicateRadius = 5f;

		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 Minimap _trackedMinimap;

		internal static bool TryAddDungeonPin(Location location)
		{
			//IL_002b: 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_004c: 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_004e: 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_005a: 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)
			//IL_0062: 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;
			}
			if (!PluginConfig.IsDungeonTrackingEnabled(theme))
			{
				return false;
			}
			string prefabName = Utils.GetPrefabName(((Component)location).gameObject);
			Vector3 position = ((Component)location).transform.position;
			if (HasDungeonPin(theme, position))
			{
				return false;
			}
			DungeonPinModel dungeonPinModel = new DungeonPinModel(theme, prefabName, position);
			PinData val = FindExistingDungeonPin(theme, 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_0010: 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);
			}
		}

		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, GetDungeonName(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_002a: 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)
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return;
			}
			Location[] array = Object.FindObjectsByType<Location>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			int num = 0;
			Location[] array2 = array;
			foreach (Location location in array2)
			{
				if (TryGetSupportedDungeonTheme(location, out var theme2) && theme2 == theme && TryAddDungeonPin(location))
				{
					num++;
				}
			}
		}

		private static bool TryGetSupportedDungeonTheme(Location location, out Theme theme)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected I4, but got Unknown
			theme = (Theme)0;
			if ((Object)(object)location == (Object)null || !location.m_hasInterior)
			{
				return false;
			}
			DungeonGenerator componentInChildren = ((Component)location).GetComponentInChildren<DungeonGenerator>(true);
			if ((Object)(object)componentInChildren == (Object)null || (int)componentInChildren.m_algorithm != 0)
			{
				return false;
			}
			theme = (Theme)(int)componentInChildren.m_themes;
			return IsSupportedDungeon(theme);
		}

		private static bool IsSupportedDungeon(Theme theme)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			if ((int)theme <= 4)
			{
				if ((int)theme == 2 || (int)theme == 4)
				{
					goto IL_001a;
				}
			}
			else if ((int)theme == 8 || (int)theme == 128)
			{
				goto IL_001a;
			}
			return false;
			IL_001a:
			return true;
		}

		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(Theme theme, Vector3 position)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return null;
			}
			List<PinData> list = MinimapPins.Invoke(Minimap.instance);
			if (list == null)
			{
				return null;
			}
			string dungeonName = GetDungeonName(theme);
			float radiusSqr = 25f;
			foreach (PinData item in list)
			{
				if (IsMatchingDungeonPin(item, dungeonName) && 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 int RemoveExistingDungeonPins(Theme theme)
		{
			//IL_0000: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			string dungeonName = GetDungeonName(theme);
			int num = 0;
			for (int num2 = DungeonPins.Count - 1; num2 >= 0; num2--)
			{
				DungeonPinModel dungeonPinModel = DungeonPins[num2];
				if (dungeonPinModel.Theme == theme)
				{
					if (dungeonPinModel.Pin != null && (Object)(object)Minimap.instance != (Object)null)
					{
						Minimap.instance.RemovePin(dungeonPinModel.Pin);
					}
					DungeonPins.RemoveAt(num2);
					num++;
				}
			}
			if ((Object)(object)Minimap.instance == (Object)null)
			{
				return num;
			}
			List<PinData> list = MinimapPins.Invoke(Minimap.instance);
			if (list == null)
			{
				return num;
			}
			for (int num3 = list.Count - 1; num3 >= 0; num3--)
			{
				PinData val = list[num3];
				if (IsMatchingDungeonPin(val, dungeonName))
				{
					Minimap.instance.RemovePin(val);
					num++;
				}
			}
			return num;
		}

		private static bool IsMatchingDungeonPin(PinData pin, string dungeonName)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			if (pin == null || pin.m_name != dungeonName)
			{
				return false;
			}
			if ((int)pin.m_type != 2)
			{
				return (int)pin.m_type == 3;
			}
			return true;
		}

		private static void EnsureMinimapState()
		{
			if (!((Object)(object)_trackedMinimap == (Object)(object)Minimap.instance))
			{
				DungeonPins.Clear();
				_trackedMinimap = Minimap.instance;
			}
		}

		private static string GetDungeonName(Theme theme)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			if ((int)theme <= 4)
			{
				if ((int)theme == 2)
				{
					return "Sunken Crypt";
				}
				if ((int)theme == 4)
				{
					return "Frost Cave";
				}
			}
			else
			{
				if ((int)theme == 8)
				{
					return "Burial Chamber";
				}
				if ((int)theme == 128)
				{
					return "Infested Mine";
				}
			}
			return "Dungeon";
		}
	}
	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("com.hex.resourcetracker", "HexResourceTracker", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PluginGuid = "com.hex.resourcetracker";

		private const string PluginName = "HexResourceTracker";

		private const string PluginVersion = "1.2.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("com.hex.resourcetracker");
			_harmonyInstance.PatchAll(executingAssembly);
			Log.LogInfo((object)"HexResourceTracker v1.2.0 loaded.");
		}

		private void OnDestroy()
		{
			Log.LogInfo((object)"HexResourceTracker v1.2.0 unloaded.");
			Harmony harmonyInstance = _harmonyInstance;
			if (harmonyInstance != null)
			{
				harmonyInstance.UnpatchSelf();
			}
			_harmonyInstance = null;
			Instance = null;
			Log = null;
		}
	}
	internal static class PluginConfig
	{
		private const string GeneralSection = "General";

		private const string ResourcesSection = "Resources To Track";

		private const string DungeonsSection = "Dungeons To Track";

		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 ConfigEntry<bool> IsModEnabled { get; private set; }

		internal static void Initialize(ConfigFile config)
		{
			IsModEnabled = config.Bind<bool>("General", "Enable", true, "Enable or disable the HexResourceTracker mod.");
			BindResource(config, "Pickable_Mushroom", "Mushrooms");
			BindResource(config, "Pickable_Dandelion", "Dandelions");
			BindResource(config, "RaspberryBush", "Raspberries");
			BindResource(config, "BlueberryBush", "Blueberries");
			BindResource(config, "Pickable_Thistle", "Thistle");
			BindResource(config, "Pickable_SeedCarrot", "Carrot Seeds");
			BindResource(config, "Pickable_SeedTurnip", "Turnip Seeds");
			BindResource(config, "Pickable_Flax_Wild", "Flax");
			BindResource(config, "Pickable_Barley_Wild", "Barley");
			BindResource(config, "CloudberryBush", "Cloudberries");
			BindResource(config, "Pickable_Mushroom_JotunPuffs", "Jotun Puffs");
			BindResource(config, "Pickable_Mushroom_Magecap", "Magecap");
			BindResource(config, "rock4_copper", "Copper");
			BindResource(config, "silvervein", "Silver");
			BindResource(config, "giant_skull", "Giant Skull");
			BindResource(config, "LeviathanLava", "Flametal");
			BindResource(config, "VineAsh", "Vineberries");
			BindResource(config, "Pickable_SmokePuff", "Smoke Puffs");
			BindResource(config, "Pickable_Fiddlehead", "Fiddleheads");
			BindDungeon(config, (Theme)8, "Burial Chambers");
			BindDungeon(config, (Theme)2, "Sunken Crypts");
			BindDungeon(config, (Theme)4, "Frost Caves");
			BindDungeon(config, (Theme)128, "Infested Mines");
		}

		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;
		}

		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
			{
				ResourceTrackerMapOverlay.HandleResourceTrackingChanged(prefabName, entry.Value);
				PickableResourcePinService.HandleResourceTrackingChanged(prefabName, entry.Value);
				OreResourcePinService.HandleResourceTrackingChanged(prefabName, entry.Value);
			};
			ResourceConfigs[prefabName] = entry;
		}

		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)
				ResourceTrackerMapOverlay.HandleDungeonTrackingChanged(theme, entry.Value);
				DungeonPinManager.HandleDungeonTrackingChanged(theme, entry.Value);
			};
			DungeonConfigs[theme] = entry;
		}
	}
}
namespace HexResourceTracker.Patches
{
	[HarmonyPatch(typeof(Destructible), "Awake")]
	internal static class PatchDestructibleAwake
	{
		private static void Postfix(Destructible __instance)
		{
			if (PluginConfig.IsModEnabled.Value && !((Object)(object)__instance == (Object)null))
			{
				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))
			{
				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))
			{
				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)
			{
				ResourceTrackerMapOverlay.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
			{
				PickableResourcePinService.TryAddResourcePinFromPickable(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Pickable), "Awake")]
	internal static class PatchPickableAwake
	{
		private static void Postfix(Pickable __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				PickableResourcePinService.TryAddResourcePinFromPickable(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(Minimap), "UpdatePins")]
	internal static class PatchMinimapUpdatePins
	{
		private static void Postfix(Minimap __instance)
		{
			if (PluginConfig.IsModEnabled.Value)
			{
				ResourcePinManager.UpdateResourcePinVisuals(__instance);
			}
		}
	}
}
namespace HexResourceTracker.Models
{
	internal class ResourceDefinitionModel
	{
		internal string ResourcePrefabName { get; }

		internal string ItemPrefabName { get; }

		internal ResourceDefinitionModel(string resourcePrefabName, string itemPrefabName)
		{
			ResourcePrefabName = resourcePrefabName;
			ItemPrefabName = itemPrefabName;
		}
	}
	internal class ResourcePinModel
	{
		internal ZDOID ZdoId { get; }

		internal string PickablePrefabName { get; }

		internal string ItemPrefabName { get; }

		internal Vector3 Position { get; }

		internal PinData Pin { get; set; }

		internal RectTransform LastSizedUiElement { get; set; }

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

		public ResourcePinModel(ZDOID zdoid, string pickablePrefabName, string itemPrefabName, 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;
			PickablePrefabName = pickablePrefabName;
			ItemPrefabName = itemPrefabName;
			Position = position;
		}
	}
}
namespace HexResourceTracker.Core
{
	internal static class OreResourcePinService
	{
		private const float MineRockRelinkRadius = 35f;

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

		internal static bool TryAddResourcePinFromDestructibleOre(Destructible destructible)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destructible == (Object)null || (Object)(object)Minimap.instance == (Object)null)
			{
				return false;
			}
			string key = ((Object)((Component)destructible).gameObject).name.Replace("(Clone)", string.Empty).Trim();
			if (!TrackedResourceDefinitions.DestructibleResourcesByPrefabName.TryGetValue(key, out var value))
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(value.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, value.ResourcePrefabName, value.ItemPrefabName, ((Component)destructible).transform.position));
		}

		internal static bool TryAddOrRelinkResourcePinFromMineRock5Ore(MineRock5 mineRock)
		{
			//IL_0064: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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 (!TrackedResourceDefinitions.MineRock5ResourcesByName.TryGetValue(mineRock.m_name, out var value))
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(value.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(value.ResourcePrefabName, ((Component)mineRock).transform.position, 35f);
			return ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, value.ResourcePrefabName, value.ItemPrefabName, ((Component)mineRock).transform.position));
		}

		internal static bool TryAddResourcePinFromMineRock(MineRock mineRock)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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 (!TrackedResourceDefinitions.MineRockResourcesByName.TryGetValue(mineRock.m_name, out var value))
			{
				return false;
			}
			if (!PluginConfig.IsResourceTrackingEnabled(value.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, value.ResourcePrefabName, value.ItemPrefabName, ((Component)mineRock).transform.position));
		}

		internal static bool TryRemoveResourcePinFromDestructibleOre(Destructible destructible)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destructible == (Object)null)
			{
				return false;
			}
			string key = ((Object)((Component)destructible).gameObject).name.Replace("(Clone)", string.Empty).Trim();
			if (!TrackedResourceDefinitions.DestructibleResourcesByPrefabName.ContainsKey(key))
			{
				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_0046: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mineRock == (Object)null)
			{
				return false;
			}
			if (!TrackedResourceDefinitions.MineRockResourcesByName.ContainsKey(mineRock.m_name))
			{
				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) && (TrackedResourceDefinitions.DestructibleResourcesByPrefabName.ContainsKey(prefabName) || TrackedResourceDefinitions.MineRockResourcesByName.Values.Any((ResourceDefinitionModel definition) => definition.ResourcePrefabName == prefabName) || TrackedResourceDefinitions.MineRock5ResourcesByName.Values.Any((ResourceDefinitionModel definition) => definition.ResourcePrefabName == prefabName)))
			{
				if (!isEnabled)
				{
					ResourcePinManager.RemoveResourcePins(prefabName);
				}
				else if (!((Object)(object)Minimap.instance == (Object)null))
				{
					RescanLoadedDestructibles(prefabName);
					RescanLoadedMineRock5(prefabName);
					RescanLoadedMineRock(prefabName);
				}
			}
		}

		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) && TrackedResourceDefinitions.MineRock5ResourcesByName.TryGetValue(val.m_name, out var value) && !(value.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) && TrackedResourceDefinitions.MineRockResourcesByName.TryGetValue(val.m_name, out var value) && !(value.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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(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;
			}
			string pickablePrefabName = ((Object)((Component)pickable).gameObject).name.Replace("(Clone)", string.Empty).Trim();
			if (!IsTrackedPickablePrefab(pickablePrefabName))
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (zDO == null)
			{
				return false;
			}
			return ResourcePinManager.TryAddResourcePin(new ResourcePinModel(zDO.m_uid, pickablePrefabName, ((Object)pickable.m_itemPrefab).name, ((Component)pickable).transform.position));
		}

		internal static void HandleResourceTrackingChanged(string pickablePrefabName, bool isEnabled)
		{
			if (string.IsNullOrWhiteSpace(pickablePrefabName))
			{
				return;
			}
			if (!isEnabled)
			{
				ResourcePinManager.RemoveResourcePins(pickablePrefabName);
			}
			else
			{
				if (!IsTrackedPickablePrefab(pickablePrefabName) || (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() != pickablePrefabName))
					{
						TryAddResourcePinFromPickable(val);
					}
				}
			}
		}

		private static bool IsTrackedPickablePrefab(string pickablePrefabName)
		{
			return PluginConfig.IsResourceTrackingEnabled(pickablePrefabName);
		}
	}
	internal class ResourceTrackerDragHandler : 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 ResourcePinManager
	{
		private const float ResourcePinSize = 20f;

		private const float ClusterRadius = 25f;

		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 }
		};

		internal static bool TryAddResourcePin(ResourcePinModel model)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			if (model == null || (Object)(object)Minimap.instance == (Object)null || model.ZdoId == ZDOID.None)
			{
				return false;
			}
			if (ResourcePinByZdoId.ContainsKey(model.ZdoId))
			{
				return false;
			}
			if (HasNearbyResourcePin(model))
			{
				return false;
			}
			PinData val = Minimap.instance.AddPin(model.Position, (PinType)8, string.Empty, false, false, 0L, default(PlatformUserID));
			Sprite sprite = GetSprite(model.ItemPrefabName);
			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.ItemPrefabName);
				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);
					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_003b: 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)
			if (string.IsNullOrWhiteSpace(prefabName))
			{
				return;
			}
			List<ZDOID> list = new List<ZDOID>();
			foreach (KeyValuePair<ZDOID, ResourcePinModel> item in ResourcePinByZdoId)
			{
				if (item.Value.PickablePrefabName == 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_008c: 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.PickablePrefabName != 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;
		}

		private static bool HasNearbyResourcePin(ResourcePinModel model)
		{
			//IL_0034: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			float num = 625f;
			foreach (ResourcePinModel value in ResourcePinByZdoId.Values)
			{
				if (!(value.PickablePrefabName != model.PickablePrefabName))
				{
					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 itemPrefabName)
		{
			if (!string.IsNullOrWhiteSpace(itemPrefabName) && ResourceIconSizeOverrides.TryGetValue(itemPrefabName, out var value))
			{
				return value;
			}
			return 20f;
		}

		private static void SetPinUpdateRequired()
		{
			if (!((Object)(object)Minimap.instance == (Object)null))
			{
				MPinUpdateRequired.SetValue(Minimap.instance, true);
			}
		}
	}
	internal static class ResourceTrackerMapOverlay
	{
		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("HexResourceTrackerOverlay");
				_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, 680f);
				((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_Flax_Wild", "Flax", -235f);
				AddResourceToggle("Pickable_Barley_Wild", "Barley", -260f);
				AddResourceToggle("CloudberryBush", "Cloudberries", -285f);
				AddResourceToggle("Pickable_Mushroom_JotunPuffs", "Jotun Puffs", -310f);
				AddResourceToggle("Pickable_Mushroom_Magecap", "Magecap", -335f);
				AddResourceToggle("rock4_copper", "Copper", -360f);
				AddResourceToggle("silvervein", "Silver", -385f);
				AddResourceToggle("giant_skull", "Giant Skull", -410f);
				AddResourceToggle("LeviathanLava", "Flametal", -435f);
				AddResourceToggle("VineAsh", "Vineberries", -460f);
				AddResourceToggle("Pickable_SmokePuff", "Smoke Puffs", -485f);
				AddResourceToggle("Pickable_Fiddlehead", "Fiddleheads", -510f);
				AddSectionHeader("Dungeons", -540f);
				AddDungeonToggle((Theme)8, "Burial Chambers", -568f);
				AddDungeonToggle((Theme)2, "Sunken Crypts", -593f);
				AddDungeonToggle((Theme)4, "Frost Caves", -618f);
				AddDungeonToggle((Theme)128, "Infested Mines", -643f);
			}
		}

		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<ResourceTrackerDragHandler>();
			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;
		}
	}
	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")
		} };
	}
}