Decompiled source of WorldAtlas v2.1.1

WorldAtlas.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModHub;
using Splatform;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WorldAtlas")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.1.1.0")]
[assembly: AssemblyInformationalVersion("2.1.1")]
[assembly: AssemblyProduct("WorldAtlas")]
[assembly: AssemblyTitle("WorldAtlas")]
[assembly: AssemblyVersion("2.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WorldAtlas
{
	internal static class AtlasNet
	{
		private const string RpcRequest = "WorldAtlas_Request";

		private const string RpcData = "WorldAtlas_Data";

		private const string RpcFound = "WorldAtlas_Found";

		private const string RpcFoundSync = "WorldAtlas_FoundSync";

		private const string RpcCross = "WorldAtlas_Cross";

		private const string RpcCrossSync = "WorldAtlas_CrossSync";

		private const int Proto = 1;

		private const int ChunkSize = 1500;

		private const float Timeout = 10f;

		private static List<KeyValuePair<string, Vector3>> _incoming;

		private static int _chunksGot;

		private static int _chunksTotal;

		private static ZRoutedRpc _registeredOn;

		public static void Register()
		{
			if (ZRoutedRpc.instance != null && _registeredOn != ZRoutedRpc.instance)
			{
				_registeredOn = ZRoutedRpc.instance;
				ZRoutedRpc.instance.Register<ZPackage>("WorldAtlas_Request", (Action<long, ZPackage>)OnRequest);
				ZRoutedRpc.instance.Register<ZPackage>("WorldAtlas_Data", (Action<long, ZPackage>)OnData);
				ZRoutedRpc.instance.Register<ZPackage>("WorldAtlas_Found", (Action<long, ZPackage>)OnFound);
				ZRoutedRpc.instance.Register<ZPackage>("WorldAtlas_FoundSync", (Action<long, ZPackage>)OnFoundSync);
				ZRoutedRpc.instance.Register<ZPackage>("WorldAtlas_Cross", (Action<long, ZPackage>)OnCross);
				ZRoutedRpc.instance.Register<ZPackage>("WorldAtlas_CrossSync", (Action<long, ZPackage>)OnCrossSync);
			}
		}

		public static void Tick()
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			if (LocationStore.Status == LocationStore.State.Idle)
			{
				Request();
			}
			if (LocationStore.Status != LocationStore.State.Loading || !(LocationStore.RequestTime >= 0f))
			{
				return;
			}
			if (ZNet.instance.IsServer())
			{
				if (Time.time - LocationStore.RequestTime > 2f)
				{
					Request();
				}
			}
			else if (Time.time - LocationStore.RequestTime > 10f && _chunksGot == 0)
			{
				LocationStore.Status = LocationStore.State.NoServerMod;
			}
		}

		public static void Request()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			LocationStore.Status = LocationStore.State.Loading;
			LocationStore.RequestTime = Time.time;
			if (ZNet.instance.IsServer())
			{
				List<KeyValuePair<string, Vector3>> list = LocationStore.ReadFromZoneSystem();
				if (list != null && list.Count > 0)
				{
					LocationStore.Set(list);
				}
			}
			else if (ZRoutedRpc.instance != null)
			{
				_incoming = null;
				_chunksGot = 0;
				_chunksTotal = 0;
				ZPackage val = new ZPackage();
				val.Write(1);
				ZNetPeer serverPeer = ZNet.instance.GetServerPeer();
				if (serverPeer != null)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(serverPeer.m_uid, "WorldAtlas_Request", new object[1] { val });
				}
				else
				{
					ZRoutedRpc.instance.InvokeRoutedRPC("WorldAtlas_Request", new object[1] { val });
				}
			}
		}

		private static void OnRequest(long sender, ZPackage req)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			List<KeyValuePair<string, Vector3>> list = LocationStore.ReadFromZoneSystem();
			if (list == null)
			{
				list = new List<KeyValuePair<string, Vector3>>();
			}
			int num = Mathf.Max(1, Mathf.CeilToInt((float)list.Count / 1500f));
			for (int i = 0; i < num; i++)
			{
				int num2 = i * 1500;
				int num3 = Mathf.Min(list.Count, num2 + 1500);
				List<string> list2 = new List<string>();
				Dictionary<string, int> dictionary = new Dictionary<string, int>();
				for (int j = num2; j < num3; j++)
				{
					if (!dictionary.ContainsKey(list[j].Key))
					{
						dictionary[list[j].Key] = list2.Count;
						list2.Add(list[j].Key);
					}
				}
				ZPackage val = new ZPackage();
				val.Write(1);
				val.Write(i);
				val.Write(num);
				val.Write(list2.Count);
				foreach (string item in list2)
				{
					val.Write(item);
				}
				val.Write(num3 - num2);
				for (int k = num2; k < num3; k++)
				{
					val.Write(dictionary[list[k].Key]);
					val.Write(list[k].Value.x);
					val.Write(list[k].Value.y);
					val.Write(list[k].Value.z);
				}
				ZRoutedRpc.instance.InvokeRoutedRPC(sender, "WorldAtlas_Data", new object[1] { val });
			}
			Plugin.Log($"Sent {list.Count} locations in {num} part(s)");
			SendFoundTo(sender, FoundStore.All);
			SendCrossTo(sender, ToChanges(CrossStore.All), full: true);
		}

		private static List<KeyValuePair<string, bool>> ToChanges(IEnumerable<string> keys)
		{
			List<KeyValuePair<string, bool>> list = new List<KeyValuePair<string, bool>>();
			foreach (string key in keys)
			{
				list.Add(new KeyValuePair<string, bool>(key, value: true));
			}
			return list;
		}

		public static void SendCrossed(List<KeyValuePair<string, bool>> changes)
		{
			if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null || changes.Count == 0)
			{
				return;
			}
			if (ZNet.instance.IsServer())
			{
				SendCrossTo(0L, changes, full: false);
				return;
			}
			ZPackage val = PackCross(changes, full: false);
			ZNetPeer serverPeer = ZNet.instance.GetServerPeer();
			if (serverPeer != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(serverPeer.m_uid, "WorldAtlas_Cross", new object[1] { val });
			}
			else
			{
				ZRoutedRpc.instance.InvokeRoutedRPC("WorldAtlas_Cross", new object[1] { val });
			}
		}

		private static void SendCrossTo(long target, List<KeyValuePair<string, bool>> changes, bool full)
		{
			if (full)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(target, "WorldAtlas_CrossSync", new object[1] { PackCross(changes, full: true) });
				return;
			}
			for (int i = 0; i < changes.Count; i += 2000)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(target, "WorldAtlas_CrossSync", new object[1] { PackCross(changes.GetRange(i, Mathf.Min(2000, changes.Count - i)), full: false) });
			}
		}

		private static ZPackage PackCross(List<KeyValuePair<string, bool>> changes, bool full)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			val.Write(1);
			val.Write(full);
			val.Write(changes.Count);
			foreach (KeyValuePair<string, bool> change in changes)
			{
				val.Write(change.Key);
				val.Write(change.Value);
			}
			return val;
		}

		private static List<KeyValuePair<string, bool>> UnpackCross(ZPackage pkg, out bool full)
		{
			full = false;
			List<KeyValuePair<string, bool>> list = new List<KeyValuePair<string, bool>>();
			if (pkg.ReadInt() != 1)
			{
				return list;
			}
			full = pkg.ReadBool();
			int num = pkg.ReadInt();
			for (int i = 0; i < num; i++)
			{
				string key = pkg.ReadString();
				bool value = pkg.ReadBool();
				list.Add(new KeyValuePair<string, bool>(key, value));
			}
			return list;
		}

		private static void OnCross(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				bool full;
				List<KeyValuePair<string, bool>> list = CrossStore.Apply(UnpackCross(pkg, out full), full: false);
				if (list.Count > 0)
				{
					SendCrossTo(0L, list, full: false);
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Cross from client: " + ex.Message);
			}
		}

		private static void OnCrossSync(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				bool full;
				List<KeyValuePair<string, bool>> changes = UnpackCross(pkg, out full);
				CrossStore.Apply(changes, full);
			}
			catch (Exception ex)
			{
				Plugin.LogError("Cross sync: " + ex.Message);
			}
		}

		public static void SendFound(List<string> keys)
		{
			if ((Object)(object)ZNet.instance == (Object)null || ZRoutedRpc.instance == null || keys.Count == 0)
			{
				return;
			}
			if (ZNet.instance.IsServer())
			{
				SendFoundTo(0L, keys);
				return;
			}
			ZPackage val = Pack(keys);
			ZNetPeer serverPeer = ZNet.instance.GetServerPeer();
			if (serverPeer != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(serverPeer.m_uid, "WorldAtlas_Found", new object[1] { val });
			}
			else
			{
				ZRoutedRpc.instance.InvokeRoutedRPC("WorldAtlas_Found", new object[1] { val });
			}
		}

		private static void SendFoundTo(long target, IEnumerable<string> keys)
		{
			List<string> list = new List<string>(keys);
			for (int i = 0; i < list.Count; i += 2000)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(target, "WorldAtlas_FoundSync", new object[1] { Pack(list.GetRange(i, Mathf.Min(2000, list.Count - i))) });
			}
		}

		private static ZPackage Pack(List<string> keys)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			val.Write(1);
			val.Write(keys.Count);
			foreach (string key in keys)
			{
				val.Write(key);
			}
			return val;
		}

		private static List<string> Unpack(ZPackage pkg)
		{
			List<string> list = new List<string>();
			if (pkg.ReadInt() != 1)
			{
				return list;
			}
			int num = pkg.ReadInt();
			for (int i = 0; i < num; i++)
			{
				list.Add(pkg.ReadString());
			}
			return list;
		}

		private static void OnFound(long sender, ZPackage pkg)
		{
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				List<string> list = FoundStore.AddMany(Unpack(pkg));
				if (list.Count > 0)
				{
					SendFoundTo(0L, list);
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Found from client: " + ex.Message);
			}
		}

		private static void OnFoundSync(long sender, ZPackage pkg)
		{
			try
			{
				FoundStore.AddMany(Unpack(pkg));
			}
			catch (Exception ex)
			{
				Plugin.LogError("Found sync: " + ex.Message);
			}
		}

		private static void OnData(long sender, ZPackage pkg)
		{
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null || ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				if (pkg.ReadInt() != 1)
				{
					return;
				}
				int num = pkg.ReadInt();
				int chunksTotal = pkg.ReadInt();
				if (num == 0 || _incoming == null)
				{
					_incoming = new List<KeyValuePair<string, Vector3>>();
					_chunksGot = 0;
				}
				_chunksTotal = chunksTotal;
				int num2 = pkg.ReadInt();
				string[] array = new string[num2];
				for (int i = 0; i < num2; i++)
				{
					array[i] = pkg.ReadString();
				}
				int num3 = pkg.ReadInt();
				for (int j = 0; j < num3; j++)
				{
					int num4 = pkg.ReadInt();
					float num5 = pkg.ReadSingle();
					float num6 = pkg.ReadSingle();
					float num7 = pkg.ReadSingle();
					if (num4 >= 0 && num4 < array.Length)
					{
						_incoming.Add(new KeyValuePair<string, Vector3>(array[num4], new Vector3(num5, num6, num7)));
					}
				}
				_chunksGot++;
				if (_chunksGot >= _chunksTotal)
				{
					LocationStore.Set(_incoming);
					_incoming = null;
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Bad location data: " + ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(Game), "Start")]
	internal static class GameStartPatch
	{
		private static void Prefix()
		{
			AtlasNet.Register();
		}
	}
	[HarmonyPatch(typeof(ZNet), "Awake")]
	internal static class ZNetAwakePatchFound
	{
		private static void Postfix()
		{
			FoundStore.Clear();
			CrossStore.Clear();
		}
	}
	[HarmonyPatch(typeof(ZNet), "Awake")]
	internal static class ZNetAwakePatch
	{
		private static void Postfix()
		{
			LocationStore.Clear();
			Icons.Clear();
			AtlasNet.Register();
		}
	}
	internal class AtlasWindow
	{
		private const string BlockOwner = "worldatlas";

		private const float LeftW = 340f;

		private const float RowH = 28f;

		private const float CatH = 32f;

		private float _cx;

		private float _cz;

		private float _zoom = -1f;

		private bool _dragging;

		private Vector2 _dragStart;

		private Vector2 _dragLast;

		private string _search = "";

		private Vector2 _listScroll;

		private Loc _selected;

		private Loc _hovered;

		private PinData _hoveredPin;

		private Vector3? _pendingFocus;

		private bool _pinDialog;

		private bool _pinDialogFocus;

		private Vector3 _pinPos;

		private string _pinName = "";

		private int _pinIcon = 3;

		private Rect _pinDialogRect;

		private static readonly PinType[] PinTypes;

		private Sprite[] _pinSprites;

		private string _toast;

		private float _toastUntil;

		private float _nextFog;

		private bool _fogDirty = true;

		private GUIStyle _mapLabel;

		private GUIStyle _mapLabelShadow;

		private GUIStyle _countStyle;

		private GUIStyle _smallDim;

		private GUIStyle _crossStyle;

		private static FieldInfo _pinsField;

		private static Sprite _foundMark;

		private static Sprite _crossMark;

		public bool IsOpen { get; private set; }

		public void Open()
		{
			IsOpen = true;
			ModHubAPI.SetInputBlock("worldatlas", true);
			_fogDirty = true;
			_hovered = null;
			_pinDialog = false;
			if (LocationStore.Status == LocationStore.State.NoServerMod)
			{
				AtlasNet.Request();
			}
			WorldAtlasAPI.RaiseOpenChanged(open: true);
		}

		public void FocusOn(Vector3 p)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			_pendingFocus = p;
		}

		public void Close()
		{
			if (IsOpen)
			{
				IsOpen = false;
				_dragging = false;
				_pinDialog = false;
				GUIUtility.keyboardControl = 0;
				ModHubAPI.SetInputBlock("worldatlas", false);
				WorldAtlasAPI.RaiseOpenChanged(open: false);
			}
		}

		public bool HandleEscape()
		{
			if (_pinDialog)
			{
				_pinDialog = false;
				GUIUtility.keyboardControl = 0;
				return true;
			}
			if (GUIUtility.keyboardControl != 0)
			{
				GUIUtility.keyboardControl = 0;
				return true;
			}
			if (_selected != null)
			{
				_selected = null;
				return true;
			}
			return false;
		}

		public void Draw()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = HubUI.BeginScaled();
			try
			{
				EnsureStyles();
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(20f, 20f, val.x - 40f, val.y - 40f);
				HubUI.Window(val2, (string)null, false);
				if (HubUI.CloseButton(val2))
				{
					Close();
					return;
				}
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(((Rect)(ref val2)).x + 30f, ((Rect)(ref val2)).y + 30f, 340f, ((Rect)(ref val2)).height - 60f);
				Rect map = default(Rect);
				((Rect)(ref map))..ctor(((Rect)(ref r)).xMax + 18f, ((Rect)(ref val2)).y + 70f, ((Rect)(ref val2)).xMax - 30f - (((Rect)(ref r)).xMax + 18f), ((Rect)(ref val2)).height - 70f - 30f - 34f);
				Rect val3 = default(Rect);
				((Rect)(ref val3))..ctor(((Rect)(ref map)).x, ((Rect)(ref val2)).y + 18f, ((Rect)(ref map)).width, 50f);
				Rect r2 = default(Rect);
				((Rect)(ref r2))..ctor(((Rect)(ref map)).x, ((Rect)(ref map)).yMax + 6f, ((Rect)(ref map)).width, 28f);
				GUI.Label(val3, L.T("title").ToUpperInvariant(), HubUI.TitleStyle);
				if (Time.unscaledTime >= _nextFog || _fogDirty)
				{
					RefreshFog();
				}
				if (_zoom < 0f)
				{
					_zoom = FitZoom(map);
					_cx = 0f;
					_cz = 0f;
				}
				if (_pendingFocus.HasValue)
				{
					_cx = _pendingFocus.Value.x;
					_cz = _pendingFocus.Value.z;
					_zoom = Mathf.Max(_zoom, FitZoom(map) * 6f);
					_pendingFocus = null;
				}
				DrawLeft(r);
				DrawMap(map);
				DrawStatus(r2, map);
				HandleMapInput(map);
			}
			finally
			{
				HubUI.EndScaled();
			}
		}

		private void EnsureStyles()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0053: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00b4: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			if (_mapLabel == null || !((Object)(object)_mapLabel.font == (Object)(object)HubUI.Font))
			{
				_mapLabel = new GUIStyle(HubUI.LabelStyle)
				{
					fontSize = 13,
					alignment = (TextAnchor)1,
					wordWrap = false
				};
				_mapLabelShadow = new GUIStyle(_mapLabel);
				_mapLabelShadow.normal.textColor = new Color(0f, 0f, 0f, 0.85f);
				_countStyle = new GUIStyle(HubUI.LabelDimStyle)
				{
					alignment = (TextAnchor)5,
					wordWrap = false
				};
				_smallDim = new GUIStyle(HubUI.LabelDimStyle)
				{
					fontSize = 13,
					wordWrap = false
				};
				_crossStyle = new GUIStyle(HubUI.LabelStyle)
				{
					fontSize = 22,
					alignment = (TextAnchor)4,
					wordWrap = false
				};
			}
		}

		private void DrawLeft(Rect r)
		{
			//IL_001d: 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_0091: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			float y = ((Rect)(ref r)).y;
			HubUI.LabelDim(new Rect(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, 22f), L.F("seed", MapRenderer.SeedName));
			y += 24f;
			HubUI.LabelDim(new Rect(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, 22f), StatusText());
			y += 28f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, 34f);
			_search = HubUI.TextField(val, _search);
			if (string.IsNullOrEmpty(_search) && GUIUtility.keyboardControl == 0)
			{
				GUI.Label(new Rect(((Rect)(ref val)).x + 12f, ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height), L.T("search"), HubUI.LabelDimStyle);
			}
			y += 42f;
			float num = (((Rect)(ref r)).width - 10f) * 0.5f;
			if (HubUI.Button(new Rect(((Rect)(ref r)).x, y, num, 32f), L.T("all")))
			{
				SetAll(hidden: false);
			}
			if (HubUI.Button(new Rect(((Rect)(ref r)).x + num + 10f, y, num, 32f), L.T("none")))
			{
				SetAll(hidden: true);
			}
			y += 38f;
			if (HubUI.Button(new Rect(((Rect)(ref r)).x, y, num, 28f), L.T("collapse_all")))
			{
				Plugin.SetAllCollapsed(collapsed: true);
			}
			if (HubUI.Button(new Rect(((Rect)(ref r)).x + num + 10f, y, num, 28f), L.T("expand_all")))
			{
				Plugin.SetAllCollapsed(collapsed: false);
			}
			y += 36f;
			int count = WorldAtlasAPI.Toggles.Count;
			float num2 = (6 + count) * 28 + 8 + 36;
			Rect r2 = default(Rect);
			((Rect)(ref r2))..ctor(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, ((Rect)(ref r)).yMax - num2 - 8f - y);
			DrawTypeList(r2);
			float num3 = ((Rect)(ref r)).yMax - num2;
			Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), Plugin.OnlyExplored, L.T("only_explored"));
			num3 += 28f;
			if (Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), Plugin.DimUnexplored, L.T("dim_unexplored")))
			{
				_fogDirty = true;
			}
			num3 += 28f;
			Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), Plugin.ShowPlayers, L.T("players"));
			num3 += 28f;
			Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), Plugin.ShowMyPins, L.T("my_pins"));
			num3 += 28f;
			Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), Plugin.ShowModPins, ModPinsLabel());
			num3 += 28f;
			foreach (WorldAtlasAPI.AtlasToggle toggle in WorldAtlasAPI.Toggles)
			{
				bool flag = SafeGet(toggle.Get);
				bool flag2 = HubUI.Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), flag, SafeLabel(toggle.Label));
				if (flag2 != flag)
				{
					try
					{
						toggle.Set?.Invoke(flag2);
					}
					catch (Exception ex)
					{
						Plugin.LogError("[" + toggle.Id + "] " + ex.Message);
					}
				}
				num3 += 28f;
			}
			Toggle(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, 26f), Plugin.ShowLabels, L.T("labels"));
			num3 += 36f;
			if (HubUI.Button(new Rect(((Rect)(ref r)).x, num3, num, 34f), L.T("center_player")))
			{
				CenterOnPlayer();
			}
			if (HubUI.Button(new Rect(((Rect)(ref r)).x + num + 10f, num3, num, 34f), L.T("settings")))
			{
				Plugin.OpenSettings();
			}
		}

		private static bool Toggle(Rect r, ConfigEntry<bool> entry, string text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			bool flag = HubUI.Toggle(r, entry.Value, text);
			if (flag == entry.Value)
			{
				return false;
			}
			entry.Value = flag;
			GamePins.ForceRefresh();
			return true;
		}

		private string StatusText()
		{
			if (MapRenderer.Busy)
			{
				return L.F("status_generating", Mathf.RoundToInt(MapRenderer.Progress * 100f));
			}
			return LocationStore.Status switch
			{
				LocationStore.State.Ready => L.F("status_count", LocationStore.All.Count) + "   ·   " + L.F("found_count", FoundStore.Count), 
				LocationStore.State.NoServerMod => L.T("status_noserver"), 
				_ => L.T("status_loading"), 
			};
		}

		private List<LocType> TypesOf(string cat)
		{
			List<LocType> list = new List<LocType>();
			foreach (LocType value in Catalog.Types.Values)
			{
				if (value.Category == cat && value.Count > 0 && MatchesSearch(value))
				{
					list.Add(value);
				}
			}
			list.Sort(Catalog.Compare);
			return list;
		}

		private bool MatchesSearch(LocType t)
		{
			return string.IsNullOrEmpty(_search) || t.Name.IndexOf(_search, StringComparison.CurrentCultureIgnoreCase) >= 0 || t.SamplePrefab.IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private void DrawTypeList(Rect r)
		{
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<string, List<LocType>>> list = new List<KeyValuePair<string, List<LocType>>>();
			float num = 0f;
			string[] categories = Catalog.Categories;
			foreach (string text in categories)
			{
				List<LocType> list2 = TypesOf(text);
				if (list2.Count != 0)
				{
					list.Add(new KeyValuePair<string, List<LocType>>(text, list2));
					num += 36f;
					if (!Plugin.IsCollapsed(text) || !string.IsNullOrEmpty(_search))
					{
						num += (float)list2.Count * 28f;
					}
				}
			}
			if (list.Count == 0)
			{
				HubUI.LabelDim(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 28f), (LocationStore.Status == LocationStore.State.Ready) ? L.T("nothing_here") : "");
				return;
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(0f, 0f, ((Rect)(ref r)).width - 16f, num);
			_listScroll = GUI.BeginScrollView(r, _listScroll, val, false, false, GUIStyle.none, GUI.skin.verticalScrollbar);
			float num2 = 0f;
			Rect val2 = default(Rect);
			Rect val3 = default(Rect);
			Rect val4 = default(Rect);
			Rect r2 = default(Rect);
			Rect val6 = default(Rect);
			foreach (KeyValuePair<string, List<LocType>> item in list)
			{
				string key = item.Key;
				List<LocType> value = item.Value;
				bool flag = !Plugin.IsCollapsed(key) || !string.IsNullOrEmpty(_search);
				int num3 = 0;
				bool flag2 = true;
				foreach (LocType item2 in value)
				{
					num3 += item2.Count;
					if (Plugin.IsTypeHidden(item2.Key))
					{
						flag2 = false;
					}
				}
				((Rect)(ref val2))..ctor(0f, num2, ((Rect)(ref val)).width, 32f);
				HubUI.Slot(val2, ((Rect)(ref val2)).Contains(Event.current.mousePosition), false);
				HubUI.Dot(new Vector2(((Rect)(ref val2)).x + 44f, ((Rect)(ref val2)).center.y), 12f, Catalog.CategoryColor(key));
				bool flag3 = HubUI.Toggle(new Rect(((Rect)(ref val2)).x + 8f, ((Rect)(ref val2)).y, 24f, ((Rect)(ref val2)).height), flag2, "");
				if (flag3 != flag2)
				{
					List<string> list3 = new List<string>();
					foreach (LocType item3 in value)
					{
						list3.Add(item3.Key);
					}
					Plugin.SetTypesHidden(list3, !flag3);
					GamePins.ForceRefresh();
				}
				((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 56f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width - 56f - 70f, ((Rect)(ref val2)).height);
				GUI.Label(val3, "<b>" + Catalog.CategoryName(key) + "</b>", HubUI.LabelStyle);
				GUI.Label(new Rect(((Rect)(ref val2)).xMax - 76f, ((Rect)(ref val2)).y, 46f, ((Rect)(ref val2)).height), num3.ToString(), _countStyle);
				GUI.Label(new Rect(((Rect)(ref val2)).xMax - 26f, ((Rect)(ref val2)).y, 20f, ((Rect)(ref val2)).height), flag ? "▾" : "▸", HubUI.LabelStyle);
				if (GUI.Button(new Rect(((Rect)(ref val3)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).xMax - ((Rect)(ref val3)).x, ((Rect)(ref val2)).height), GUIContent.none, GUIStyle.none))
				{
					Plugin.ToggleCollapsed(key);
				}
				num2 += 36f;
				if (!flag)
				{
					continue;
				}
				foreach (LocType item4 in value)
				{
					((Rect)(ref val4))..ctor(16f, num2, ((Rect)(ref val)).width - 16f, 28f);
					bool flag4 = !Plugin.IsTypeHidden(item4.Key);
					bool flag5 = HubUI.Toggle(new Rect(((Rect)(ref val4)).x, ((Rect)(ref val4)).y, 24f, ((Rect)(ref val4)).height), flag4, "");
					if (flag5 != flag4)
					{
						Plugin.SetTypeHidden(item4.Key, !flag5);
						GamePins.ForceRefresh();
					}
					((Rect)(ref r2))..ctor(((Rect)(ref val4)).x + 32f, ((Rect)(ref val4)).y + 3f, 22f, 22f);
					Sprite val5 = (Plugin.UseIcons.Value ? Icons.Get(item4) : null);
					if ((Object)(object)val5 != (Object)null)
					{
						Icons.Draw(r2, item4);
					}
					else
					{
						HubUI.Dot(((Rect)(ref r2)).center, 12f, Catalog.CategoryColor(item4.Category));
					}
					((Rect)(ref val6))..ctor(((Rect)(ref r2)).xMax + 8f, ((Rect)(ref val4)).y, ((Rect)(ref val4)).width - (((Rect)(ref r2)).xMax + 8f - ((Rect)(ref val4)).x) - 50f, ((Rect)(ref val4)).height);
					Rect val7 = new Rect(((Rect)(ref val6)).x, ((Rect)(ref val4)).y, ((Rect)(ref val4)).xMax - ((Rect)(ref val6)).x, ((Rect)(ref val4)).height);
					bool flag6 = ((Rect)(ref val7)).Contains(Event.current.mousePosition);
					GUI.Label(val6, flag6 ? ("<color=#E8C36A>" + item4.Name + "</color>") : item4.Name, HubUI.NoWrap(flag4 ? HubUI.LabelStyle : HubUI.LabelDimStyle));
					int num4 = MapPanel.FoundOf(item4);
					GUI.Label(new Rect(((Rect)(ref val4)).xMax - 72f, ((Rect)(ref val4)).y, 66f, ((Rect)(ref val4)).height), (num4 > 0) ? $"<color=#7CD67C>{num4}</color>/{item4.Count}" : item4.Count.ToString(), _countStyle);
					if (GUI.Button(new Rect(((Rect)(ref val6)).x, ((Rect)(ref val4)).y, ((Rect)(ref val4)).xMax - ((Rect)(ref val6)).x, ((Rect)(ref val4)).height), GUIContent.none, GUIStyle.none))
					{
						JumpToNearest(item4);
					}
					num2 += 28f;
				}
			}
			GUI.EndScrollView();
		}

		private void SetAll(bool hidden)
		{
			List<string> list = new List<string>();
			foreach (LocType value in Catalog.Types.Values)
			{
				if (value.Count > 0 && MatchesSearch(value))
				{
					list.Add(value.Key);
				}
			}
			Plugin.SetTypesHidden(list, hidden);
			GamePins.ForceRefresh();
		}

		private static float FitZoom(Rect map)
		{
			return Mathf.Min(((Rect)(ref map)).width, ((Rect)(ref map)).height) / 21000f;
		}

		private Vector2 W2L(Rect map, Vector3 p)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(((Rect)(ref map)).width * 0.5f + (p.x - _cx) * _zoom, ((Rect)(ref map)).height * 0.5f - (p.z - _cz) * _zoom);
		}

		private Vector3 S2W(Rect map, Vector2 s)
		{
			//IL_0006: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(_cx + (s.x - ((Rect)(ref map)).center.x) / _zoom, 0f, _cz - (s.y - ((Rect)(ref map)).center.y) / _zoom);
		}

		private bool LocVisible(Loc l)
		{
			if (Plugin.IsTypeHidden(l.Type.Key))
			{
				return false;
			}
			if (Plugin.OnlyExplored.Value && !l.Explored)
			{
				return false;
			}
			if (Plugin.HideFound.Value && l.Found)
			{
				return false;
			}
			if (Plugin.HideCrossed.Value && l.Crossed)
			{
				return false;
			}
			if (!string.IsNullOrEmpty(_search) && !MatchesSearch(l.Type))
			{
				return false;
			}
			return true;
		}

		private void DrawMap(Rect map)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: 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_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			Vector2 mousePosition = current.mousePosition;
			bool flag = ((Rect)(ref map)).Contains(mousePosition);
			Color color = GUI.color;
			GUI.color = MapRenderer.OutsideColor;
			GUI.DrawTexture(map, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
			GUI.BeginGroup(map);
			try
			{
				float num = 21000f * _zoom;
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref map)).width * 0.5f + (-10500f - _cx) * _zoom, ((Rect)(ref map)).height * 0.5f - (10500f - _cz) * _zoom, num, num);
				if (MapRenderer.Ready && (Object)(object)MapRenderer.Map != (Object)null)
				{
					GUI.DrawTexture(val, (Texture)(object)MapRenderer.Map);
				}
				else
				{
					GUI.Label(new Rect(0f, ((Rect)(ref map)).height * 0.5f - 20f, ((Rect)(ref map)).width, 40f), L.F("status_generating", Mathf.RoundToInt(MapRenderer.Progress * 100f)), HubUI.TileLabelStyle);
				}
				if (Plugin.DimUnexplored.Value && (Object)(object)MapRenderer.Fog != (Object)null)
				{
					GUI.DrawTexture(val, (Texture)(object)MapRenderer.Fog);
				}
				Vector2 val2 = mousePosition - ((Rect)(ref map)).position;
				_hovered = null;
				_hoveredPin = null;
				float num2 = float.MaxValue;
				float value = Plugin.IconSize.Value;
				float num3 = FitZoom(map);
				bool flag2 = Plugin.ShowLabels.Value && _zoom >= num3 * 6f;
				Rect val3 = default(Rect);
				((Rect)(ref val3))..ctor(0f - value, 0f - value, ((Rect)(ref map)).width + value * 2f, ((Rect)(ref map)).height + value * 2f);
				List<KeyValuePair<Loc, Vector2>> list = new List<KeyValuePair<Loc, Vector2>>();
				Vector2 val5;
				foreach (Loc item in LocationStore.All)
				{
					if (!LocVisible(item))
					{
						continue;
					}
					Vector2 val4 = W2L(map, item.Pos);
					if (!((Rect)(ref val3)).Contains(val4))
					{
						continue;
					}
					list.Add(new KeyValuePair<Loc, Vector2>(item, val4));
					if (!flag)
					{
						continue;
					}
					if (_dragging)
					{
						val5 = _dragStart - mousePosition;
						if (!(((Vector2)(ref val5)).sqrMagnitude < 25f))
						{
							continue;
						}
					}
					val5 = val4 - val2;
					float sqrMagnitude = ((Vector2)(ref val5)).sqrMagnitude;
					float num4 = value * 0.6f + 4f;
					if (sqrMagnitude < num4 * num4 && sqrMagnitude < num2)
					{
						num2 = sqrMagnitude;
						_hovered = item;
					}
				}
				list.Sort((KeyValuePair<Loc, Vector2> a, KeyValuePair<Loc, Vector2> b) => Catalog.Rank(b.Key.Type).CompareTo(Catalog.Rank(a.Key.Type)));
				foreach (KeyValuePair<Loc, Vector2> item2 in list)
				{
					DrawLoc(item2.Key, item2.Value, value, item2.Key == _hovered || item2.Key == _selected);
				}
				if (flag2 && list.Count <= 400)
				{
					foreach (KeyValuePair<Loc, Vector2> item3 in list)
					{
						DrawMapLabel(item3.Value + new Vector2(0f, value * 0.5f + 2f), item3.Key.Type.Name);
					}
				}
				Rect map2 = map;
				int mouseIn;
				if (flag)
				{
					if (_dragging)
					{
						val5 = _dragStart - mousePosition;
						mouseIn = ((((Vector2)(ref val5)).sqrMagnitude < 25f) ? 1 : 0);
					}
					else
					{
						mouseIn = 1;
					}
				}
				else
				{
					mouseIn = 0;
				}
				DrawUserPins(map2, flag2, val2, (byte)mouseIn != 0);
				if (Plugin.ShowPlayers.Value)
				{
					DrawPlayers(map);
				}
			}
			finally
			{
				GUI.EndGroup();
			}
			DrawZoomButtons(map);
			DrawLegend(map);
			if (_selected != null)
			{
				DrawSelected(map);
			}
			else if (_hovered != null && flag)
			{
				DrawTooltip(map, _hovered, mousePosition);
			}
			else if (_hoveredPin != null && flag)
			{
				DrawPinTooltip(map, _hoveredPin, mousePosition);
			}
			if (_pinDialog)
			{
				DrawPinDialog(map);
			}
			DrawToast(map);
		}

		private static int Priority(string cat)
		{
			return cat switch
			{
				"bosses" => 6, 
				"traders" => 5, 
				"special" => 4, 
				"dungeons" => 3, 
				"camps" => 2, 
				"resources" => 1, 
				_ => 0, 
			};
		}

		private void DrawLoc(Loc l, Vector2 p, float size, bool highlight)
		{
			//IL_0003: 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_006a: 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_00d2: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
			DrawLocBody(l, p, size, highlight);
			if (Plugin.MarkFound.Value && l.Found)
			{
				if ((Object)(object)_foundMark == (Object)null)
				{
					_foundMark = Icons.Badge("_found");
				}
				float num = size * 0.55f;
				if ((Object)(object)_foundMark != (Object)null)
				{
					HubUI.DrawSprite(new Rect(p.x + size * 0.15f, p.y - size * 0.7f, num, num), _foundMark);
				}
			}
			if (l.Crossed)
			{
				if ((Object)(object)_crossMark == (Object)null)
				{
					_crossMark = Icons.Badge("_cross");
				}
				float num2 = size + 6f;
				if ((Object)(object)_crossMark != (Object)null)
				{
					HubUI.DrawSprite(new Rect(p.x - num2 * 0.5f, p.y - num2 * 0.5f, num2, num2), _crossMark);
				}
			}
		}

		private void DrawLocBody(Loc l, Vector2 p, float size, bool highlight)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			Color val = Catalog.CategoryColor(l.Type.Category);
			if (highlight)
			{
				HubUI.Dot(p, size + 10f, HubUI.GoldBright);
			}
			Sprite val2 = (Plugin.UseIcons.Value ? Icons.Get(l.Type) : null);
			if ((Object)(object)val2 != (Object)null && Icons.BadgesOn)
			{
				float num = size + 6f;
				Icons.Draw(new Rect(p.x - num * 0.5f, p.y - num * 0.5f, num, num), l.Type);
			}
			else if ((Object)(object)val2 != (Object)null)
			{
				HubUI.Dot(p, size + 4f, val);
				HubUI.Dot(p, size, new Color(0.08f, 0.07f, 0.06f, 0.92f));
				float num2 = size * 0.78f;
				HubUI.DrawSprite(new Rect(p.x - num2 * 0.5f, p.y - num2 * 0.5f, num2, num2), val2);
			}
			else
			{
				float num3 = (Plugin.UseIcons.Value ? (size * 0.62f) : (size * 0.45f));
				HubUI.Dot(p, num3 + 3f, new Color(0f, 0f, 0f, 0.8f));
				HubUI.Dot(p, num3, val);
			}
		}

		private void DrawMapLabel(Vector2 topCenter, string text)
		{
			//IL_0003: 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_004c: 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)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(topCenter.x - 100f, topCenter.y, 200f, 18f);
			GUI.Label(new Rect(((Rect)(ref val)).x + 1f, ((Rect)(ref val)).y + 1f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), text, _mapLabelShadow);
			GUI.Label(val, text, _mapLabel);
		}

		private List<PinData> GamePinList()
		{
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			if (_pinsField == null)
			{
				_pinsField = AccessTools.Field(typeof(Minimap), "m_pins");
			}
			return _pinsField?.GetValue(instance) as List<PinData>;
		}

		private static bool IsOwnPin(PinData p)
		{
			return p.m_save && MapRadarBridge.Get(p) == null;
		}

		private void DrawUserPins(Rect map, bool labels, Vector2 localMouse, bool mouseIn)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Invalid comparison between Unknown and I4
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Invalid comparison between Unknown and I4
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			List<PinData> list = GamePinList();
			if (list == null)
			{
				return;
			}
			bool value = Plugin.ShowMyPins.Value;
			bool value2 = Plugin.ShowModPins.Value;
			if (!value && !value2)
			{
				return;
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(-20f, -20f, ((Rect)(ref map)).width + 40f, ((Rect)(ref map)).height + 40f);
			float num = 196f;
			foreach (PinData item in list)
			{
				if (item == null || GamePins.IsOurs(item) || (int)item.m_type == 10 || (int)item.m_type == 12)
				{
					continue;
				}
				bool flag = IsOwnPin(item);
				if (flag ? (!value) : (!value2))
				{
					continue;
				}
				Vector2 val2 = W2L(map, item.m_pos);
				if (!((Rect)(ref val)).Contains(val2))
				{
					continue;
				}
				MapRadarBridge.Info info = (flag ? null : MapRadarBridge.Get(item));
				if (info != null)
				{
					DrawRadarPin(val2, info);
				}
				else
				{
					float num2 = (flag ? 22f : 18f);
					if ((Object)(object)item.m_icon != (Object)null)
					{
						HubUI.DrawSprite(new Rect(val2.x - num2 * 0.5f, val2.y - num2 * 0.5f, num2, num2), item.m_icon);
					}
					else
					{
						HubUI.Dot(val2, num2 * 0.5f, HubUI.Gold);
					}
					if (item.m_checked)
					{
						GUI.Label(new Rect(val2.x - 12f, val2.y - 14f, 24f, 28f), "<color=#D83A30><b>X</b></color>", _crossStyle);
					}
					if (labels && !string.IsNullOrEmpty(item.m_name))
					{
						DrawMapLabel(val2 + new Vector2(0f, num2 * 0.5f + 1f), item.m_name);
					}
				}
				if (mouseIn)
				{
					Vector2 val3 = val2 - localMouse;
					float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						_hoveredPin = item;
					}
				}
			}
			if (_hoveredPin != null)
			{
				_hovered = null;
			}
		}

		private void DrawRadarPin(Vector2 p, MapRadarBridge.Info r)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_009d: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			float num = 20f + Mathf.Min(8f, (float)Mathf.Max(0, r.Count - 1) * 1.2f);
			Color color = GUI.color;
			if (r.Hidden)
			{
				GUI.color = new Color(1f, 1f, 1f, 0.4f);
			}
			if ((Object)(object)r.Icon != (Object)null)
			{
				HubUI.DrawSprite(new Rect(p.x - num * 0.5f, p.y - num * 0.5f, num, num), r.Icon);
			}
			else
			{
				HubUI.Dot(p, 10f, HubUI.Gold);
			}
			if (r.Stars > 0)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(p.x + num * 0.38f, p.y - num * 0.38f);
				HubUI.Dot(val, 10f, Color.black);
				HubUI.Dot(val, 7f, r.StarColor);
			}
			if (r.Count > 1)
			{
				GUI.Label(new Rect(p.x, p.y + num * 0.1f, num, 16f), "x" + r.Count, _mapLabel);
			}
			GUI.color = color;
		}

		private static string RadarName(MapRadarBridge.Info r)
		{
			string text = r.Display ?? "";
			if (r.Stars > 0)
			{
				text += $" [{r.Stars}*]";
			}
			if (r.Count > 1)
			{
				text += $" x{r.Count}";
			}
			return text;
		}

		private void DrawPlayers(Rect map)
		{
			//IL_010a: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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)
			//IL_0153: 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_004a: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			string text = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetPlayerName() : null);
			if ((Object)(object)ZNet.instance != (Object)null)
			{
				foreach (PlayerInfo player in ZNet.instance.GetPlayerList())
				{
					if (player.m_publicPosition && !(player.m_name == text))
					{
						Vector2 val = W2L(map, player.m_position);
						HubUI.Dot(val, 16f, Color.white);
						HubUI.Dot(val, 12f, Color32.op_Implicit(new Color32((byte)80, (byte)150, (byte)240, byte.MaxValue)));
						DrawMapLabel(val + new Vector2(0f, 9f), player.m_name);
					}
				}
			}
			if ((Object)(object)localPlayer != (Object)null)
			{
				Vector2 val2 = W2L(map, ((Component)localPlayer).transform.position);
				HubUI.Dot(val2, 20f, Color.white);
				HubUI.Dot(val2, 15f, HubUI.GoldBright);
				DrawMapLabel(val2 + new Vector2(0f, 11f), L.T("you"));
			}
		}

		private void DrawZoomButtons(Rect map)
		{
			//IL_0057: 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_0067: 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_008a: 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)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref map)).x + 10f, ((Rect)(ref map)).y + 10f, 34f, 34f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref map)).x + 10f, ((Rect)(ref map)).y + 50f, 34f, 34f);
			if (HubUI.Button(val, "+"))
			{
				ZoomAround(map, ((Rect)(ref map)).center, 1.5f);
			}
			if (HubUI.Button(val2, "-"))
			{
				ZoomAround(map, ((Rect)(ref map)).center, 2f / 3f);
			}
		}

		private Rect LegendRect(Rect map)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = MapRenderer.LegendBiomes.Length * 20 + 20 + 16;
			return new Rect(((Rect)(ref map)).x + 10f, ((Rect)(ref map)).yMax - num - 10f, 190f, num);
		}

		private unsafe void DrawLegend(Rect map)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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)
			Rect val = LegendRect(map);
			HubUI.Slot(val, false, false);
			float num = ((Rect)(ref val)).y + 8f;
			Biome[] legendBiomes = MapRenderer.LegendBiomes;
			for (int i = 0; i < legendBiomes.Length; i++)
			{
				Biome b = legendBiomes[i];
				Color color = GUI.color;
				GUI.color = MapRenderer.BiomeColor(b);
				GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 12f, num + 4f, 14f, 12f), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = color;
				GUI.Label(new Rect(((Rect)(ref val)).x + 34f, num, ((Rect)(ref val)).width - 40f, 20f), L.T("biome_" + ((object)(*(Biome*)(&b))/*cast due to .constrained prefix*/).ToString()), _smallDim);
				num += 20f;
			}
			Color color2 = GUI.color;
			GUI.color = MapRenderer.ShallowColor;
			GUI.DrawTexture(new Rect(((Rect)(ref val)).x + 12f, num + 4f, 14f, 12f), (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color2;
			GUI.Label(new Rect(((Rect)(ref val)).x + 34f, num, ((Rect)(ref val)).width - 40f, 20f), L.T("biome_Shallows"), _smallDim);
		}

		private Rect SelectedRect(Rect map)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref map)).xMax - 330f, ((Rect)(ref map)).y + 10f, 320f, 170f);
		}

		private void DrawSelected(Rect map)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			Rect val = SelectedRect(map);
			HubUI.Slot(val, false, true);
			Loc selected = _selected;
			float num = ((Rect)(ref val)).y + 10f;
			HubUI.Header(new Rect(((Rect)(ref val)).x + 14f, num, ((Rect)(ref val)).width - 50f, 28f), selected.Type.Name);
			if (GUI.Button(new Rect(((Rect)(ref val)).xMax - 36f, num, 26f, 26f), "x", HubUI.ButtonStyle))
			{
				_selected = null;
				return;
			}
			num += 30f;
			HubUI.LabelDim(new Rect(((Rect)(ref val)).x + 14f, num, ((Rect)(ref val)).width - 28f, 22f), Catalog.CategoryName(selected.Type.Category));
			num += 22f;
			HubUI.Label(new Rect(((Rect)(ref val)).x + 14f, num, ((Rect)(ref val)).width - 28f, 22f), $"X: {selected.Pos.x:0}   Z: {selected.Pos.z:0}");
			num += 24f;
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				float num2 = Vector3.Distance(Flat(((Component)Player.m_localPlayer).transform.position), Flat(selected.Pos));
				HubUI.LabelDim(new Rect(((Rect)(ref val)).x + 14f, num, ((Rect)(ref val)).width - 28f, 22f), L.F("distance", Mathf.RoundToInt(num2)));
			}
			num += 30f;
			float num3 = (((Rect)(ref val)).width - 38f) * 0.5f;
			if (HubUI.Button(new Rect(((Rect)(ref val)).x + 14f, num, num3, 32f), L.T("put_pin")))
			{
				AddGamePin(selected.Pos, selected.Type.Name);
			}
			if (HubUI.Button(new Rect(((Rect)(ref val)).x + 24f + num3, num, num3, 32f), L.T("center")))
			{
				_cx = selected.Pos.x;
				_cz = selected.Pos.z;
			}
		}

		private void DrawTooltip(Rect map, Loc l, Vector2 mouse)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00b8: 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)
			//IL_00e1: 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_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			string text = $"X: {l.Pos.x:0}   Z: {l.Pos.z:0}";
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				text = text + "   ·   " + L.F("distance", Mathf.RoundToInt(Vector3.Distance(Flat(((Component)Player.m_localPlayer).transform.position), Flat(l.Pos))));
			}
			float num = Mathf.Max(220f, Mathf.Max(HubUI.HeaderStyle.CalcSize(new GUIContent(l.Type.Name)).x, _smallDim.CalcSize(new GUIContent(text)).x) + 28f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(mouse.x + 18f, mouse.y + 14f, num, 58f);
			if (((Rect)(ref val)).xMax > ((Rect)(ref map)).xMax)
			{
				((Rect)(ref val)).x = mouse.x - 18f - ((Rect)(ref val)).width;
			}
			if (((Rect)(ref val)).yMax > ((Rect)(ref map)).yMax)
			{
				((Rect)(ref val)).y = mouse.y - 14f - ((Rect)(ref val)).height;
			}
			HubUI.Slot(val, false, false);
			GUI.Label(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 6f, ((Rect)(ref val)).width - 20f, 26f), l.Type.Name, HubUI.HeaderStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 32f, ((Rect)(ref val)).width - 20f, 20f), text, _smallDim);
		}

		private void DrawToast(Rect map)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			if (!string.IsNullOrEmpty(_toast) && !(Time.unscaledTime > _toastUntil))
			{
				float num = Mathf.Min(((Rect)(ref map)).width - 40f, HubUI.LabelStyle.CalcSize(new GUIContent(_toast)).x + 40f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((Rect)(ref map)).center.x - num * 0.5f, ((Rect)(ref map)).yMax - 60f, num, 40f);
				HubUI.Slot(val, false, true);
				GUI.Label(val, _toast, HubUI.TileLabelStyle);
			}
		}

		private void DrawStatus(Rect r, Rect map)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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)
			string text = L.T("map_hint_new");
			Vector2 mousePosition = Event.current.mousePosition;
			if (((Rect)(ref map)).Contains(mousePosition))
			{
				Vector3 val = S2W(map, mousePosition);
				string arg = "";
				if (WorldGenerator.instance != null)
				{
					Vector2 val2 = new Vector2(val.x, val.z);
					if (((Vector2)(ref val2)).magnitude < 10500f)
					{
						arg = "   ·   " + L.T("biome_" + ((object)WorldGenerator.instance.GetBiome(val.x, val.z, 0.02f, false)/*cast due to .constrained prefix*/).ToString());
					}
				}
				text = $"X: {val.x:0}   Z: {val.z:0}{arg}";
			}
			GUI.Label(r, text, _smallDim);
		}

		private void HandleMapInput(Rect map)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected I4, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_005e: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 12)
			{
				return;
			}
			Vector2 mousePosition = current.mousePosition;
			int num;
			if (((Rect)(ref map)).Contains(mousePosition))
			{
				Rect val = LegendRect(map);
				if (!((Rect)(ref val)).Contains(mousePosition) && (!_pinDialog || !((Rect)(ref _pinDialogRect)).Contains(mousePosition)))
				{
					if (_selected != null)
					{
						val = SelectedRect(map);
						if (((Rect)(ref val)).Contains(mousePosition))
						{
							goto IL_00a7;
						}
					}
					val = new Rect(((Rect)(ref map)).x + 10f, ((Rect)(ref map)).y + 10f, 34f, 74f);
					num = ((!((Rect)(ref val)).Contains(mousePosition)) ? 1 : 0);
					goto IL_00a8;
				}
			}
			goto IL_00a7;
			IL_00a8:
			bool flag = (byte)num != 0;
			EventType type = current.type;
			EventType val2 = type;
			Vector2 val3;
			switch ((int)val2)
			{
			case 6:
				if (flag)
				{
					ZoomAround(map, mousePosition, (current.delta.y > 0f) ? 0.8f : 1.25f);
					current.Use();
				}
				break;
			case 0:
				if (flag && current.button == 0)
				{
					_dragging = true;
					val3 = (_dragStart = (_dragLast = mousePosition));
					GUIUtility.keyboardControl = 0;
					current.Use();
				}
				else if (flag && current.button == 1)
				{
					OnRightClick(map, mousePosition);
					current.Use();
				}
				break;
			case 3:
				if (_dragging)
				{
					Vector2 val4 = mousePosition - _dragLast;
					_dragLast = mousePosition;
					_cx -= val4.x / _zoom;
					_cz += val4.y / _zoom;
					ClampView(map);
					current.Use();
				}
				break;
			case 1:
				if (current.button != 0 || !_dragging)
				{
					break;
				}
				_dragging = false;
				val3 = mousePosition - _dragStart;
				if (((Vector2)(ref val3)).sqrMagnitude < 25f)
				{
					if (_pinDialog)
					{
						_pinDialog = false;
					}
					else if (_hoveredPin != null && IsOwnPin(_hoveredPin))
					{
						_hoveredPin.m_checked = !_hoveredPin.m_checked;
					}
					else
					{
						_selected = _hovered;
					}
				}
				current.Use();
				break;
			case 2:
			case 4:
			case 5:
				break;
			}
			return;
			IL_00a7:
			num = 0;
			goto IL_00a8;
		}

		private void ZoomAround(Rect map, Vector2 screenPoint, float factor)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_005c: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = S2W(map, screenPoint);
			float num = FitZoom(map);
			_zoom = Mathf.Clamp(_zoom * factor, num * 0.7f, num * 80f);
			Vector3 val2 = S2W(map, screenPoint);
			_cx += val.x - val2.x;
			_cz += val.z - val2.z;
			ClampView(map);
		}

		private void ClampView(Rect map)
		{
			float num = 10500f;
			_cx = Mathf.Clamp(_cx, 0f - num, num);
			_cz = Mathf.Clamp(_cz, 0f - num, num);
		}

		private void CenterOnPlayer()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				_cx = ((Component)localPlayer).transform.position.x;
				_cz = ((Component)localPlayer).transform.position.z;
				_zoom = Mathf.Max(_zoom, 0.12f);
			}
		}

		private void JumpToNearest(LocType t)
		{
			//IL_001f: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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)
			Vector3 v = (((Object)(object)Player.m_localPlayer != (Object)null) ? ((Component)Player.m_localPlayer).transform.position : Vector3.zero);
			Loc loc = null;
			float num = float.MaxValue;
			foreach (Loc item in LocationStore.All)
			{
				if (item.Type == t && (!Plugin.OnlyExplored.Value || item.Explored))
				{
					Vector3 val = Flat(item.Pos) - Flat(v);
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						loc = item;
					}
				}
			}
			if (loc == null)
			{
				Toast(L.T("nothing_here"));
				return;
			}
			if (Plugin.IsTypeHidden(t.Key))
			{
				Plugin.SetTypeHidden(t.Key, hidden: false);
				GamePins.ForceRefresh();
			}
			_selected = loc;
			_cx = loc.Pos.x;
			_cz = loc.Pos.z;
			_zoom = Mathf.Max(_zoom, 0.08f);
			Toast(L.F("nearest", L.F("distance", Mathf.RoundToInt(Mathf.Sqrt(num)))));
		}

		private void AddGamePin(Vector3 pos, string name)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_007f: 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)
			Minimap instance = Minimap.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				float y = default(float);
				if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(pos, ref y))
				{
					pos.y = y;
				}
				instance.AddPin(pos, (PinType)3, name ?? "", true, false, 0L, default(PlatformUserID));
				Toast(L.F("pin_added", string.IsNullOrEmpty(name) ? $"{pos.x:0}, {pos.z:0}" : name));
			}
		}

		private void OnRightClick(Rect map, Vector2 m)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			if (_hoveredPin != null)
			{
				if (IsOwnPin(_hoveredPin))
				{
					Minimap instance = Minimap.instance;
					if (instance != null)
					{
						instance.RemovePin(_hoveredPin);
					}
					Toast(L.T("pin_removed"));
					_hoveredPin = null;
					return;
				}
				MapRadarBridge.Info info = MapRadarBridge.Get(_hoveredPin);
				if (info != null)
				{
					if (MapRadarBridge.ToggleHidden(info, out var nowHidden))
					{
						Toast(L.T(nowHidden ? "radar_hidden" : "radar_unhidden"));
					}
					return;
				}
				if (WorldAtlasAPI.RaisePinRightClick(_hoveredPin))
				{
					return;
				}
			}
			if (Plugin.RightClickPin.Value)
			{
				Vector3 pos = ((_hovered != null) ? _hovered.Pos : S2W(map, m));
				OpenPinDialog(map, m, pos, (_hovered != null) ? _hovered.Type.Name : "");
			}
		}

		private void OpenPinDialog(Rect map, Vector2 screen, Vector3 pos, string name)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			_pinDialog = true;
			_pinDialogFocus = true;
			_pinPos = pos;
			_pinName = name ?? "";
			_pinDialogRect = new Rect(screen.x + 12f, screen.y + 12f, 340f, 170f);
			if (((Rect)(ref _pinDialogRect)).xMax > ((Rect)(ref map)).xMax)
			{
				((Rect)(ref _pinDialogRect)).x = screen.x - 12f - ((Rect)(ref _pinDialogRect)).width;
			}
			if (((Rect)(ref _pinDialogRect)).yMax > ((Rect)(ref map)).yMax)
			{
				((Rect)(ref _pinDialogRect)).y = screen.y - 12f - ((Rect)(ref _pinDialogRect)).height;
			}
		}

		private void DrawPinDialog(Rect map)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 4 && ((int)current.keyCode == 13 || (int)current.keyCode == 271))
			{
				ConfirmPin();
				current.Use();
				return;
			}
			Rect pinDialogRect = _pinDialogRect;
			HubUI.Slot(pinDialogRect, false, true);
			HubUI.Header(new Rect(((Rect)(ref pinDialogRect)).x + 14f, ((Rect)(ref pinDialogRect)).y + 8f, ((Rect)(ref pinDialogRect)).width - 28f, 28f), L.T("new_pin"));
			GUI.SetNextControlName("wa_pin_name");
			_pinName = HubUI.TextField(new Rect(((Rect)(ref pinDialogRect)).x + 14f, ((Rect)(ref pinDialogRect)).y + 42f, ((Rect)(ref pinDialogRect)).width - 28f, 32f), _pinName);
			if (_pinDialogFocus)
			{
				GUI.FocusControl("wa_pin_name");
				_pinDialogFocus = false;
			}
			if (_pinSprites == null)
			{
				_pinSprites = LoadPinSprites();
			}
			float num = ((Rect)(ref pinDialogRect)).x + 14f;
			Rect val = default(Rect);
			for (int i = 0; i < PinTypes.Length; i++)
			{
				((Rect)(ref val))..ctor(num + (float)(i * 46), ((Rect)(ref pinDialogRect)).y + 84f, 40f, 40f);
				bool flag = _pinIcon == i;
				HubUI.Slot(val, ((Rect)(ref val)).Contains(current.mousePosition), flag);
				if ((Object)(object)_pinSprites[i] != (Object)null)
				{
					HubUI.DrawSprite(new Rect(((Rect)(ref val)).x + 6f, ((Rect)(ref val)).y + 6f, 28f, 28f), _pinSprites[i]);
				}
				else
				{
					GUI.Label(val, i.ToString(), HubUI.TileLabelStyle);
				}
				if (GUI.Button(val, GUIContent.none, GUIStyle.none))
				{
					_pinIcon = i;
				}
			}
			if (HubUI.Button(new Rect(((Rect)(ref pinDialogRect)).xMax - 104f, ((Rect)(ref pinDialogRect)).y + 84f, 90f, 40f), L.T("ok")))
			{
				ConfirmPin();
			}
			HubUI.LabelDim(new Rect(((Rect)(ref pinDialogRect)).x + 14f, ((Rect)(ref pinDialogRect)).y + 130f, ((Rect)(ref pinDialogRect)).width - 28f, 30f), $"X: {_pinPos.x:0}   Z: {_pinPos.z:0}");
		}

		private void ConfirmPin()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0089: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			_pinDialog = false;
			GUIUtility.keyboardControl = 0;
			Minimap instance = Minimap.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				Vector3 pinPos = _pinPos;
				float y = default(float);
				if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(pinPos, ref y))
				{
					pinPos.y = y;
				}
				instance.AddPin(pinPos, PinTypes[Mathf.Clamp(_pinIcon, 0, PinTypes.Length - 1)], _pinName ?? "", true, false, 0L, default(PlatformUserID));
				Toast(L.F("pin_added", string.IsNullOrEmpty(_pinName) ? $"{pinPos.x:0}, {pinPos.z:0}" : _pinName));
			}
		}

		private static Sprite[] LoadPinSprites()
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			Sprite[] array = (Sprite[])(object)new Sprite[PinTypes.Length];
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return array;
			}
			try
			{
				if (AccessTools.Field(typeof(Minimap), "m_icons")?.GetValue(instance) is IList list)
				{
					foreach (object item in list)
					{
						if (item == null)
						{
							continue;
						}
						Type type = item.GetType();
						object obj = AccessTools.Field(type, "m_name")?.GetValue(item);
						object? obj2 = AccessTools.Field(type, "m_icon")?.GetValue(item);
						Sprite val = (Sprite)((obj2 is Sprite) ? obj2 : null);
						if (obj != null && !((Object)(object)val == (Object)null))
						{
							int num = Array.IndexOf(PinTypes, (PinType)obj);
							if (num >= 0)
							{
								array[num] = val;
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Pin icons: " + ex.Message);
			}
			return array;
		}

		private void DrawPinTooltip(Rect map, PinData pin, Vector2 mouse)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			MapRadarBridge.Info info = (IsOwnPin(pin) ? null : MapRadarBridge.Get(pin));
			string text = ((info != null) ? RadarName(info) : pin.m_name);
			if (info != null && !info.IsMob)
			{
				text += (info.Hidden ? ("   ·   " + L.T("radar_rmb_show")) : ("   ·   " + L.T("radar_rmb_hide")));
			}
			if (!string.IsNullOrEmpty(text))
			{
				float num = Mathf.Max(160f, HubUI.LabelStyle.CalcSize(new GUIContent(text)).x + 28f);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(mouse.x + 18f, mouse.y + 14f, num, 34f);
				if (((Rect)(ref val)).xMax > ((Rect)(ref map)).xMax)
				{
					((Rect)(ref val)).x = mouse.x - 18f - ((Rect)(ref val)).width;
				}
				if (((Rect)(ref val)).yMax > ((Rect)(ref map)).yMax)
				{
					((Rect)(ref val)).y = mouse.y - 14f - ((Rect)(ref val)).height;
				}
				HubUI.Slot(val, false, false);
				GUI.Label(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y, ((Rect)(ref val)).width - 20f, ((Rect)(ref val)).height), text, HubUI.NoWrap(HubUI.LabelStyle));
			}
		}

		private static string ModPinsLabel()
		{
			return WorldAtlasAPI.MapRadarInstalled ? L.T("radar_pins") : L.T("mod_pins");
		}

		private static bool SafeGet(Func<bool> f)
		{
			try
			{
				return f?.Invoke() ?? false;
			}
			catch
			{
				return false;
			}
		}

		private static string SafeLabel(Func<string> f)
		{
			try
			{
				return f?.Invoke() ?? "";
			}
			catch
			{
				return "";
			}
		}

		private void Toast(string msg)
		{
			_toast = msg;
			_toastUntil = Time.unscaledTime + 2.5f;
		}

		private void RefreshFog()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			_fogDirty = false;
			_nextFog = Time.unscaledTime + 3f;
			foreach (Loc item in LocationStore.All)
			{
				item.Explored = MapRenderer.IsExplored(item.Pos);
			}
			if (Plugin.DimUnexplored.Value)
			{
				MapRenderer.RebuildFog();
			}
		}

		private static Vector3 Flat(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(v.x, 0f, v.z);
		}

		static AtlasWindow()
		{
			PinType[] array = new PinType[5];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			PinTypes = (PinType[])(object)array;
		}
	}
	internal static class CrossStore
	{
		private static readonly HashSet<string> _crossed = new HashSet<string>();

		private static string _loadedFor;

		public static int Version;

		public static int Count => _crossed.Count;

		public static IEnumerable<string> All => _crossed;

		public static void Clear()
		{
			_crossed.Clear();
			_loadedFor = null;
			Version++;
		}

		public static void ApplyTo(List<Loc> all)
		{
			EnsureLoaded();
			foreach (Loc item in all)
			{
				item.Crossed = _crossed.Contains(item.FoundKey);
			}
		}

		public static List<KeyValuePair<string, bool>> Apply(List<KeyValuePair<string, bool>> changes, bool full)
		{
			EnsureLoaded();
			List<KeyValuePair<string, bool>> list = new List<KeyValuePair<string, bool>>();
			if (full)
			{
				HashSet<string> hashSet = new HashSet<string>();
				foreach (KeyValuePair<string, bool> change in changes)
				{
					if (change.Value && !string.IsNullOrEmpty(change.Key))
					{
						hashSet.Add(change.Key);
					}
				}
				if (hashSet.SetEquals(_crossed))
				{
					return list;
				}
				_crossed.Clear();
				foreach (string item in hashSet)
				{
					_crossed.Add(item);
				}
				list.AddRange(changes);
			}
			else
			{
				foreach (KeyValuePair<string, bool> change2 in changes)
				{
					if (!string.IsNullOrEmpty(change2.Key) && (change2.Value ? _crossed.Add(change2.Key) : _crossed.Remove(change2.Key)))
					{
						list.Add(change2);
					}
				}
				if (list.Count == 0)
				{
					return list;
				}
			}
			foreach (Loc item2 in LocationStore.All)
			{
				item2.Crossed = _crossed.Contains(item2.FoundKey);
			}
			Version++;
			Save();
			if (Plugin.HideCrossed.Value)
			{
				GamePins.ForceRefresh();
			}
			return list;
		}

		public static void Toggle(Loc loc)
		{
			if (loc != null && !string.IsNullOrEmpty(loc.FoundKey))
			{
				List<KeyValuePair<string, bool>> changes = new List<KeyValuePair<string, bool>>
				{
					new KeyValuePair<string, bool>(loc.FoundKey, !loc.Crossed)
				};
				List<KeyValuePair<string, bool>> list = Apply(changes, full: false);
				if (list.Count > 0 && Plugin.ShareCrossed.Value)
				{
					AtlasNet.SendCrossed(list);
				}
			}
		}

		private static string FileFor(string worldId)
		{
			return Path.Combine(Paths.ConfigPath, "WorldAtlas", "crossed", worldId + ".txt");
		}

		private static void EnsureLoaded()
		{
			string text = MapRenderer.WorldFileId();
			if (text == null || text == _loadedFor)
			{
				return;
			}
			_loadedFor = text;
			_crossed.Clear();
			try
			{
				string path = FileFor(text);
				if (File.Exists(path))
				{
					string[] array = File.ReadAllLines(path);
					foreach (string text2 in array)
					{
						string text3 = text2.Trim();
						if (text3.Length > 0)
						{
							_crossed.Add(text3);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Crossed list read: " + ex.Message);
			}
			Version++;
		}

		private static void Save()
		{
			if (_loadedFor == null)
			{
				return;
			}
			try
			{
				string path = FileFor(_loadedFor);
				Directory.CreateDirectory(Path.GetDirectoryName(path));
				File.WriteAllLines(path, new List<string>(_crossed).ToArray());
			}
			catch (Exception ex)
			{
				Plugin.LogError("Crossed list write: " + ex.Message);
			}
		}
	}
	internal static class FoundStore
	{
		private static readonly HashSet<string> _found = new HashSet<string>();

		private static string _loadedFor;

		private static float _nextScan;

		public static int Version;

		public static int Count => _found.Count;

		public static IEnumerable<string> All => _found;

		public static void Clear()
		{
			_found.Clear();
			_loadedFor = null;
			Version++;
		}

		public static bool Has(string key)
		{
			return key != null && _found.Contains(key);
		}

		public static void ApplyTo(List<Loc> all)
		{
			EnsureLoaded();
			foreach (Loc item in all)
			{
				item.Found = _found.Contains(item.FoundKey);
			}
		}

		public static List<string> AddMany(IEnumerable<string> keys)
		{
			EnsureLoaded();
			List<string> list = new List<string>();
			foreach (string key in keys)
			{
				if (!string.IsNullOrEmpty(key) && _found.Add(key))
				{
					list.Add(key);
				}
			}
			if (list.Count == 0)
			{
				return list;
			}
			HashSet<string> hashSet = new HashSet<string>(list);
			foreach (Loc item in LocationStore.All)
			{
				if (!item.Found && hashSet.Contains(item.FoundKey))
				{
					item.Found = true;
				}
			}
			Version++;
			Save();
			GamePins.ForceRefresh();
			return list;
		}

		public static void Tick()
		{
			//IL_0063: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time < _nextScan || LocationStore.Status != LocationStore.State.Ready)
			{
				return;
			}
			_nextScan = Time.time + 1f;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			float value = Plugin.FoundRadius.Value;
			float num = value * value;
			Vector3 position = ((Component)localPlayer).transform.position;
			List<string> list = null;
			foreach (Loc item in LocationStore.All)
			{
				if (!item.Found)
				{
					float num2 = item.Pos.x - position.x;
					float num3 = item.Pos.z - position.z;
					if (!(num2 * num2 + num3 * num3 > num))
					{
						(list ?? (list = new List<string>())).Add(item.FoundKey);
					}
				}
			}
			if (list != null)
			{
				List<string> list2 = AddMany(list);
				if (list2.Count > 0 && Plugin.ShareFound.Value)
				{
					AtlasNet.SendFound(list2);
				}
			}
		}

		private static string FileFor(string worldId)
		{
			return Path.Combine(Paths.ConfigPath, "WorldAtlas", "found", worldId + ".txt");
		}

		private static void EnsureLoaded()
		{
			string text = MapRenderer.WorldFileId();
			if (text == null || text == _loadedFor)
			{
				return;
			}
			_loadedFor = text;
			_found.Clear();
			try
			{
				string path = FileFor(text);
				if (File.Exists(path))
				{
					string[] array = File.ReadAllLines(path);
					foreach (string text2 in array)
					{
						string text3 = text2.Trim();
						if (text3.Length > 0)
						{
							_found.Add(text3);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.LogError("Found list read: " + ex.Message);
			}
			Version++;
		}

		private static void Save()
		{
			if (_loadedFor == null)
			{
				return;
			}
			try
			{
				string path = FileFor(_loadedFor);
				Directory.CreateDirectory(Path.GetDirectoryName(path));
				File.WriteAllLines(path, new List<string>(_found).ToArray());
			}
			catch (Exception ex)
			{
				Plugin.LogError("Found list write: " + ex.Message);
			}
		}
	}
	internal static class GamePins
	{
		private static readonly List<PinData> _pins = new List<PinData>();

		private static readonly HashSet<PinData> _set = new HashSet<PinData>();

		private static readonly Dictionary<PinData, Loc> _locOf = new Dictionary<PinData, Loc>();

		private static readonly Dictionary<PinData, Sprite> _spriteOf = new Dictionary<PinData, Sprite>();

		private static bool _removing;

		private static Minimap _owner;