Decompiled source of NotYourRadar v0.1.2

NotYourRadar.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NotYourRadar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NotYourRadar")]
[assembly: AssemblyTitle("NotYourRadar")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BetterRadar;

internal static class BetterRadarMapUI
{
	[HarmonyPatch(typeof(UnifiedPopup), "Awake")]
	private static class UnifiedPopupAwakePatch
	{
		private static void Postfix(Button ___buttonRight)
		{
			if ((Object)(object)___buttonRight != (Object)null)
			{
				NativeButtonTemplate = ((Component)___buttonRight).gameObject;
			}
			TryCreateUI();
		}
	}

	[HarmonyPatch(typeof(InventoryGui), "Awake")]
	private static class InventoryGuiAwakePatch
	{
		private static void Postfix(InventoryGui __instance)
		{
			Transform val = ((Component)__instance).transform.Find("root/Skills/SkillsFrame/bkg");
			if ((Object)(object)val != (Object)null)
			{
				NativePanelTemplate = ((Component)val).gameObject;
				BetterRadarPlugin.Log.LogInfo((object)"Captured native Valheim lit panel template.");
			}
			if ((Object)(object)__instance.m_recipeListScroll != (Object)null)
			{
				NativeScrollbarTemplate = ((Component)__instance.m_recipeListScroll).gameObject;
			}
			TryCreateUI();
		}
	}

	[HarmonyPatch(typeof(Minimap), "Awake")]
	private static class MinimapAwakePatch
	{
		private static void Postfix(Minimap __instance)
		{
			CurrentMap = __instance;
			Transform val = __instance.m_largeRoot.transform.Find("SharedPanel/PublicPosition");
			if ((Object)(object)val != (Object)null)
			{
				NativeToggleTemplate = ((Component)val).gameObject;
			}
			TryCreateUI();
		}
	}

	[HarmonyPatch(typeof(Minimap), "SetMapMode")]
	private static class MinimapSetMapModePatch
	{
		private static void Postfix(MapMode mode)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			if ((int)mode != 2)
			{
				CloseSettingsPanel();
			}
		}
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static PopupButtonCallback <>9__132_0;

		public static PopupButtonCallback <>9__132_1;

		public static PopupButtonCallback <>9__133_0;

		public static PopupButtonCallback <>9__133_1;

		internal void <ShowClearConfirmation>b__132_0()
		{
			UnifiedPopup.Pop();
			PersistentPins.ClearPins();
		}

		internal void <ShowClearConfirmation>b__132_1()
		{
			UnifiedPopup.Pop();
		}

		internal void <ShowForgetConfirmation>b__133_0()
		{
			UnifiedPopup.Pop();
			PersistentPins.ForgetDiscoveries();
		}

		internal void <ShowForgetConfirmation>b__133_1()
		{
			UnifiedPopup.Pop();
		}
	}

	private static GameObject NativeButtonTemplate;

	private static GameObject NativePanelTemplate;

	private static GameObject NativeToggleTemplate;

	private static GameObject NativeScrollbarTemplate;

	private static GameObject MapPinsToggleObject;

	private static GameObject MapRescanPinsButton;

	private static GameObject MapMarkersToggleObject;

	private static GameObject SettingsPanel;

	private static GameObject AutoPinSelectionPanel;

	private static GameObject NearbyMarkerSelectionPanel;

	private static RectTransform AutoPinSelectionContent;

	private static RectTransform NearbyMarkerSelectionContent;

	private static bool PinsMeadowsExpanded;

	private static bool PinsBlackForestExpanded;

	private static bool PinsSwampExpanded;

	private static bool PinsMountainsExpanded;

	private static bool PinsPlainsExpanded;

	private static bool PinsMistlandsExpanded;

	private static bool PinsAshlandsExpanded;

	private static bool PinsDeepNorthExpanded;

	private static GameObject PinsMeadowsHeader;

	private static GameObject PinsBlackForestHeader;

	private static GameObject PinsSwampHeader;

	private static GameObject PinsMountainsHeader;

	private static GameObject PinsPlainsHeader;

	private static GameObject PinsMistlandsHeader;

	private static GameObject PinsAshlandsHeader;

	private static GameObject PinsDeepNorthHeader;

	private static readonly List<GameObject> PinsMeadowsRows = new List<GameObject>();

	private static readonly List<GameObject> PinsBlackForestRows = new List<GameObject>();

	private static readonly List<GameObject> PinsSwampRows = new List<GameObject>();

	private static bool MarkersMeadowsExpanded;

	private static bool MarkersBlackForestExpanded;

	private static bool MarkersSwampExpanded;

	private static bool MarkersMountainsExpanded;

	private static bool MarkersPlainsExpanded;

	private static bool MarkersMistlandsExpanded;

	private static bool MarkersAshlandsExpanded;

	private static bool MarkersDeepNorthExpanded;

	private static bool MarkersOceanExpanded;

	private static bool MarkersHerbalistExpanded;

	private static bool MarkersValharvestExpanded;

	private static GameObject MarkersMeadowsHeader;

	private static GameObject MarkersBlackForestHeader;

	private static GameObject MarkersSwampHeader;

	private static GameObject MarkersMountainsHeader;

	private static GameObject MarkersPlainsHeader;

	private static GameObject MarkersMistlandsHeader;

	private static GameObject MarkersAshlandsHeader;

	private static GameObject MarkersDeepNorthHeader;

	private static GameObject MarkersOceanHeader;

	private static GameObject MarkersHerbalistHeader;

	private static GameObject MarkersValharvestHeader;

	private static readonly List<GameObject> MarkersMeadowsRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersBlackForestRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersSwampRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersMountainsRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersPlainsRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersMistlandsRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersAshlandsRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersDeepNorthRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersOceanRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersHerbalistRows = new List<GameObject>();

	private static readonly List<GameObject> MarkersValharvestRows = new List<GameObject>();

	private static Minimap CurrentMap;

	private static void TryCreateUI()
	{
		if (!((Object)(object)CurrentMap == (Object)null) && !((Object)(object)CurrentMap.m_largeRoot == (Object)null) && !((Object)(object)NativeButtonTemplate == (Object)null) && !((Object)(object)NativePanelTemplate == (Object)null) && !((Object)(object)NativeToggleTemplate == (Object)null) && !((Object)(object)NativeScrollbarTemplate == (Object)null))
		{
			if ((Object)(object)MapPinsToggleObject == (Object)null)
			{
				CreateMapQuickToggles();
			}
			if ((Object)(object)SettingsPanel == (Object)null)
			{
				CreateSettingsPanel();
			}
			if ((Object)(object)AutoPinSelectionPanel == (Object)null)
			{
				CreateAutoPinSelectionPanel();
			}
			if ((Object)(object)NearbyMarkerSelectionPanel == (Object)null)
			{
				CreateNearbyMarkerSelectionPanel();
			}
		}
	}

	private static void CreateAutoPinSelectionPanel()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Expected O, but got Unknown
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Expected O, but got Unknown
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Expected O, but got Unknown
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Expected O, but got Unknown
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Expected O, but got Unknown
		AutoPinSelectionPanel = Object.Instantiate<GameObject>(NativePanelTemplate, CurrentMap.m_largeRoot.transform);
		((Object)AutoPinSelectionPanel).name = "BetterRadarAutoPinSelectionPanel";
		ConfigureSelectionPanel(AutoPinSelectionPanel);
		CreateSelectionTitle(AutoPinSelectionPanel.transform, "Pin Selection");
		AutoPinSelectionContent = CreateSelectionScrollView(AutoPinSelectionPanel.transform, "AutoPin");
		PinsMeadowsHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Meadows", 0f, new UnityAction(TogglePinsMeadows));
		PinsBlackForestHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Black Forest", -45f, new UnityAction(TogglePinsBlackForest));
		PinsSwampHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Swamp", -90f, new UnityAction(TogglePinsSwamp));
		PinsMountainsHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Mountains", -135f, new UnityAction(TogglePinsMountains));
		PinsPlainsHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Plains", -180f, new UnityAction(TogglePinsPlains));
		PinsMistlandsHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Mistlands", -225f, new UnityAction(TogglePinsMistlands));
		PinsAshlandsHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Ashlands", -270f, new UnityAction(TogglePinsAshlands));
		PinsDeepNorthHeader = CreateBiomeHeader((Transform)(object)AutoPinSelectionContent, "Deep North", -315f, new UnityAction(TogglePinsDeepNorth));
		RefreshPinSelectionRows();
		CreateSelectionPanelButton(AutoPinSelectionPanel.transform, "Back", new Vector2(0f, 12f), new UnityAction(ShowSettingsPanel));
		AutoPinSelectionPanel.SetActive(false);
	}

	private static void CreateNearbyMarkerSelectionPanel()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Expected O, but got Unknown
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Expected O, but got Unknown
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Expected O, but got Unknown
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Expected O, but got Unknown
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Expected O, but got Unknown
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Expected O, but got Unknown
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Expected O, but got Unknown
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Expected O, but got Unknown
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Expected O, but got Unknown
		NearbyMarkerSelectionPanel = Object.Instantiate<GameObject>(NativePanelTemplate, CurrentMap.m_largeRoot.transform);
		((Object)NearbyMarkerSelectionPanel).name = "BetterRadarNearbyMarkerSelectionPanel";
		ConfigureSelectionPanel(NearbyMarkerSelectionPanel);
		CreateSelectionTitle(NearbyMarkerSelectionPanel.transform, "Nearby Marker Selection");
		NearbyMarkerSelectionContent = CreateSelectionScrollView(NearbyMarkerSelectionPanel.transform, "NearbyMarker");
		float num = 0f;
		MarkersMeadowsHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Meadows", num, new UnityAction(ToggleMarkersMeadows));
		num -= 45f;
		MarkersBlackForestHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Black Forest", num, new UnityAction(ToggleMarkersBlackForest));
		num -= 45f;
		MarkersSwampHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Swamp", num, new UnityAction(ToggleMarkersSwamp));
		num -= 45f;
		MarkersMountainsHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Mountains", num, new UnityAction(ToggleMarkersMountains));
		num -= 45f;
		MarkersPlainsHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Plains", num, new UnityAction(ToggleMarkersPlains));
		num -= 45f;
		MarkersMistlandsHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Mistlands", num, new UnityAction(ToggleMarkersMistlands));
		num -= 45f;
		MarkersAshlandsHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Ashlands", num, new UnityAction(ToggleMarkersAshlands));
		num -= 45f;
		MarkersDeepNorthHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Deep North", num, new UnityAction(ToggleMarkersDeepNorth));
		num -= 45f;
		MarkersOceanHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Ocean", num, new UnityAction(ToggleMarkersOcean));
		num -= 45f;
		if (ModCompatibility.HerbalistLoaded)
		{
			MarkersHerbalistHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Herbalist", num, new UnityAction(ToggleMarkersHerbalist));
			num -= 45f;
		}
		if (ModCompatibility.ValharvestLoaded)
		{
			MarkersValharvestHeader = CreateBiomeHeader((Transform)(object)NearbyMarkerSelectionContent, "Valharvest", num, new UnityAction(ToggleMarkersValharvest));
		}
		RefreshMarkerSelectionRows();
		CreateSelectionPanelButton(NearbyMarkerSelectionPanel.transform, "Back", new Vector2(0f, 15f), new UnityAction(ShowSettingsPanel));
		NearbyMarkerSelectionPanel.SetActive(false);
	}

	internal static void ApplyScrollSpeed()
	{
		float value = BetterRadarPlugin.UiScrollSpeed.Value;
		if ((Object)(object)AutoPinSelectionPanel != (Object)null)
		{
			ScrollRect[] componentsInChildren = AutoPinSelectionPanel.GetComponentsInChildren<ScrollRect>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].scrollSensitivity = value;
			}
		}
		if ((Object)(object)NearbyMarkerSelectionPanel != (Object)null)
		{
			ScrollRect[] componentsInChildren = NearbyMarkerSelectionPanel.GetComponentsInChildren<ScrollRect>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].scrollSensitivity = value;
			}
		}
	}

	private static RectTransform CreateSelectionScrollView(Transform parent, string prefix)
	{
		//IL_002b: 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_003d: 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_0063: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(prefix + "ScrollView", new Type[2]
		{
			typeof(RectTransform),
			typeof(ScrollRect)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 0f);
		component.anchorMax = new Vector2(1f, 1f);
		component.offsetMin = new Vector2(35f, 60f);
		component.offsetMax = new Vector2(-35f, -65f);
		ScrollRect component2 = val.GetComponent<ScrollRect>();
		RectTransform val2 = CreateSelectionViewport(val.transform, prefix);
		RectTransform val3 = CreateSelectionContent((Transform)(object)val2, prefix);
		Scrollbar verticalScrollbar = CreateSelectionScrollbar(val.transform, prefix);
		component2.viewport = val2;
		component2.content = val3;
		component2.horizontal = false;
		component2.vertical = true;
		component2.verticalScrollbar = verticalScrollbar;
		component2.scrollSensitivity = BetterRadarPlugin.UiScrollSpeed.Value;
		return val3;
	}

	private static RectTransform CreateSelectionViewport(Transform parent, string prefix)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_0091: 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)
		GameObject val = new GameObject(prefix + "Viewport", new Type[3]
		{
			typeof(RectTransform),
			typeof(Image),
			typeof(RectMask2D)
		});
		val.transform.SetParent(parent, false);
		Image component = val.GetComponent<Image>();
		((Graphic)component).color = new Color(0f, 0f, 0f, 0f);
		((Graphic)component).raycastTarget = true;
		RectTransform component2 = val.GetComponent<RectTransform>();
		component2.anchorMin = Vector2.zero;
		component2.anchorMax = Vector2.one;
		component2.offsetMin = Vector2.zero;
		component2.offsetMax = new Vector2(-24f, 0f);
		return component2;
	}

	private static RectTransform CreateSelectionContent(Transform parent, string prefix)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(prefix + "Content", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = Vector2.zero;
		component.sizeDelta = new Vector2(0f, 400f);
		return component;
	}

	private static Scrollbar CreateSelectionScrollbar(Transform parent, string prefix)
	{
		//IL_0034: 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_005e: 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)
		GameObject obj = Object.Instantiate<GameObject>(NativeScrollbarTemplate, parent);
		((Object)obj).name = prefix + "Scrollbar";
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(1f, 0f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(1f, 1f);
		component.anchoredPosition = Vector2.zero;
		component.sizeDelta = new Vector2(18f, 0f);
		Scrollbar component2 = obj.GetComponent<Scrollbar>();
		((UnityEventBase)component2.onValueChanged).RemoveAllListeners();
		component2.direction = (Direction)2;
		return component2;
	}

	private static void CreateSelectionTitle(Transform parent, string titleText)
	{
		//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)
		//IL_0037: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Title", new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 1f);
		component.anchorMax = new Vector2(0.5f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(0f, -20f);
		component.sizeDelta = new Vector2(460f, 42f);
		TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component2).text = titleText;
		((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
		((TMP_Text)component2).fontSize = 26f;
		((Graphic)component2).color = new Color(0.93f, 0.66f, 0.21f, 1f);
		((Graphic)component2).raycastTarget = false;
		if ((Object)(object)CurrentMap.m_biomeNameLarge != (Object)null && (Object)(object)CurrentMap.m_biomeNameLarge.font != (Object)null)
		{
			((TMP_Text)component2).font = CurrentMap.m_biomeNameLarge.font;
		}
	}

	private static GameObject CreateSelectionPanelButton(Transform parent, string labelText, Vector2 position, UnityAction action)
	{
		//IL_0023: 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_004d: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = Object.Instantiate<GameObject>(NativeButtonTemplate, parent);
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0f);
		component.anchorMax = new Vector2(0.5f, 0f);
		component.pivot = new Vector2(0.5f, 0f);
		component.anchoredPosition = position;
		component.sizeDelta = new Vector2(180f, 40f);
		Button component2 = obj.GetComponent<Button>();
		((UnityEventBase)component2.onClick).RemoveAllListeners();
		((UnityEvent)component2.onClick).AddListener(action);
		TMP_Text componentInChildren = obj.GetComponentInChildren<TMP_Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = labelText;
			componentInChildren.fontSize *= 0.85f;
		}
		return obj;
	}

	private static void RefreshPinSelectionRows()
	{
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)AutoPinSelectionContent == (Object)null)
		{
			return;
		}
		ClearPinSelectionRows();
		float y = 0f;
		y = LayoutPinBiome(PinsMeadowsHeader, "Meadows", (Biome)1, PinsMeadowsExpanded, PinsMeadowsRows, y);
		y = LayoutPinBiome(PinsBlackForestHeader, "Black Forest", (Biome)8, PinsBlackForestExpanded, PinsBlackForestRows, y);
		y = LayoutPinBiome(PinsSwampHeader, "Swamp", (Biome)2, PinsSwampExpanded, PinsSwampRows, y);
		GameObject[] array = (GameObject[])(object)new GameObject[5] { PinsMountainsHeader, PinsPlainsHeader, PinsMistlandsHeader, PinsAshlandsHeader, PinsDeepNorthHeader };
		foreach (GameObject val in array)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.SetActive(false);
			}
		}
		AutoPinSelectionContent.sizeDelta = new Vector2(0f, Mathf.Max(400f, 0f - y + 40f));
	}

	private static void CreatePinCategoryIcon(Transform parent, PinSelectionCategory category)
	{
		//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)
		//IL_0037: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_009b: 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)
		GameObject val = new GameObject("RadarIcon", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(1f, 0.5f);
		component.anchorMax = new Vector2(1f, 0.5f);
		component.pivot = new Vector2(1f, 0.5f);
		component.anchoredPosition = new Vector2(-48f, 0f);
		component.sizeDelta = new Vector2(24f, 24f);
		Image component2 = val.GetComponent<Image>();
		component2.sprite = RadarIcons.Get(category.IconKind);
		((Graphic)component2).color = category.Tint;
		((Graphic)component2).raycastTarget = false;
	}

	private static GameObject CreatePinToggleRow(PinSelectionCategory category, float x, float y)
	{
		//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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = Object.Instantiate<GameObject>(NativeToggleTemplate, (Transform)(object)AutoPinSelectionContent);
		((Object)obj).name = "PinCategory_" + category.Key;
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 1f);
		component.anchorMax = new Vector2(0.5f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(x, y);
		component.sizeDelta = new Vector2(330f, 36f);
		Transform obj2 = obj.transform.Find("Label");
		TMP_Text val = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
		if ((Object)(object)val != (Object)null)
		{
			val.text = category.DisplayName;
			RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
			val.alignment = (TextAlignmentOptions)4097;
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = new Vector2(8f, 0f);
			component2.offsetMax = new Vector2(-82f, 0f);
		}
		CreatePinCategoryIcon(obj.transform, category);
		Toggle component3 = obj.GetComponent<Toggle>();
		if ((Object)(object)((Selectable)component3).targetGraphic != (Object)null)
		{
			RectTransform rectTransform = ((Selectable)component3).targetGraphic.rectTransform;
			rectTransform.anchorMin = new Vector2(1f, 0.5f);
			rectTransform.anchorMax = new Vector2(1f, 0.5f);
			rectTransform.pivot = new Vector2(1f, 0.5f);
			rectTransform.anchoredPosition = new Vector2(-4f, 0f);
		}
		string key = category.Key;
		((UnityEventBase)component3.onValueChanged).RemoveAllListeners();
		component3.isOn = PersistentPins.IsCategoryVisible(key);
		((UnityEvent<bool>)(object)component3.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
		{
			PersistentPins.SetCategoryVisible(key, value);
		});
		return obj;
	}

	private static void ClearPinSelectionRows()
	{
		foreach (GameObject pinsMeadowsRow in PinsMeadowsRows)
		{
			if ((Object)(object)pinsMeadowsRow != (Object)null)
			{
				Object.Destroy((Object)(object)pinsMeadowsRow);
			}
		}
		foreach (GameObject pinsBlackForestRow in PinsBlackForestRows)
		{
			if ((Object)(object)pinsBlackForestRow != (Object)null)
			{
				Object.Destroy((Object)(object)pinsBlackForestRow);
			}
		}
		foreach (GameObject pinsSwampRow in PinsSwampRows)
		{
			if ((Object)(object)pinsSwampRow != (Object)null)
			{
				Object.Destroy((Object)(object)pinsSwampRow);
			}
		}
		PinsMeadowsRows.Clear();
		PinsBlackForestRows.Clear();
		PinsSwampRows.Clear();
	}

	private static int GetSwampOrder(string key)
	{
		return key switch
		{
			"target:pickable_thistle" => 10, 
			"target:pickable_seedturnip" => 20, 
			"muddy_scrap_piles" => 30, 
			"target:infestedtree01" => 40, 
			"target:spawner_bonepile" => 50, 
			"target:spawner_draugrpile" => 60, 
			"target:spawner_imp" => 70, 
			"treasure_chests" => 80, 
			"runestones" => 90, 
			"target:sunkencrypt4" => 200, 
			"wood" => 210, 
			"stone" => 220, 
			"icon:mushroom" => 230, 
			"icon:herb" => 240, 
			"icon:flower" => 250, 
			"uncategorized" => 260, 
			_ => 999, 
		};
	}

	private static int GetBlackForestOrder(string key)
	{
		return key switch
		{
			"target:blueberrybush" => 10, 
			"target:pickable_mushroom" => 20, 
			"target:pickable_thistle" => 30, 
			"target:pickable_seedcarrot" => 40, 
			"target:rock4_copper" => 50, 
			"target:minerock_tin" => 60, 
			"target:greydwarf_camp1" => 70, 
			"treasure_chests" => 80, 
			"runestones" => 90, 
			"burial_chambers" => 200, 
			"target:trollcave02" => 210, 
			"target:bearcave" => 220, 
			"wood" => 230, 
			"stone" => 240, 
			"icon:berry" => 250, 
			"icon:mushroom" => 260, 
			"icon:herb" => 270, 
			"icon:flower" => 280, 
			"uncategorized" => 290, 
			_ => 999, 
		};
	}

	private static int GetMeadowsOrder(string key)
	{
		return key switch
		{
			"target:raspberrybush" => 10, 
			"target:pickable_mushroom" => 20, 
			"target:pickable_dandelion" => 30, 
			"beehives" => 40, 
			"treasure_chests" => 50, 
			"runestones" => 60, 
			"wood" => 110, 
			"stone" => 120, 
			"icon:berry" => 130, 
			"icon:mushroom" => 140, 
			"icon:herb" => 150, 
			"icon:flower" => 160, 
			"uncategorized" => 170, 
			_ => 999, 
		};
	}

	private static int GetPinCategoryOrder(Biome biome, PinSelectionCategory category)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Invalid comparison between Unknown and I4
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Invalid comparison between Unknown and I4
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Invalid comparison between Unknown and I4
		string key = (category.Key ?? "").ToLowerInvariant();
		if ((int)biome == 1)
		{
			return GetMeadowsOrder(key);
		}
		if ((int)biome == 8)
		{
			return GetBlackForestOrder(key);
		}
		if ((int)biome == 2)
		{
			return GetSwampOrder(key);
		}
		return 1000;
	}

	private static float LayoutPinBiome(GameObject header, string name, Biome biome, bool expanded, List<GameObject> rows, float y)
	{
		//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_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		bool flag = RadarProgression.IsBiomeUnlocked(biome);
		if ((Object)(object)header != (Object)null)
		{
			header.SetActive(flag);
		}
		if (!flag || (Object)(object)header == (Object)null)
		{
			return y;
		}
		header.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, y);
		SetBiomeExpanded(header, null, name, expanded);
		y -= 45f;
		if (!expanded)
		{
			return y;
		}
		List<PinSelectionCategory> list = new List<PinSelectionCategory>();
		foreach (PinSelectionCategory item in PinSelectionCatalog.GetAll())
		{
			if ((item.Biomes & biome) != 0)
			{
				list.Add(item);
			}
		}
		List<PinSelectionCategory> list2 = new List<PinSelectionCategory>();
		List<PinSelectionCategory> list3 = new List<PinSelectionCategory>();
		foreach (PinSelectionCategory item2 in list)
		{
			bool flag2 = item2.IconKind == RadarIconKind.Cave || item2.Key == "wood" || item2.Key == "stone" || item2.Key == "camps";
			if (item2.Tint != Color.white && !flag2)
			{
				list2.Add(item2);
			}
			else
			{
				list3.Add(item2);
			}
		}
		list2.Sort((PinSelectionCategory a, PinSelectionCategory b) => GetPinCategoryOrder(biome, a).CompareTo(GetPinCategoryOrder(biome, b)));
		list3.Sort((PinSelectionCategory a, PinSelectionCategory b) => GetPinCategoryOrder(biome, a).CompareTo(GetPinCategoryOrder(biome, b)));
		int num = Mathf.Max(list2.Count, list3.Count);
		for (int num2 = 0; num2 < num; num2++)
		{
			float y2 = y - (float)num2 * 40f;
			if (num2 < list2.Count)
			{
				rows.Add(CreatePinToggleRow(list2[num2], -180f, y2));
			}
			if (num2 < list3.Count)
			{
				rows.Add(CreatePinToggleRow(list3[num2], 180f, y2));
			}
		}
		y -= (float)num * 40f;
		return y;
	}

	private static void ClearMarkerSelectionRows()
	{
		List<GameObject>[] array = new List<GameObject>[11]
		{
			MarkersMeadowsRows, MarkersBlackForestRows, MarkersSwampRows, MarkersMountainsRows, MarkersPlainsRows, MarkersMistlandsRows, MarkersAshlandsRows, MarkersDeepNorthRows, MarkersOceanRows, MarkersHerbalistRows,
			MarkersValharvestRows
		};
		foreach (List<GameObject> list in array)
		{
			foreach (GameObject item in list)
			{
				if ((Object)(object)item != (Object)null)
				{
					Object.Destroy((Object)(object)item);
				}
			}
			list.Clear();
		}
	}

	private static void RefreshMarkerSelectionRows()
	{
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)NearbyMarkerSelectionContent == (Object)null))
		{
			ClearMarkerSelectionRows();
			float y = 0f;
			y = LayoutMarkerBiome(MarkersMeadowsHeader, "Meadows", (Biome)1, MarkersMeadowsExpanded, MarkersMeadowsRows, y);
			y = LayoutMarkerBiome(MarkersBlackForestHeader, "Black Forest", (Biome)8, MarkersBlackForestExpanded, MarkersBlackForestRows, y);
			y = LayoutMarkerBiome(MarkersSwampHeader, "Swamp", (Biome)2, MarkersSwampExpanded, MarkersSwampRows, y);
			y = LayoutMarkerBiome(MarkersMountainsHeader, "Mountains", (Biome)4, MarkersMountainsExpanded, MarkersMountainsRows, y);
			y = LayoutMarkerBiome(MarkersPlainsHeader, "Plains", (Biome)16, MarkersPlainsExpanded, MarkersPlainsRows, y);
			y = LayoutMarkerBiome(MarkersMistlandsHeader, "Mistlands", (Biome)512, MarkersMistlandsExpanded, MarkersMistlandsRows, y);
			y = LayoutMarkerBiome(MarkersAshlandsHeader, "Ashlands", (Biome)32, MarkersAshlandsExpanded, MarkersAshlandsRows, y);
			y = LayoutMarkerBiome(MarkersDeepNorthHeader, "Deep North", (Biome)64, MarkersDeepNorthExpanded, MarkersDeepNorthRows, y);
			y = LayoutMarkerBiome(MarkersOceanHeader, "Ocean", (Biome)256, MarkersOceanExpanded, MarkersOceanRows, y);
			if ((Object)(object)MarkersHerbalistHeader != (Object)null)
			{
				y = LayoutMarkerSource(MarkersHerbalistHeader, "Herbalist", "Herbalist", MarkersHerbalistExpanded, MarkersHerbalistRows, y);
			}
			if ((Object)(object)MarkersValharvestHeader != (Object)null)
			{
				y = LayoutMarkerSource(MarkersValharvestHeader, "Valharvest", "Valharvest", MarkersValharvestExpanded, MarkersValharvestRows, y);
			}
			NearbyMarkerSelectionContent.sizeDelta = new Vector2(0f, Mathf.Max(400f, 0f - y + 40f));
		}
	}

	private static float LayoutMarkerBiome(GameObject header, string name, Biome biome, bool expanded, List<GameObject> rows, float y)
	{
		//IL_0000: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		bool flag = RadarProgression.IsBiomeUnlocked(biome);
		if ((Object)(object)header != (Object)null)
		{
			header.SetActive(flag);
		}
		if (!flag || (Object)(object)header == (Object)null)
		{
			return y;
		}
		header.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, y);
		SetBiomeExpanded(header, null, name, expanded);
		y -= 45f;
		if (!expanded)
		{
			return y;
		}
		List<NearbyMarkerSelectionEntry> list = new List<NearbyMarkerSelectionEntry>();
		List<NearbyMarkerSelectionEntry> list2 = new List<NearbyMarkerSelectionEntry>();
		foreach (NearbyMarkerSelectionEntry item in NearbyMarkerSelectionCatalog.GetAll())
		{
			if ((item.Biomes & biome) != 0)
			{
				if (item.Kind == NearbyMarkerSelectionKind.Creature)
				{
					list2.Add(item);
				}
				else
				{
					list.Add(item);
				}
			}
		}
		int num = Mathf.Max(list.Count, list2.Count);
		for (int i = 0; i < num; i++)
		{
			float y2 = y - (float)i * 40f;
			if (i < list.Count)
			{
				rows.Add(CreateMarkerToggleRow(list[i], -180f, y2));
			}
			if (i < list2.Count)
			{
				rows.Add(CreateMarkerToggleRow(list2[i], 180f, y2));
			}
		}
		y -= (float)num * 40f;
		return y;
	}

	private static float LayoutMarkerSource(GameObject header, string name, string source, bool expanded, List<GameObject> rows, float y)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		header.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, y);
		SetBiomeExpanded(header, null, name, expanded);
		y -= 45f;
		if (!expanded)
		{
			return y;
		}
		List<NearbyMarkerSelectionEntry> list = new List<NearbyMarkerSelectionEntry>();
		List<NearbyMarkerSelectionEntry> list2 = new List<NearbyMarkerSelectionEntry>();
		foreach (NearbyMarkerSelectionEntry item in NearbyMarkerSelectionCatalog.GetAll())
		{
			if (!(item.Source != source))
			{
				if (item.RightColumn)
				{
					list2.Add(item);
				}
				else
				{
					list.Add(item);
				}
			}
		}
		int num = Mathf.Max(list.Count, list2.Count);
		for (int i = 0; i < num; i++)
		{
			float y2 = y - (float)i * 40f;
			if (i < list.Count)
			{
				rows.Add(CreateMarkerToggleRow(list[i], -180f, y2));
			}
			if (i < list2.Count)
			{
				rows.Add(CreateMarkerToggleRow(list2[i], 180f, y2));
			}
		}
		y -= (float)num * 40f;
		return y;
	}

	private static GameObject CreateMarkerToggleRow(NearbyMarkerSelectionEntry entry, float x, float y)
	{
		//IL_0044: 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_006e: 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_008f: 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)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Object.Instantiate<GameObject>(NativeToggleTemplate, (Transform)(object)NearbyMarkerSelectionContent);
		((Object)val).name = "MarkerCategory_" + entry.Key;
		val.SetActive(true);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 1f);
		component.anchorMax = new Vector2(0.5f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(x, y);
		component.sizeDelta = new Vector2(330f, 36f);
		Transform obj = val.transform.Find("Label");
		TMP_Text val2 = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
		if ((Object)(object)val2 != (Object)null)
		{
			val2.text = entry.DisplayName;
			val2.alignment = (TextAlignmentOptions)4097;
			RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = new Vector2(8f, 0f);
			component2.offsetMax = new Vector2(-82f, 0f);
		}
		GameObject val3 = new GameObject("MarkerIcon", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		val3.transform.SetParent(val.transform, false);
		RectTransform component3 = val3.GetComponent<RectTransform>();
		component3.anchorMin = new Vector2(1f, 0.5f);
		component3.anchorMax = new Vector2(1f, 0.5f);
		component3.pivot = new Vector2(1f, 0.5f);
		component3.anchoredPosition = new Vector2(-48f, 0f);
		component3.sizeDelta = new Vector2(24f, 24f);
		Image component4 = val3.GetComponent<Image>();
		component4.sprite = NearbyMarkers.GetSelectionIcon(entry);
		((Graphic)component4).raycastTarget = false;
		Toggle component5 = val.GetComponent<Toggle>();
		if ((Object)(object)((Selectable)component5).targetGraphic != (Object)null)
		{
			RectTransform rectTransform = ((Selectable)component5).targetGraphic.rectTransform;
			rectTransform.anchorMin = new Vector2(1f, 0.5f);
			rectTransform.anchorMax = new Vector2(1f, 0.5f);
			rectTransform.pivot = new Vector2(1f, 0.5f);
			rectTransform.anchoredPosition = new Vector2(-4f, 0f);
		}
		string[] keys = entry.Keys;
		((UnityEventBase)component5.onValueChanged).RemoveAllListeners();
		component5.isOn = true;
		string[] array = keys;
		for (int i = 0; i < array.Length; i++)
		{
			if (!NearbyMarkers.IsTargetVisible(array[i]))
			{
				component5.isOn = false;
				break;
			}
		}
		((UnityEvent<bool>)(object)component5.onValueChanged).AddListener((UnityAction<bool>)delegate(bool value)
		{
			string[] array2 = keys;
			for (int j = 0; j < array2.Length; j++)
			{
				NearbyMarkers.SetTargetVisible(array2[j], value);
			}
		});
		return val;
	}

	private static GameObject CreateMarkerTestRow(Transform parent, float y)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Expected O, but got Unknown
		GameObject val = new GameObject("MarkerTestRow", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(0f, y);
		component.sizeDelta = new Vector2(-40f, 36f);
		CreateMarkerTestLabel(val.transform, "Creature Test", -180f);
		CreateMarkerTestLabel(val.transform, "Pickable Test", 180f);
		return val;
	}

	private static void CreateMarkerTestLabel(Transform parent, string text, float x)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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_0059: 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)
		//IL_007f: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(text, new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = new Vector2(x, 0f);
		component.sizeDelta = new Vector2(300f, 36f);
		TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component2).text = text;
		((TMP_Text)component2).fontSize = 20f;
		((TMP_Text)component2).alignment = (TextAlignmentOptions)513;
		((Graphic)component2).color = new Color(0.93f, 0.66f, 0.21f, 1f);
		if ((Object)(object)CurrentMap.m_biomeNameLarge != (Object)null && (Object)(object)CurrentMap.m_biomeNameLarge.font != (Object)null)
		{
			((TMP_Text)component2).font = CurrentMap.m_biomeNameLarge.font;
		}
	}

	private static GameObject CreateBiomeTestRow(Transform parent, string labelText, float y)
	{
		//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)
		//IL_0037: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Expected O, but got Unknown
		GameObject val = new GameObject("BiomeTestRow", new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		val.transform.SetParent(parent, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(25f, y);
		component.sizeDelta = new Vector2(-50f, 36f);
		TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component2).text = labelText;
		((TMP_Text)component2).alignment = (TextAlignmentOptions)513;
		((TMP_Text)component2).enableAutoSizing = false;
		((TMP_Text)component2).fontSize = 20f;
		((Graphic)component2).color = new Color(0.93f, 0.66f, 0.21f, 1f);
		if ((Object)(object)CurrentMap.m_biomeNameLarge != (Object)null && (Object)(object)CurrentMap.m_biomeNameLarge.font != (Object)null)
		{
			((TMP_Text)component2).font = CurrentMap.m_biomeNameLarge.font;
		}
		return val;
	}

	private static GameObject CreateBiomeHeader(Transform parent, string labelText, float y, UnityAction action)
	{
		//IL_0023: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = Object.Instantiate<GameObject>(NativeButtonTemplate, parent);
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(1f, 1f);
		component.pivot = new Vector2(0.5f, 1f);
		component.anchoredPosition = new Vector2(0f, y);
		component.sizeDelta = new Vector2(-10f, 42f);
		Button component2 = obj.GetComponent<Button>();
		((UnityEventBase)component2.onClick).RemoveAllListeners();
		((UnityEvent)component2.onClick).AddListener(action);
		TMP_Text componentInChildren = obj.GetComponentInChildren<TMP_Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = "> " + labelText;
			componentInChildren.alignment = (TextAlignmentOptions)513;
		}
		return obj;
	}

	private static void ToggleMarkersMeadows()
	{
		MarkersMeadowsExpanded = !MarkersMeadowsExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersBlackForest()
	{
		MarkersBlackForestExpanded = !MarkersBlackForestExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersSwamp()
	{
		MarkersSwampExpanded = !MarkersSwampExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersMountains()
	{
		MarkersMountainsExpanded = !MarkersMountainsExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersPlains()
	{
		MarkersPlainsExpanded = !MarkersPlainsExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersMistlands()
	{
		MarkersMistlandsExpanded = !MarkersMistlandsExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersAshlands()
	{
		MarkersAshlandsExpanded = !MarkersAshlandsExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersDeepNorth()
	{
		MarkersDeepNorthExpanded = !MarkersDeepNorthExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersOcean()
	{
		MarkersOceanExpanded = !MarkersOceanExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersHerbalist()
	{
		MarkersHerbalistExpanded = !MarkersHerbalistExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void ToggleMarkersValharvest()
	{
		MarkersValharvestExpanded = !MarkersValharvestExpanded;
		RefreshMarkerSelectionRows();
	}

	private static void TogglePinsMeadows()
	{
		PinsMeadowsExpanded = !PinsMeadowsExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsBlackForest()
	{
		PinsBlackForestExpanded = !PinsBlackForestExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsSwamp()
	{
		PinsSwampExpanded = !PinsSwampExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsMountains()
	{
		PinsMountainsExpanded = !PinsMountainsExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsPlains()
	{
		PinsPlainsExpanded = !PinsPlainsExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsMistlands()
	{
		PinsMistlandsExpanded = !PinsMistlandsExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsAshlands()
	{
		PinsAshlandsExpanded = !PinsAshlandsExpanded;
		RefreshPinSelectionRows();
	}

	private static void TogglePinsDeepNorth()
	{
		PinsDeepNorthExpanded = !PinsDeepNorthExpanded;
		RefreshPinSelectionRows();
	}

	private static void SetBiomeExpanded(GameObject header, GameObject childRow, string biomeName, bool expanded)
	{
		if ((Object)(object)header != (Object)null)
		{
			TMP_Text componentInChildren = header.GetComponentInChildren<TMP_Text>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.text = (expanded ? "V " : "> ") + biomeName;
			}
		}
		if ((Object)(object)childRow != (Object)null)
		{
			childRow.SetActive(expanded);
		}
	}

	private static void ConfigureSelectionPanel(GameObject panel)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = panel.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = Vector2.zero;
		component.sizeDelta = new Vector2(820f, 580f);
	}

	private static GameObject CreateMapQuickToggle(string objectName, string labelText, Vector2 position, bool initialValue, UnityAction<bool> action)
	{
		//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_006d: 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)
		GameObject obj = Object.Instantiate<GameObject>(NativeToggleTemplate, CurrentMap.m_largeRoot.transform);
		((Object)obj).name = objectName;
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		component.pivot = new Vector2(0f, 1f);
		component.anchoredPosition = position;
		component.sizeDelta = new Vector2(260f, 40f);
		Transform obj2 = obj.transform.Find("Label");
		TMP_Text val = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
		if ((Object)(object)val != (Object)null)
		{
			val.text = labelText;
		}
		Toggle component2 = obj.GetComponent<Toggle>();
		((UnityEventBase)component2.onValueChanged).RemoveAllListeners();
		component2.isOn = initialValue;
		((UnityEvent<bool>)(object)component2.onValueChanged).AddListener(action);
		return obj;
	}

	private static GameObject CreateMapQuickButton(string objectName, string labelText, Vector2 position, UnityAction action)
	{
		//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_006d: 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)
		GameObject obj = Object.Instantiate<GameObject>(NativeButtonTemplate, CurrentMap.m_largeRoot.transform);
		((Object)obj).name = objectName;
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		component.pivot = new Vector2(0f, 1f);
		component.anchoredPosition = position;
		component.sizeDelta = new Vector2(180f, 40f);
		Button component2 = obj.GetComponent<Button>();
		((UnityEventBase)component2.onClick).RemoveAllListeners();
		((UnityEvent)component2.onClick).AddListener(action);
		TMP_Text componentInChildren = obj.GetComponentInChildren<TMP_Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = labelText;
		}
		return obj;
	}

	private static void CreateMapQuickToggles()
	{
		//IL_0014: 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_0086: 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_009c: Expected O, but got Unknown
		MapPinsToggleObject = CreateMapQuickToggle("BetterRadarMapPinsToggle", "Toggle Pins", new Vector2(20f, -20f), BetterRadarPlugin.PersistentPinsVisible.Value, PersistentPins.SetPinsVisible);
		MapMarkersToggleObject = CreateMapQuickToggle("BetterRadarMapMarkersToggle", "Toggle Markers", new Vector2(20f, -65f), BetterRadarPlugin.NearbyMarkersVisible.Value, NearbyMarkers.SetVisible);
		MapRescanPinsButton = CreateMapQuickButton("BetterRadarMapRescanPins", "Rescan Pins", new Vector2(20f, -115f), new UnityAction(PersistentPins.NearbyRescan));
	}

	private static void CreateSettingsPanel()
	{
		//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_0077: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: 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_0118: Expected O, but got Unknown
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Expected O, but got Unknown
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Expected O, but got Unknown
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Expected O, but got Unknown
		SettingsPanel = Object.Instantiate<GameObject>(NativePanelTemplate, CurrentMap.m_largeRoot.transform);
		((Object)SettingsPanel).name = "BetterRadarSettingsPanel";
		SettingsPanel.SetActive(true);
		RectTransform component = SettingsPanel.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = Vector2.zero;
		component.sizeDelta = new Vector2(540f, 460f);
		CreateTitle();
		CreatePanelButton("BetterRadarPinSelection", "Pin Selection", new Vector2(0f, 85f), new Vector2(300f, 44f), new UnityAction(OpenPinSelectionPanel));
		CreatePanelButton("BetterRadarMarkerSelection", "Marker Selection", new Vector2(0f, 30f), new Vector2(300f, 44f), new UnityAction(OpenMarkerSelectionPanel));
		CreatePanelButton("BetterRadarClearPins", "Clear Radar Pins", new Vector2(0f, -25f), new Vector2(300f, 44f), new UnityAction(ShowClearConfirmation));
		CreatePanelButton("BetterRadarForgetDiscoveries", "Forget Radar Discoveries", new Vector2(0f, -80f), new Vector2(300f, 44f), new UnityAction(ShowForgetConfirmation));
		CreatePanelButton("BetterRadarCloseSettings", "Close", new Vector2(0f, -140f), new Vector2(180f, 42f), new UnityAction(CloseSettingsAndReturn));
		SettingsPanel.SetActive(false);
	}

	private static void CreateTitle()
	{
		//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)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_00a4: 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)
		GameObject val = new GameObject("Title", new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		val.transform.SetParent(SettingsPanel.transform, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = new Vector2(0f, 145f);
		component.sizeDelta = new Vector2(460f, 50f);
		TextMeshProUGUI component2 = val.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component2).text = "Radar Settings";
		((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
		((TMP_Text)component2).fontSize = 26f;
		((Graphic)component2).color = new Color(0.93f, 0.66f, 0.21f, 1f);
		((Graphic)component2).raycastTarget = false;
		if ((Object)(object)CurrentMap.m_biomeNameLarge != (Object)null && (Object)(object)CurrentMap.m_biomeNameLarge.font != (Object)null)
		{
			((TMP_Text)component2).font = CurrentMap.m_biomeNameLarge.font;
		}
	}

	private static GameObject CreatePanelButton(string objectName, string labelText, Vector2 position, Vector2 size, UnityAction action)
	{
		//IL_0033: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = Object.Instantiate<GameObject>(NativeButtonTemplate, SettingsPanel.transform);
		((Object)obj).name = objectName;
		obj.SetActive(true);
		RectTransform component = obj.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = position;
		component.sizeDelta = size;
		Button component2 = obj.GetComponent<Button>();
		((UnityEventBase)component2.onClick).RemoveAllListeners();
		((UnityEvent)component2.onClick).AddListener(action);
		TMP_Text componentInChildren = obj.GetComponentInChildren<TMP_Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = labelText;
			componentInChildren.fontSize *= 0.85f;
		}
		return obj;
	}

	private static void OpenPinSelectionPanel()
	{
		RefreshPinSelectionRows();
		if ((Object)(object)SettingsPanel != (Object)null)
		{
			SettingsPanel.SetActive(false);
		}
		if ((Object)(object)AutoPinSelectionPanel != (Object)null)
		{
			AutoPinSelectionPanel.SetActive(true);
			AutoPinSelectionPanel.transform.SetAsLastSibling();
		}
	}

	private static void OpenMarkerSelectionPanel()
	{
		RefreshMarkerSelectionRows();
		if ((Object)(object)SettingsPanel != (Object)null)
		{
			SettingsPanel.SetActive(false);
		}
		if ((Object)(object)NearbyMarkerSelectionPanel != (Object)null)
		{
			NearbyMarkerSelectionPanel.SetActive(true);
			NearbyMarkerSelectionPanel.transform.SetAsLastSibling();
		}
	}

	private static void ShowSettingsPanel()
	{
		if ((Object)(object)AutoPinSelectionPanel != (Object)null)
		{
			AutoPinSelectionPanel.SetActive(false);
		}
		if ((Object)(object)NearbyMarkerSelectionPanel != (Object)null)
		{
			NearbyMarkerSelectionPanel.SetActive(false);
		}
		if ((Object)(object)SettingsPanel != (Object)null)
		{
			SettingsPanel.SetActive(true);
			SettingsPanel.transform.SetAsLastSibling();
		}
	}

	internal static void ResetPauseMenuState()
	{
		if ((Object)(object)SettingsPanel != (Object)null)
		{
			SettingsPanel.SetActive(false);
		}
		if ((Object)(object)AutoPinSelectionPanel != (Object)null)
		{
			AutoPinSelectionPanel.SetActive(false);
		}
		if ((Object)(object)NearbyMarkerSelectionPanel != (Object)null)
		{
			NearbyMarkerSelectionPanel.SetActive(false);
		}
	}

	internal static void OpenFromPauseMenu(Transform pauseRoot)
	{
		TryCreateUI();
		ResetPauseMenuState();
		if (!((Object)(object)SettingsPanel == (Object)null) && !((Object)(object)pauseRoot == (Object)null))
		{
			SettingsPanel.transform.SetParent(pauseRoot, false);
			if ((Object)(object)AutoPinSelectionPanel != (Object)null)
			{
				AutoPinSelectionPanel.transform.SetParent(pauseRoot, false);
			}
			if ((Object)(object)NearbyMarkerSelectionPanel != (Object)null)
			{
				NearbyMarkerSelectionPanel.transform.SetParent(pauseRoot, false);
			}
			SettingsPanel.SetActive(true);
			SettingsPanel.transform.SetAsLastSibling();
		}
	}

	private static void ToggleSettingsPanel()
	{
		if (!((Object)(object)SettingsPanel == (Object)null))
		{
			SettingsPanel.SetActive(!SettingsPanel.activeSelf);
			if (SettingsPanel.activeSelf)
			{
				SettingsPanel.transform.SetAsLastSibling();
			}
		}
	}

	private static void CloseSettingsAndReturn()
	{
		CloseSettingsPanel();
		BetterRadarPauseUI.ReturnToPauseMenu();
	}

	private static void CloseSettingsPanel()
	{
		if ((Object)(object)SettingsPanel != (Object)null)
		{
			SettingsPanel.SetActive(false);
		}
	}

	private static void ShowClearConfirmation()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//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_0048: Expected O, but got Unknown
		object obj = <>c.<>9__132_0;
		if (obj == null)
		{
			PopupButtonCallback val = delegate
			{
				UnifiedPopup.Pop();
				PersistentPins.ClearPins();
			};
			<>c.<>9__132_0 = val;
			obj = (object)val;
		}
		object obj2 = <>c.<>9__132_1;
		if (obj2 == null)
		{
			PopupButtonCallback val2 = delegate
			{
				UnifiedPopup.Pop();
			};
			<>c.<>9__132_1 = val2;
			obj2 = (object)val2;
		}
		UnifiedPopup.Push((PopupBase)new YesNoPopup("Clear Radar Pins?", "Remove all Radar map pins? Discovery history will be kept, so removed pins will not be recreated.", (PopupButtonCallback)obj, (PopupButtonCallback)obj2, false, false));
	}

	private static void ShowForgetConfirmation()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//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_0048: Expected O, but got Unknown
		object obj = <>c.<>9__133_0;
		if (obj == null)
		{
			PopupButtonCallback val = delegate
			{
				UnifiedPopup.Pop();
				PersistentPins.ForgetDiscoveries();
			};
			<>c.<>9__133_0 = val;
			obj = (object)val;
		}
		object obj2 = <>c.<>9__133_1;
		if (obj2 == null)
		{
			PopupButtonCallback val2 = delegate
			{
				UnifiedPopup.Pop();
			};
			<>c.<>9__133_1 = val2;
			obj2 = (object)val2;
		}
		UnifiedPopup.Push((PopupBase)new YesNoPopup("Forget Radar Discoveries?", "Remove all Radar pins and erase discovery history? Nearby targets can then be discovered again.", (PopupButtonCallback)obj, (PopupButtonCallback)obj2, false, false));
	}
}
internal static class BetterRadarPauseUI
{
	[HarmonyPatch(typeof(Menu), "Start")]
	private static class MenuStartPatch
	{
		private static void Postfix(Menu __instance)
		{
			SetupRadarSettingsButton(__instance);
		}
	}

	[HarmonyPatch(typeof(Menu), "UpdateNavigation")]
	private static class MenuUpdateNavigationPatch
	{
		private static void Postfix(Menu __instance)
		{
			SetupRadarSettingsButton(__instance);
		}
	}

	[HarmonyPatch(typeof(Menu), "Hide")]
	private static class MenuHidePatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			BetterRadarMapUI.ResetPauseMenuState();
		}
	}

	private static GameObject RadarSettingsButton;

	private static Menu ActiveMenu;

	private static void SetupRadarSettingsButton(Menu menu)
	{
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Expected O, but got Unknown
		if ((Object)(object)menu == (Object)null || (Object)(object)menu.m_menuDialog == (Object)null)
		{
			return;
		}
		Transform val = menu.m_menuDialog.Find("MenuEntries");
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Transform val2 = val.Find("Settings");
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		Transform val3 = val.Find("Radar Settings");
		if ((Object)(object)val3 != (Object)null)
		{
			RadarSettingsButton = ((Component)val3).gameObject;
			return;
		}
		RadarSettingsButton = Object.Instantiate<GameObject>(((Component)val2).gameObject, val);
		((Object)RadarSettingsButton).name = "Radar Settings";
		RadarSettingsButton.transform.SetSiblingIndex(val2.GetSiblingIndex() + 1);
		Button component = RadarSettingsButton.GetComponent<Button>();
		for (int i = 0; i < ((UnityEventBase)component.onClick).GetPersistentEventCount(); i++)
		{
			((UnityEventBase)component.onClick).SetPersistentListenerState(i, (UnityEventCallState)0);
		}
		((UnityEventBase)component.onClick).RemoveAllListeners();
		((UnityEvent)component.onClick).AddListener(new UnityAction(OpenRadarSettings));
		TMP_Text componentInChildren = RadarSettingsButton.GetComponentInChildren<TMP_Text>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.text = "Radar Settings";
		}
		RadarSettingsButton.SetActive(true);
	}

	private static void OpenRadarSettings()
	{
		ActiveMenu = Menu.instance;
		if ((Object)(object)ActiveMenu != (Object)null && (Object)(object)ActiveMenu.m_menuDialog != (Object)null)
		{
			((Component)ActiveMenu.m_menuDialog).gameObject.SetActive(false);
		}
		BetterRadarMapUI.OpenFromPauseMenu(ActiveMenu.m_root);
	}

	internal static void ReturnToPauseMenu()
	{
		if ((Object)(object)ActiveMenu != (Object)null && (Object)(object)ActiveMenu.m_menuDialog != (Object)null)
		{
			((Component)ActiveMenu.m_menuDialog).gameObject.SetActive(true);
		}
	}
}
[BepInPlugin("notyourfriend.NotYourRadar", "NotYourRadar", "0.1.2")]
public class BetterRadarPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "notyourfriend.NotYourRadar";

	public const string PluginName = "NotYourRadar";

	public const string PluginVersion = "0.1.2";

	internal static ManualLogSource Log;

	internal static Harmony Harmony;

	internal static ConfigEntry<bool> PersistentEnabled;

	internal static ConfigEntry<bool> PersistentPinsVisible;

	internal static ConfigEntry<string> HiddenPersistentTargets;

	internal static ConfigEntry<bool> NearbyMarkersVisible;

	internal static ConfigEntry<string> HiddenNearbyTargets;

	internal static ConfigEntry<KeyboardShortcut> PersistentPinsToggleHotkey;

	internal static ConfigEntry<KeyboardShortcut> NearbyMarkersToggleHotkey;

	internal static ConfigEntry<KeyboardShortcut> RescanPinsHotkey;

	internal static ConfigEntry<float> PersistentRadius;

	internal static ConfigEntry<float> PersistentMergeDistance;

	internal static ConfigEntry<float> PersistentSweepInterval;

	internal static ConfigEntry<bool> ExtendedMinimapZoom;

	internal static ConfigEntry<float> MinimapMinimumZoom;

	internal static ConfigEntry<float> UiScrollSpeed;

	private void Awake()
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		RadarIcons.Load();
		ExtendedMinimapZoom = ((BaseUnityPlugin)this).Config.Bind<bool>("Minimap", "Extended Zoom", true, "Allow the small minimap to zoom in farther than vanilla.");
		MinimapMinimumZoom = ((BaseUnityPlugin)this).Config.Bind<float>("Minimap", "Minimum Zoom", 0.005f, "Small minimap zoom-in limit. Vanilla is 0.01; lower values zoom in farther.");
		UiScrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Scroll Speed", 360f, new ConfigDescription("Mouse-wheel scroll speed for Radar selection menus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(40f, 800f), Array.Empty<object>()));
		UiScrollSpeed.SettingChanged += delegate
		{
			BetterRadarMapUI.ApplyScrollSpeed();
		};
		PersistentEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Persistent Pins", "Enabled", true, "Automatically discover and permanently map whitelisted targets.");
		PersistentPinsVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Persistent Pins", "Show Auto-Pins", true, "Show or hide persistent Radar auto-pins without erasing discovery history.");
		HiddenPersistentTargets = ((BaseUnityPlugin)this).Config.Bind<string>("Persistent Pins", "Hidden Targets", "", "Semicolon-separated persistent Radar target prefabs hidden from the map.");
		NearbyMarkersVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("Nearby Markers", "Show Nearby Markers", true, "Show or hide temporary nearby creature and ready-pickable markers.");
		HiddenNearbyTargets = ((BaseUnityPlugin)this).Config.Bind<string>("Nearby Markers", "Hidden Targets", "", "Semicolon-separated Nearby Marker category keys hidden from the minimap.");
		PersistentPinsToggleHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Persistent Auto-Pins Toggle", new KeyboardShortcut((KeyCode)109, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Toggle persistent Radar auto-pins.");
		NearbyMarkersToggleHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Nearby Markers Toggle", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Toggle temporary nearby creature and ready-pickable markers.");
		RescanPinsHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Rescan Pins", new KeyboardShortcut((KeyCode)109, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Rescan nearby persistent Radar targets.");
		PersistentRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Persistent Pins", "Discovery Radius", 100f, "Maximum distance in metres at which persistent targets are discovered.");
		PersistentMergeDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Persistent Pins", "Merge Distance", 5f, "Distance in metres used when determining whether a target has already been mapped.");
		PersistentSweepInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Persistent Pins", "Sweep Interval", 2f, "Seconds between persistent-world discovery scans.");
		Harmony = new Harmony("notyourfriend.NotYourRadar");
		Harmony.PatchAll();
		Log.LogInfo((object)"NotYourRadar 0.1.2 loaded.");
	}

	private void Update()
	{
		//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_0055: 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_00a5: 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)
		KeyboardShortcut value = PersistentPinsToggleHotkey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			bool flag = !PersistentPinsVisible.Value;
			PersistentPins.SetPinsVisible(flag);
			Log.LogInfo((object)("Persistent auto-pins " + (flag ? "shown" : "hidden") + " via hotkey."));
		}
		value = NearbyMarkersToggleHotkey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			bool flag2 = !NearbyMarkersVisible.Value;
			NearbyMarkers.SetVisible(flag2);
			Log.LogInfo((object)("Nearby markers " + (flag2 ? "shown" : "hidden") + " via hotkey."));
		}
		value = RescanPinsHotkey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			PersistentPins.NearbyRescan();
			Log.LogInfo((object)"Nearby persistent targets rescanned via hotkey.");
		}
		PersistentPins.Tick();
		NearbyMarkers.Tick();
	}

	private void OnDestroy()
	{
		Harmony harmony = Harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
internal static class MineRockRetirementPatch
{
	private static void Postfix(MineRock __instance, ZNetView ___m_nview)
	{
		ZDO val = ((___m_nview != null) ? ___m_nview.GetZDO() : null);
		if (val != null && !MineableState.IsUntouched(((Component)__instance).gameObject, val))
		{
			PersistentPins.RetirePersistentTarget(((Component)__instance).gameObject, val);
		}
	}
}
[HarmonyPatch(typeof(MineRock5), "RPC_Damage")]
internal static class MineRock5RetirementPatch
{
	private static void Postfix(MineRock5 __instance, ZNetView ___m_nview)
	{
		ZDO val = ((___m_nview != null) ? ___m_nview.GetZDO() : null);
		if (val != null && !MineableState.IsUntouched(((Component)__instance).gameObject, val))
		{
			PersistentPins.RetirePersistentTarget(((Component)__instance).gameObject, val);
		}
	}
}
internal static class MineableState
{
	internal static bool IsMineable(GameObject obj)
	{
		if ((Object)(object)obj == (Object)null)
		{
			return false;
		}
		if ((Object)(object)obj.GetComponentInChildren<MineRock>(true) != (Object)null)
		{
			return true;
		}
		if ((Object)(object)obj.GetComponentInChildren<MineRock5>(true) != (Object)null)
		{
			return true;
		}
		if ((Object)(object)obj.GetComponentInChildren<Destructible>(true) == (Object)null)
		{
			return false;
		}
		string text = ((Object)obj).name.ToLowerInvariant();
		if (!text.Contains("copper") && !text.Contains("tin") && !text.Contains("silver") && !text.Contains("obsidian"))
		{
			return text.Contains("mudpile");
		}
		return true;
	}

	internal static bool IsUntouched(GameObject obj, ZDO zdo)
	{
		if ((Object)(object)obj == (Object)null || zdo == null || !zdo.IsValid())
		{
			return false;
		}
		if ((Object)(object)obj.GetComponentInChildren<MineRock>(true) != (Object)null)
		{
			return IsUntouchedMineRock(zdo);
		}
		if ((Object)(object)obj.GetComponentInChildren<MineRock5>(true) != (Object)null)
		{
			return IsUntouchedMineRock5(zdo);
		}
		float num = default(float);
		if ((Object)(object)obj.GetComponentInChildren<Destructible>(true) != (Object)null && IsMineable(obj))
		{
			return !zdo.GetFloat(ZDOVars.s_health, ref num);
		}
		return false;
	}

	private static bool IsUntouchedMineRock5(ZDO zdo)
	{
		string text = default(string);
		return !zdo.GetString(ZDOVars.s_health, ref text);
	}

	private static bool IsUntouchedMineRock(ZDO zdo)
	{
		float num = default(float);
		for (int i = 0; i < 256; i++)
		{
			if (zdo.GetFloat("Health" + i, ref num))
			{
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch]
internal static class MinimapZoomPatch
{
	private const float VanillaMinimumZoom = 0.01f;

	private const float MiddleZoom = 0.0075f;

	private const float ExtendedMinimumZoom = 0.005f;

	[HarmonyPatch(typeof(Minimap), "Update")]
	[HarmonyPrefix]
	private static void MinimapUpdatePrefix(Minimap __instance)
	{
		if (!BetterRadarPlugin.ExtendedMinimapZoom.Value)
		{
			__instance.m_minZoom = 0.01f;
		}
		else
		{
			__instance.m_minZoom = Mathf.Clamp(BetterRadarPlugin.MinimapMinimumZoom.Value, 0.001f, 0.01f);
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPrefix]
	private static void SmallZoomSetterPrefix(Minimap __instance, ref float value)
	{
		if (!BetterRadarPlugin.ExtendedMinimapZoom.Value)
		{
			return;
		}
		float smallZoom = __instance.SmallZoom;
		if (!(smallZoom <= 0.0101f) && !(value < 0.01f))
		{
			return;
		}
		if (value < smallZoom)
		{
			if (smallZoom > 0.0075999997f)
			{
				value = 0.0075f;
			}
			else
			{
				value = 0.005f;
			}
		}
		else if (value > smallZoom)
		{
			if (smallZoom < 0.0074f)
			{
				value = 0.0075f;
			}
			else
			{
				value = 0.01f;
			}
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPrefix]
	private static void LargeZoomPrefix(ref float value)
	{
		value = Mathf.Max(0.01f, value);
	}
}
internal static class ModCompatibility
{
	internal const string HerbalistGuid = "blacks7ar.Herbalist";

	internal const string ValharvestGuid = "com.frenvius.Valharvest";

	internal static bool HerbalistLoaded => Chainloader.PluginInfos.ContainsKey("blacks7ar.Herbalist");

	internal static bool ValharvestLoaded => Chainloader.PluginInfos.ContainsKey("com.frenvius.Valharvest");
}
internal static class MoreWorldLocationsCompat
{
	private static readonly HashSet<string> SemanticPins = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
	{
		"MWL_BlackForestBlacksmith1", "MWL_BlackForestBlacksmith2", "MWL_MountainsBlacksmith1", "MWL_MistlandsBlacksmith1", "MWL_PlainsTavern1", "MWL_OceanTavern1", "MWL_PlainsCamp1", "MWL_MeadowsTrainer1", "MWL_SwampTrainer1", "MWL_PlainsTrainer1",
		"MWL_MistTrainer1", "MWL_Port1", "MWL_Port2", "MWL_Port3", "MWL_Port4", "MWL_Port5", "MWL_Port6"
	};

	internal static bool HasOwnSemanticPin(string targetName)
	{
		if (!string.IsNullOrEmpty(targetName))
		{
			return SemanticPins.Contains(targetName);
		}
		return false;
	}

	internal static bool TryResolveLocationIcon(string targetName, out RadarIconKind iconKind)
	{
		iconKind = RadarIconKind.Unknown;
		if (string.IsNullOrEmpty(targetName) || !targetName.StartsWith("MWL_", StringComparison.OrdinalIgnoreCase))
		{
			return false;
		}
		string text = targetName.ToLowerInvariant();
		switch (text)
		{
		case "mwl_deershrine1":
		case "mwl_deershrine2":
			iconKind = RadarIconKind.Tower;
			return true;
		case "mwl_massgrave1":
			iconKind = RadarIconKind.Wood;
			return true;
		case "mwl_swampaltar4":
			iconKind = RadarIconKind.Tower;
			return true;
		default:
			if (ContainsAny(text, "tomb", "secretroom", "dungeon", "crypt", "cave"))
			{
				iconKind = RadarIconKind.Cave;
				return true;
			}
			if ((text.Contains("fuling") || text.Contains("goblin")) && ContainsAny(text, "village", "camp"))
			{
				iconKind = RadarIconKind.Swords;
				return true;
			}
			if (text.Contains("wood"))
			{
				iconKind = RadarIconKind.Wood;
				return true;
			}
			if (ContainsAny(text, "tower", "ruin", "castle", "fort", "stone", "wall", "temple", "pillar", "church", "lighthouse"))
			{
				iconKind = RadarIconKind.Tower;
				return true;
			}
			if (ContainsAny(text, "hut", "house", "barn", "farm", "treehouse", "sawmill", "shipyard", "forge", "workshop"))
			{
				iconKind = RadarIconKind.Wood;
				return true;
			}
			return false;
		}
	}

	private static bool ContainsAny(string value, params string[] terms)
	{
		foreach (string value2 in terms)
		{
			if (value.Contains(value2))
			{
				return true;
			}
		}
		return false;
	}
}
internal static class NearbyMarkers
{
	[HarmonyPatch(typeof(Minimap), "UpdatePins")]
	private static class MinimapUpdatePinsPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			BringNearbyMarkersToFront();
			ReapplyFallbackTints();
		}
	}

	private static readonly FieldRef<Minimap, bool> PinUpdateRequired = AccessTools.FieldRefAccess<Minimap, bool>("m_pinUpdateRequired");

	private const float ShowRadius = 50f;

	private const float HideRadius = 60f;

	private const float CreatureUpdateInterval = 0.25f;

	private const float WorldUpdateInterval = 3f;

	private static readonly Dictionary<Character, PinData> ActiveMarkers = new Dictionary<Character, PinData>();

	private static readonly FieldRef<ZNetScene, Dictionary<ZDO, ZNetView>> Instances = AccessTools.FieldRefAccess<ZNetScene, Dictionary<ZDO, ZNetView>>("m_instances");

	private static readonly Dictionary<ZDO, PinData> ActiveDynamicWorldMarkers = new Dictionary<ZDO, PinData>();

	private static readonly Dictionary<ZDO, PinData> ActiveStaticWorldMarkers = new Dictionary<ZDO, PinData>();

	private static readonly Dictionary<int, Sprite> WorldIcons = new Dictionary<int, Sprite>();

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

	private static readonly HashSet<string> RedDotCreatures = new HashSet<string>();

	private static float NextCreatureUpdate;

	private static float NextWorldUpdate;

	internal static string GetCreatureKey(string prefab)
	{
		return "creature:" + prefab;
	}

	internal static string GetPickableKey(string itemPrefab)
	{
		return "pickable:" + itemPrefab;
	}

	internal static string GetFishKey(string itemPrefab)
	{
		return "fish:" + itemPrefab;
	}

	internal static bool IsTargetVisible(string categoryKey)
	{
		if (string.IsNullOrEmpty(categoryKey))
		{
			return true;
		}
		string[] array = (BetterRadarPlugin.HiddenNearbyTargets.Value ?? "").Split(';');
		foreach (string text in array)
		{
			if (categoryKey.Equals(text.Trim(), StringComparison.OrdinalIgnoreCase))
			{
				return false;
			}
		}
		return true;
	}

	internal static void SetTargetVisible(string categoryKey, bool visible)
	{
		HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
		string[] array = (BetterRadarPlugin.HiddenNearbyTargets.Value ?? "").Split(';');
		for (int i = 0; i < array.Length; i++)
		{
			string text = array[i].Trim();
			if (!string.IsNullOrEmpty(text))
			{
				hashSet.Add(text);
			}
		}
		if (visible)
		{
			hashSet.Remove(categoryKey);
		}
		else
		{
			hashSet.Add(categoryKey);
		}
		BetterRadarPlugin.HiddenNearbyTargets.Value = string.Join(";", hashSet);
		ClearAll();
	}

	internal static void SetVisible(bool visible)
	{
		BetterRadarPlugin.NearbyMarkersVisible.Value = visible;
		if (!visible)
		{
			ClearAll();
		}
	}

	private static void ClearAll()
	{
		if ((Object)(object)Minimap.instance != (Object)null)
		{
			foreach (PinData value in ActiveMarkers.Values)
			{
				if (value != null)
				{
					Minimap.instance.RemovePin(value);
				}
			}
			foreach (PinData value2 in ActiveDynamicWorldMarkers.Values)
			{
				if (value2 != null)
				{
					Minimap.instance.RemovePin(value2);
				}
			}
			foreach (PinData value3 in ActiveStaticWorldMarkers.Values)
			{
				if (value3 != null)
				{
					Minimap.instance.RemovePin(value3);
				}
			}
		}
		ActiveMarkers.Clear();
		ActiveDynamicWorldMarkers.Clear();
		ActiveStaticWorldMarkers.Clear();
	}

	internal static void Tick()
	{
		if (!BetterRadarPlugin.NearbyMarkersVisible.Value)
		{
			if (ActiveMarkers.Count > 0 || ActiveDynamicWorldMarkers.Count > 0 || ActiveStaticWorldMarkers.Count > 0)
			{
				ClearAll();
			}
		}
		else if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Minimap.instance == (Object)null) && !((Object)(object)ObjectDB.instance == (Object)null))
		{
			UpdateActivePositions();
			if (Time.time >= NextCreatureUpdate)
			{
				NextCreatureUpdate = Time.time + 0.25f;
				UpdateCreatures();
				UpdateDynamicWorldObjects();
			}
			if (Time.time >= NextWorldUpdate)
			{
				NextWorldUpdate = Time.time + 3f;
				UpdateStaticWorldObjects();
			}
		}
	}

	private static Sprite GetItemIcon(string prefabName)
	{
		GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(prefabName);
		if ((Object)(object)itemPrefab == (Object)null)
		{
			return null;
		}
		ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
		if (component == null)
		{
			return null;
		}
		return component.m_itemData.GetIcon();
	}

	private static Sprite ResolveCreatureIcon(string prefab)
	{
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		if (CreatureIcons.TryGetValue(prefab, out var value))
		{
			return value;
		}
		Sprite val = null;
		if (prefab.Equals("Greyling", StringComparison.OrdinalIgnoreCase))
		{
			val = GetItemIcon("Resin");
		}
		if ((Object)(object)val == (Object)null)
		{
			val = (prefab.Equals("Greydwarf_Shaman", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("TrophyGreydwarfShaman") : (prefab.Equals("Greydwarf_Elite", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("TrophyGreydwarfBrute") : (prefab.Equals("Bear", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("TrophyBjorn") : (prefab.Equals("Troll", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("TrophyFrostTroll") : (prefab.Equals("Draugr_Elite", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("TrophyDraugrElite") : (prefab.Equals("Skeleton_Poison", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("TrophySkeletonPoison") : (prefab.Equals("Blob", StringComparison.OrdinalIgnoreCase) ? GetItemIcon("Ooze") : ((!prefab.Equals("BlobElite", StringComparison.OrdinalIgnoreCase)) ? GetItemIcon("Trophy" + prefab) : GetItemIcon("TrophyBlob")))))))));
		}
		if ((Object)(object)val == (Object)null && (Object)(object)Minimap.instance != (Object)null)
		{
			val = Minimap.instance.m_icons.Find((SpriteData x) => (int)x.m_name == 3).m_icon;
			RedDotCreatures.Add(prefab);
		}
		if ((Object)(object)val != (Object)null)
		{
			CreatureIcons[prefab] = val;
		}
		return val;
	}

	private static Sprite ResolveWorldIcon(ZNetView view, int prefabHash)
	{
		if (WorldIcons.TryGetValue(prefabHash, out var value))
		{
			return value;
		}
		if ((Object)(object)view == (Object)null)
		{
			return null;
		}
		Sprite val = null;
		Pickable componentInChildren = ((Component)view).GetComponentInChildren<Pickable>(true);
		if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.m_itemPrefab != (Object)null)
		{
			ItemDrop component = componentInChildren.m_itemPrefab.GetComponent<ItemDrop>();
			val = ((component != null) ? component.m_itemData.GetIcon() : null);
		}
		if ((Object)(object)val == (Object)null)
		{
			Fish componentInChildren2 = ((Component)view).GetComponentInChildren<Fish>(true);
			if ((Object)(object)componentInChildren2 != (Object)null && (Object)(object)componentInChildren2.m_pickupItem != (Object)null)
			{
				ItemDrop component2 = componentInChildren2.m_pickupItem.GetComponent<ItemDrop>();
				val = ((component2 != null) ? component2.m_itemData.GetIcon() : null);
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			WorldIcons[prefabHash] = val;
		}
		return val;
	}

	internal static Sprite GetSelectionIcon(NearbyMarkerSelectionEntry entry)
	{
		if (entry == null || string.IsNullOrEmpty(entry.Key))
		{
			return null;
		}
		int num = entry.Key.IndexOf(':');
		if (num < 0 || num >= entry.Key.Length - 1)
		{
			return null;
		}
		string text = ((!string.IsNullOrEmpty(entry.IconPrefab)) ? entry.IconPrefab : entry.Key.Substring(num + 1));
		if (!string.IsNullOrEmpty(entry.IconPrefab))
		{
			return GetItemIcon(entry.IconPrefab);
		}
		if (entry.Kind == NearbyMarkerSelectionKind.Creature)
		{
			return ResolveCreatureIcon(text);
		}
		return GetItemIcon(text);
	}

	private static void UpdateActivePositions()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		foreach (KeyValuePair<Character, PinData> activeMarker in ActiveMarkers)
		{
			if (!((Object)(object)activeMarker.Key == (Object)null) && activeMarker.Value != null)
			{
				Vector3 position = ((Component)activeMarker.Key).transform.position;
				if (!(activeMarker.Value.m_pos == position))
				{
					activeMarker.Value.m_pos = position;
					flag = true;
				}
			}
		}
		if (flag && (Object)(object)Minimap.instance != (Object)null)
		{
			PinUpdateRequired.Invoke(Minimap.instance) = true;
		}
	}

	private static void UpdateCreatures()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: 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_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		HashSet<Character> hashSet = new HashSet<Character>();
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if ((Object)(object)allCharacter == (Object)null || allCharacter.IsDead() || allCharacter.IsPlayer())
			{
				continue;
			}
			string prefabName = Utils.GetPrefabName(((Component)allCharacter).gameObject);
			string creatureKey = GetCreatureKey(prefabName);
			if (!IsTargetVisible(creatureKey) || !NearbyMarkerSelectionCatalog.IsKeyUnlocked(creatureKey))
			{
				continue;
			}
			Sprite val = ResolveCreatureIcon(prefabName);
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			hashSet.Add(allCharacter);
			float num = Vector3.Distance(position, ((Component)allCharacter).transform.position);
			if (ActiveMarkers.TryGetValue(allCharacter, out var value))
			{
				if (num > 60f)
				{
					Minimap.instance.RemovePin(value);
					ActiveMarkers.Remove(allCharacter);
				}
			}
			else if (!(num > 50f))
			{
				value = Minimap.instance.AddPin(((Component)allCharacter).transform.position, (PinType)8, "", false, false, 0L, default(PlatformUserID));
				value.m_icon = val;
				ActiveMarkers.Add(allCharacter, value);
			}
		}
		RemoveMissingCharacters(hashSet);
	}

	private static void UpdateDynamicWorldObjects()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZNetScene.instance == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		HashSet<ZDO> hashSet = new HashSet<ZDO>();
		foreach (KeyValuePair<ZDO, ZNetView> item in Instances.Invoke(ZNetScene.instance))
		{
			ZDO key = item.Key;
			ZNetView value = item.Value;
			if (key == null || !key.IsValid() || (Object)(object)value == (Object)null)
			{
				continue;
			}
			Fish componentInChildren = ((Component)value).GetComponentInChildren<Fish>(true);
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.m_pickupItem == (Object)null)
			{
				continue;
			}
			string fishKey = GetFishKey(((Object)componentInChildren.m_pickupItem).name);
			if (!IsTargetVisible(fishKey) || !NearbyMarkerSelectionCatalog.IsKeyUnlocked(fishKey))
			{
				continue;
			}
			Sprite val = ResolveWorldIcon(value, key.GetPrefab());
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			hashSet.Add(key);
			Vector3 position2 = key.GetPosition();
			float num = Vector3.Distance(position, position2);
			if (ActiveDynamicWorldMarkers.TryGetValue(key, out var value2))
			{
				if (num > 60f)
				{
					Minimap.instance.RemovePin(value2);
					ActiveDynamicWorldMarkers.Remove(key);
				}
				else if (value2.m_pos != position2)
				{
					value2.m_pos = position2;
					PinUpdateRequired.Invoke(Minimap.instance) = true;
				}
			}
			else if (!(num > 50f))
			{
				value2 = Minimap.instance.AddPin(position2, (PinType)8, "", false, false, 0L, default(PlatformUserID));
				value2.m_icon = val;
				ActiveDynamicWorldMarkers.Add(key, value2);
			}
		}
		RemoveMissingWorldObjects(ActiveDynamicWorldMarkers, hashSet);
	}

	private static void UpdateStaticWorldObjects()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: 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)
		if ((Object)(object)ZNetScene.instance == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		HashSet<ZDO> hashSet = new HashSet<ZDO>();
		foreach (KeyValuePair<ZDO, ZNetV