Decompiled source of PortalCompass v1.0.1

plugins/PortalCompass/PortalCompass.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PortalCompass")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+efce6ca149abb40a476f837e07392cbdd39daa02")]
[assembly: AssemblyProduct("PortalCompass")]
[assembly: AssemblyTitle("PortalCompass")]
[assembly: AssemblyVersion("1.0.0.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 Finn.PortalCompass
{
	[BepInPlugin("com.joostliebregts.portalpicker", "Portal Compass", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("valheim.exe")]
	public sealed class Plugin : BaseUnityPlugin
	{
		private sealed class Entry
		{
			public int Index;

			public string Key;

			public string Name;

			public float Meters;

			public Vector3 Pos;
		}

		private sealed class Nav
		{
			public Entry Entry;

			public Image Back;

			public GameObject Bar;

			public Color Normal;

			public int Row;

			public float Col = 0.5f;
		}

		private sealed class XpPortal
		{
			private static PropertyInfo pLocation;

			private static PropertyInfo pTarget;

			private static MethodInfo mFriendly;

			private static MethodInfo mHasTarget;

			private readonly object o;

			public Vector3 Location => (Vector3)pLocation.GetValue(o);

			public ZDOID Target => (ZDOID)pTarget.GetValue(o);

			private XpPortal(object o)
			{
				this.o = o;
				if (!(pLocation != null))
				{
					Type type = o.GetType();
					pLocation = AccessTools.Property(type, "Location");
					pTarget = AccessTools.Property(type, "Target");
					mFriendly = AccessTools.Method(type, "GetFriendlyName", (Type[])null, (Type[])null);
					mHasTarget = AccessTools.Method(type, "HasTarget", (Type[])null, (Type[])null);
				}
			}

			public static XpPortal Of(object o)
			{
				if (o != null)
				{
					return new XpPortal(o);
				}
				return null;
			}

			public string GetFriendlyName()
			{
				return (string)mFriendly.Invoke(o, null);
			}

			public bool HasTarget()
			{
				return (bool)mHasTarget.Invoke(o, null);
			}
		}

		private sealed class MapView : MonoBehaviour, IScrollHandler, IEventSystemHandler, IDragHandler, IPointerEnterHandler, IPointerExitHandler
		{
			public Plugin Owner;

			public bool Hovered;

			private RectTransform Rt => (RectTransform)((Component)this).transform;

			public void OnPointerEnter(PointerEventData e)
			{
				Hovered = true;
			}

			public void OnPointerExit(PointerEventData e)
			{
				Hovered = false;
			}

			private void OnDisable()
			{
				Hovered = false;
			}

			public void OnScroll(PointerEventData e)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: 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_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				if (e.scrollDelta.y != 0f)
				{
					Vector2 val = default(Vector2);
					RectTransformUtility.ScreenPointToLocalPointInRectangle(Rt, e.position, e.enterEventCamera, ref val);
					Rect rect = Rt.rect;
					Owner.ZoomMap(Mathf.Sign(e.scrollDelta.y), new Vector2((val.x - ((Rect)(ref rect)).xMin) / ((Rect)(ref rect)).width, (val.y - ((Rect)(ref rect)).yMin) / ((Rect)(ref rect)).height));
				}
			}

			public void OnDrag(PointerEventData e)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_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_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle(Rt, e.position, e.pressEventCamera, ref val);
				Vector2 val2 = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle(Rt, e.position - e.delta, e.pressEventCamera, ref val2);
				Rect rect = Rt.rect;
				Owner.PanMap(new Vector2((val.x - val2.x) / ((Rect)(ref rect)).width, (val.y - val2.y) / ((Rect)(ref rect)).height));
			}
		}

		private sealed class RailScrub : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IDragHandler, IPointerMoveHandler, IPointerExitHandler
		{
			public Plugin Owner;

			public void OnPointerDown(PointerEventData e)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				string text = Owner.RailLetterAt(e.position);
				if (text != null)
				{
					Owner.ScrollToLetter(text);
				}
			}

			public void OnDrag(PointerEventData e)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				string text = Owner.RailLetterAt(e.position);
				Owner.RailHover(text);
				if (text != null)
				{
					Owner.ScrollToLetter(text);
				}
			}

			public void OnPointerMove(PointerEventData e)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				Owner.RailHover(Owner.RailLetterAt(e.position));
			}

			public void OnPointerExit(PointerEventData e)
			{
				Owner.RailHover(null);
			}

			private void OnDisable()
			{
				Owner?.RailHover(null);
			}
		}

		private sealed class RightClick : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
		{
			public Action<Vector2> OnRight;

			public Action OnDouble;

			public void OnPointerClick(PointerEventData e)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				if ((int)e.button == 1)
				{
					OnRight?.Invoke(e.position);
				}
				else if ((int)e.button == 0 && e.clickCount == 2)
				{
					OnDouble?.Invoke();
				}
			}
		}

		private sealed class SearchClicks : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
		{
			public Plugin Owner;

			private int selectAllIn = -1;

			public void OnPointerClick(PointerEventData e)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				if ((int)e.button == 1)
				{
					Owner.ClearSearch();
				}
				else if ((int)e.button == 0 && e.clickCount >= 2)
				{
					selectAllIn = 1;
				}
			}

			private void LateUpdate()
			{
				if (selectAllIn >= 0 && selectAllIn-- <= 0)
				{
					InputField search = Owner.search;
					search.selectionAnchorPosition = 0;
					search.selectionFocusPosition = search.text.Length;
					search.ForceLabelUpdate();
					Owner.caretEnd = false;
				}
			}
		}

		private sealed class Hover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
		{
			public Action Show;

			public Action Hide;

			public void OnPointerEnter(PointerEventData e)
			{
				Show?.Invoke();
			}

			public void OnPointerExit(PointerEventData e)
			{
				Hide?.Invoke();
			}

			private void OnDisable()
			{
				Hide?.Invoke();
			}
		}

		private static class Store
		{
			[Serializable]
			public sealed class Used
			{
				public string k = "";

				public long t;
			}

			[Serializable]
			public sealed class Entry
			{
				public string key = "";

				public List<string> pinned = new List<string>();

				public List<Used> used = new List<Used>();
			}

			[Serializable]
			public sealed class File
			{
				public int version = 2;

				public string lastTab = "quick";

				public float mapZoom;

				public List<Entry> entries = new List<Entry>();
			}

			private static readonly string Path = System.IO.Path.Combine(Paths.ConfigPath, "com.joostliebregts.portalpicker.json");

			private static File data;

			public static File Data
			{
				get
				{
					Load();
					return data;
				}
			}

			public static Entry For(string key)
			{
				Load();
				Entry entry = data.entries.FirstOrDefault((Entry x) => x.key == key);
				if (entry == null)
				{
					entry = new Entry
					{
						key = key
					};
					data.entries.Add(entry);
				}
				return entry;
			}

			private static void Load()
			{
				if (data != null)
				{
					return;
				}
				try
				{
					data = (System.IO.File.Exists(Path) ? JsonConvert.DeserializeObject<File>(System.IO.File.ReadAllText(Path)) : null);
					if (data != null)
					{
						foreach (Entry entry2 in data.entries)
						{
							Entry current;
							Entry entry = (current = entry2);
							if (current.pinned == null)
							{
								current.pinned = new List<string>();
							}
							entry.pinned.RemoveAll((string k) => k == null || !k.Contains(","));
							current = entry;
							if (current.used == null)
							{
								current.used = new List<Used>();
							}
							entry.used.RemoveAll((Used u) => u == null || u.k == null || !u.k.Contains(","));
						}
					}
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)instance).Logger.LogWarning((object)("Could not read " + Path + ", starting empty (the old file is kept as .bak): " + ex.Message));
					try
					{
						System.IO.File.Copy(Path, Path + ".bak", overwrite: true);
					}
					catch
					{
					}
					data = null;
				}
				if (data == null)
				{
					data = new File();
				}
			}

			public static void Save()
			{
				try
				{
					string text = Path + ".tmp";
					System.IO.File.WriteAllText(text, JsonConvert.SerializeObject((object)data, (Formatting)1));
					if (System.IO.File.Exists(Path))
					{
						System.IO.File.Delete(Path);
					}
					System.IO.File.Move(text, Path);
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)instance).Logger.LogWarning((object)("Could not save " + Path + ": " + ex.Message));
				}
			}
		}

		public const string Id = "com.joostliebregts.portalpicker";

		public const string Version = "1.0.1";

		public const string XPortalGuid = "yay.spikehimself.xportal";

		private const float W = 980f;

		private const float H = 720f;

		private const float Pad = 20f;

		private const float ContentTop = 156f;

		private const float BottomBar = 72f;

		private const float RowH = 40f;

		private const float CompactH = 32f;

		private const float FontScale = 1.15f;

		private const int MaxPins = 6;

		private const int RecentTiles = 4;

		private const int UsedMax = 50;

		private static readonly Color Ink = Hex(15920093);

		private static readonly Color Dim = Hex(12563360);

		private static readonly Color Faint = Hex(10260863);

		private static readonly Color Orange = Hex(15770682);

		private static readonly Color PinOn = Hex(15770682);

		private static readonly Color PinOff = Hex(8024159);

		private static readonly Color Backdrop = Hex(1446671, 0.98f);

		private static readonly Color Box = Hex(1052171);

		private static readonly Color RowCol = Hex(2235671);

		private static readonly Color SelCol = Hex(3811860);

		private static readonly Color PinBox = Hex(1840914);

		private static readonly Color TileCol = Hex(3023896);

		private static readonly Color Field = Hex(2235671);

		private static readonly Color Border = Hex(4865841);

		private static readonly Color BtnCol = Hex(2761756);

		private static readonly Color TabOff = Hex(2038293);

		private static readonly Color DarkBtn = Hex(1446671);

		private static Sprite roundSprite;

		private static ConfigEntry<float> uiScale;

		private static ConfigEntry<int> scrollRows;

		private static Sprite pinSprite;

		private static Sprite dotSprite;

		private static Sprite ringSprite;

		private readonly List<(string l, Text t)> railLetters = new List<(string, Text)>();

		private string railHover;

		private RectTransform mapArea;

		private RectTransform mapListContent;

		private RectTransform mapListViewport;

		private RectTransform mapFrame;

		private RectTransform dotLayer;

		private RawImage mapImage;

		private Material mapMat;

		private MapView mapView;

		private GameObject mapOff;

		private GameObject mapLabel;

		private Text mapLabelText;

		private readonly List<(Entry e, RectTransform rt, Image img)> dots = new List<(Entry, RectTransform, Image)>();

		private readonly HashSet<Entry> unexplored = new HashSet<Entry>();

		private RectTransform hereDot;

		private Vector2 mapCenter;

		private float mapZoom = 0.1f;

		private bool mapFitted;

		private bool mapJustFitted;

		private bool mapZoomDirty;

		private const float DefaultZoom = 0.12f;

		private RectTransform selRing;

		private RectTransform hoverRing;

		private CanvasGroup youTag;

		private GameObject ctxMenu;

		private GameObject ctxBlocker;

		private Image pinButtonIcon;

		private readonly List<(RectTransform rt, CanvasGroup tag, Text text)> playerDots = new List<(RectTransform, CanvasGroup, Text)>();

		private readonly List<PlayerInfo> tmpPlayers = new List<PlayerInfo>();

		private float playerRefresh;

		private static readonly Color FriendBlue = Hex(10474495);

		private readonly List<CanvasGroup> nameTags = new List<CanvasGroup>();

		private const float TagsFrom = 0.08f;

		private const float TagsFull = 0.06f;

		private static readonly Color HoverGlow = Hex(16769955);

		private static MethodInfo mIsExplored;

		private const float MinZoom = 0.01f;

		private static Plugin instance;

		private static FieldInfo fMainPanel;

		private static FieldInfo fDropdown;

		private static FieldInfo fMapping;

		private static FieldInfo fThisPortal;

		private static FieldInfo fNameInput;

		private static FieldInfo fDefaultToggle;

		private static FieldInfo fPingButton;

		private static object portalsManager;

		private static MethodInfo mGetById;

		private static PropertyInfo pPanelInstance;

		private int adoptChecks = 30;

		private static object xpConfig;

		private GameObject mainPanel;

		private Dropdown dropdown;

		private InputField xpName;

		private Toggle xpDefault;

		private Button xpOk;

		private Button xpCancel;

		private Button xpPing;

		private GameObject canvasGo;

		private GameObject builtFor;

		private CanvasScaler scaler;

		private Image mainImg;

		private bool hidMainImg;

		private readonly List<GameObject> xpWidgets = new List<GameObject>();

		private XpPortal thisPortal;

		private GameObject root;

		private Font font;

		private InputField search;

		private InputField nameField;

		private Text countLabel;

		private Text selName;

		private Text selInfo;

		private Text pinLabel;

		private Image defaultBox;

		private readonly List<(string id, Image img, Text t)> tabs = new List<(string, Image, Text)>();

		private RectTransform quickArea;

		private RectTransform listArea;

		private RectTransform listContent;

		private RectTransform listViewport;

		private RectTransform railArea;

		private ScrollRect listScroll;

		private GameObject chipsRow;

		private GameObject pingButton;

		private GameObject clearButton;

		private readonly List<(string id, Image img, Text t)> chips = new List<(string, Image, Text)>();

		private readonly List<Entry> entries = new List<Entry>();

		private readonly List<Nav> nav = new List<Nav>();

		private int sel = -1;

		private int focusIn = -1;

		private int navRow;

		private string tab = "quick";

		private string mode = "az";

		private string lastSearch = "";

		private bool defaultOn;

		private bool noDistance;

		private bool caretEnd;

		private Store.Entry store;

		private Entry beforeKey;

		private Harmony harmony;

		private float initWait;

		private float initRetry;

		private bool initDone;

		private static Sprite playerIcon;

		private static bool playerIconLooked;

		private static Sprite linkSprite;

		private static Sprite cancelSprite;

		private static Sprite pingSprite;

		private static bool pingLooked;

		private bool Active
		{
			get
			{
				if (Object.op_Implicit((Object)(object)root))
				{
					return root.activeInHierarchy;
				}
				return false;
			}
		}

		private Store.Entry S => store ?? (store = Store.For(StoreKey()));

		private IEnumerable<Entry> Portals => entries.Where((Entry e) => e.Key != "");

		private string Q
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)search))
				{
					return "";
				}
				return search.text.Trim();
			}
		}

		private float Aspect
		{
			get
			{
				//IL_0006: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				Rect rect = mapFrame.rect;
				if (!(((Rect)(ref rect)).height > 0f))
				{
					return 1.36f;
				}
				rect = mapFrame.rect;
				float width = ((Rect)(ref rect)).width;
				rect = mapFrame.rect;
				return width / ((Rect)(ref rect)).height;
			}
		}

		private bool ContextOpen => Object.op_Implicit((Object)(object)ctxMenu);

		private static Color Hex(int rgb, float a = 1f)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, a);
		}

		private void AdoptOpenPanel()
		{
			if (adoptChecks <= 0)
			{
				return;
			}
			adoptChecks--;
			try
			{
				object obj = pPanelInstance?.GetValue(null);
				GameObject val = (GameObject)((obj == null) ? null : /*isinst with value type is only supported in some contexts*/);
				if (Object.op_Implicit((Object)(object)val) && val.activeInHierarchy)
				{
					adoptChecks = 0;
					Open(obj);
				}
			}
			catch (Exception ex)
			{
				adoptChecks = 0;
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not take over the open panel: " + ex.Message));
			}
		}

		private void OnDestroy()
		{
			try
			{
				if (Active)
				{
					Close();
				}
			}
			catch
			{
			}
			try
			{
				Harmony obj2 = harmony;
				if (obj2 != null)
				{
					obj2.UnpatchSelf();
				}
			}
			catch
			{
			}
			if (Object.op_Implicit((Object)(object)canvasGo))
			{
				Object.Destroy((Object)(object)canvasGo);
			}
			if (Object.op_Implicit((Object)(object)mapMat))
			{
				Object.Destroy((Object)(object)mapMat);
			}
			if ((Object)(object)instance == (Object)(object)this)
			{
				instance = null;
			}
		}

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			instance = this;
			uiScale = ((BaseUnityPlugin)this).Config.Bind<float>("Panel", "Size", 1f, new ConfigDescription("Size of the portal panel. 1 = as big as Valheim's own menus at your resolution and GUI scale (the same on a 1080p and a 4K screen).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.6f, 1.6f), Array.Empty<object>()));
			scrollRows = ((BaseUnityPlugin)this).Config.Bind<int>("Panel", "Rows per scroll step", 4, new ConfigDescription("How many rows of the list one notch of the mouse wheel scrolls.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			if (!TryInit(final: false))
			{
				initWait = 120f;
			}
		}

		private bool TryInit(bool final)
		{
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Expected O, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Expected O, but got Unknown
			if (initDone)
			{
				return true;
			}
			if (!Chainloader.PluginInfos.TryGetValue("yay.spikehimself.xportal", out var value) || !Object.op_Implicit((Object)(object)value.Instance))
			{
				if (final)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"XPortal never started. Portal Compass stays off.");
				}
				return false;
			}
			Type type = AccessTools.TypeByName("XPortal.UI.PortalConfigurationPanel");
			Type type2 = AccessTools.TypeByName("XPortal.KnownPortalsManager");
			pPanelInstance = ((type == null) ? null : AccessTools.Property(type, "Instance"));
			MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "ConfigurePortal", (Type[])null, (Type[])null));
			MethodInfo methodInfo2 = ((type == null) ? null : AccessTools.Method(type, "HandleInput", (Type[])null, (Type[])null));
			fMainPanel = AccessTools.Field(type, "mainPanel");
			fDropdown = AccessTools.Field(type, "targetPortalDropdown");
			fMapping = AccessTools.Field(type, "dropdownIndexToZDOIDMapping");
			fThisPortal = AccessTools.Field(type, "thisPortal");
			fNameInput = AccessTools.Field(type, "portalNameInputField");
			fDefaultToggle = AccessTools.Field(type, "defaultPortalToggle");
			fPingButton = AccessTools.Field(type, "pingMapButtonObject");
			portalsManager = ((type2 == null) ? null : AccessTools.Property(type2, "Instance")?.GetValue(null));
			mGetById = ((type2 == null) ? null : AccessTools.Method(type2, "GetKnownPortalById", (Type[])null, (Type[])null));
			try
			{
				xpConfig = AccessTools.Property(AccessTools.TypeByName("XPortal.XPortalConfig"), "Instance")?.GetValue(null);
			}
			catch
			{
			}
			if (methodInfo == null || methodInfo2 == null || fMainPanel == null || fDropdown == null || fMapping == null || fThisPortal == null || fNameInput == null || fDefaultToggle == null || fPingButton == null || portalsManager == null || mGetById == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"XPortal internals not found (expected XPortal 1.2.26). Portal Compass stays off; XPortal's own panel works as before.");
				initDone = true;
				return true;
			}
			harmony = new Harmony("com.joostliebregts.portalpicker." + Guid.NewGuid().ToString("N"));
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AfterConfigure", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Plugin), "BeforeHandleInput", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo3 = AccessTools.Method(typeof(TeleportWorld), "Teleport", new Type[1] { typeof(Player) }, (Type[])null);
			if (methodInfo3 != null)
			{
				harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AfterTeleport", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"TeleportWorld.Teleport(Player) not found: 'last used' will not be recorded.");
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Portal Compass 1.0.1 on top of XPortal.");
			initDone = true;
			return true;
		}

		private static void AfterConfigure(object __instance)
		{
			if (!Object.op_Implicit((Object)(object)instance))
			{
				return;
			}
			try
			{
				instance.Open(__instance);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)instance).Logger.LogError((object)$"Picker failed to open, falling back to XPortal's own panel: {arg}");
				instance.Close();
			}
		}

		private static bool BeforeHandleInput()
		{
			if (Object.op_Implicit((Object)(object)instance))
			{
				return !instance.Active;
			}
			return true;
		}

		private static void AfterTeleport(Player player, ZNetView ___m_nview)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Object.op_Implicit((Object)(object)player) || (Object)(object)player != (Object)(object)Player.m_localPlayer || !((Character)player).IsTeleporting() || !Object.op_Implicit((Object)(object)___m_nview) || ___m_nview.GetZDO() == null)
				{
					return;
				}
				XpPortal xpPortal = Portal(___m_nview.GetZDO().m_uid);
				XpPortal xpPortal2 = ((xpPortal == null || !xpPortal.HasTarget()) ? null : Portal(xpPortal.Target));
				if (xpPortal2 != null)
				{
					Store.Entry entry = Store.For(StoreKey());
					string key = KeyOf(xpPortal2.Location);
					entry.used.RemoveAll((Store.Used u) => u.k == key);
					entry.used.Insert(0, new Store.Used
					{
						k = key,
						t = DateTimeOffset.UtcNow.ToUnixTimeSeconds()
					});
					if (entry.used.Count > 50)
					{
						entry.used.RemoveRange(50, entry.used.Count - 50);
					}
					Store.Save();
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)instance).Logger.LogWarning((object)("Could not record the teleport: " + ex.Message));
			}
		}

		private static XpPortal Portal(ZDOID id)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return XpPortal.Of(mGetById.Invoke(portalsManager, new object[1] { id }));
			}
			catch (TargetInvocationException)
			{
				return null;
			}
		}

		private static string KeyOf(Vector3 p)
		{
			//IL_0005: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			return $"{(int)p.x},{(int)p.y},{(int)p.z}";
		}

		private static string StoreKey()
		{
			Game obj = Game.instance;
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				PlayerProfile playerProfile = obj.GetPlayerProfile();
				obj2 = ((playerProfile != null) ? playerProfile.GetName() : null);
			}
			if (obj2 == null)
			{
				obj2 = "player";
			}
			string text = (Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetWorldName() : "world");
			return (string?)obj2 + "@" + text;
		}

		private void Open(object panel)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Expected O, but got Unknown
			mainPanel = (GameObject)fMainPanel.GetValue(panel);
			dropdown = (Dropdown)fDropdown.GetValue(panel);
			xpName = (InputField)fNameInput.GetValue(panel);
			xpDefault = (Toggle)fDefaultToggle.GetValue(panel);
			thisPortal = XpPortal.Of(fThisPortal.GetValue(panel));
			GameObject val = (GameObject)fPingButton.GetValue(panel);
			if (!Object.op_Implicit((Object)(object)mainPanel) || !Object.op_Implicit((Object)(object)dropdown) || !Object.op_Implicit((Object)(object)xpName) || !Object.op_Implicit((Object)(object)xpDefault) || thisPortal == null)
			{
				return;
			}
			xpPing = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<Button>() : null);
			Transform obj = mainPanel.transform.Find("XPortal_OkayButton");
			xpOk = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
			Transform obj2 = mainPanel.transform.Find("XPortal_CancelButton");
			xpCancel = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
			if (!Object.op_Implicit((Object)(object)xpOk) || !Object.op_Implicit((Object)(object)xpCancel))
			{
				throw new Exception("XPortal's OK/Cancel buttons not found");
			}
			font = (Object.op_Implicit((Object)(object)dropdown.captionText) ? dropdown.captionText.font : Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf"));
			entries.Clear();
			foreach (KeyValuePair<int, ZDOID> item in (Dictionary<int, ZDOID>)fMapping.GetValue(panel))
			{
				if (item.Value == ZDOID.None)
				{
					entries.Add(new Entry
					{
						Index = item.Key,
						Key = "",
						Name = Localization.instance.Localize("$piece_portal_target_none"),
						Meters = -1f
					});
					continue;
				}
				XpPortal xpPortal = Portal(item.Value);
				if (xpPortal != null)
				{
					entries.Add(new Entry
					{
						Index = item.Key,
						Key = KeyOf(xpPortal.Location),
						Name = xpPortal.GetFriendlyName(),
						Pos = xpPortal.Location,
						Meters = Vector3.Distance(thisPortal.Location, xpPortal.Location)
					});
				}
			}
			if (!Object.op_Implicit((Object)(object)root) || !Object.op_Implicit((Object)(object)canvasGo) || (Object)(object)builtFor != (Object)(object)mainPanel)
			{
				Build();
			}
			xpWidgets.Clear();
			foreach (Transform item2 in mainPanel.transform)
			{
				Transform val2 = item2;
				xpWidgets.Add(((Component)val2).gameObject);
			}
			HideXPortalWidgets();
			mainImg = mainPanel.GetComponent<Image>();
			if (Object.op_Implicit((Object)(object)mainImg) && ((Behaviour)mainImg).enabled)
			{
				((Behaviour)mainImg).enabled = false;
				hidMainImg = true;
			}
			ApplyScale();
			canvasGo.SetActive(true);
			store = Store.For(StoreKey());
			noDistance = ServerFlag("HidePortalDistance");
			foreach (var chip in chips)
			{
				if (chip.id == "nearest")
				{
					((Component)((Component)chip.img).transform).gameObject.SetActive(!noDistance);
				}
			}
			root.SetActive(true);
			nameField.SetTextWithoutNotify(xpName.text);
			defaultOn = xpDefault.isOn;
			ShowDefault();
			mapFitted = false;
			if (Object.op_Implicit((Object)(object)mapMat))
			{
				Object.Destroy((Object)(object)mapMat);
				mapMat = null;
			}
			foreach (var tab in tabs)
			{
				if (tab.id == "map")
				{
					((Selectable)((Component)tab.img).GetComponent<Button>()).interactable = MapAvailable();
				}
			}
			this.tab = ((Store.Data.lastTab == "list") ? "list" : ((Store.Data.lastTab == "map" && MapAvailable()) ? "map" : "quick"));
			mode = "az";
			search.SetTextWithoutNotify("");
			lastSearch = "";
			Refresh(selectCurrent: true);
			focusIn = 1;
		}

		private void ApplyScale()
		{
			if (Object.op_Implicit((Object)(object)scaler))
			{
				float num = 1f;
				try
				{
					num = PlatformPrefs.GetFloat("GuiScale", 1f);
				}
				catch
				{
				}
				float num2 = Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f) * num * uiScale.Value;
				float num3 = Mathf.Min((float)Screen.height * 0.96f / 720f, (float)Screen.width * 0.97f / 980f);
				float num4 = Mathf.Max(0.1f, Mathf.Min(num2, num3));
				if (!Mathf.Approximately(scaler.scaleFactor, num4))
				{
					scaler.scaleFactor = num4;
				}
			}
		}

		private void HideXPortalWidgets()
		{
			foreach (GameObject xpWidget in xpWidgets)
			{
				if (Object.op_Implicit((Object)(object)xpWidget) && xpWidget.activeSelf)
				{
					xpWidget.SetActive(false);
				}
			}
		}

		private void Close()
		{
			CloseContext();
			if (Object.op_Implicit((Object)(object)canvasGo))
			{
				canvasGo.SetActive(false);
			}
			if (mapZoomDirty)
			{
				Store.Save();
				mapZoomDirty = false;
			}
			foreach (GameObject xpWidget in xpWidgets)
			{
				if (Object.op_Implicit((Object)(object)xpWidget))
				{
					xpWidget.SetActive(true);
				}
			}
			if (hidMainImg && Object.op_Implicit((Object)(object)mainImg))
			{
				((Behaviour)mainImg).enabled = true;
			}
			hidMainImg = false;
			if (Object.op_Implicit((Object)(object)xpPing))
			{
				GameObject gameObject = ((Component)xpPing).gameObject;
				Entry entry = SelectedEntry();
				gameObject.SetActive(entry != null && entry.Key != "" && PingAllowed());
			}
			xpWidgets.Clear();
		}

		private bool PingAllowed()
		{
			if (!Object.op_Implicit((Object)(object)ZoneSystem.instance) || !ZoneSystem.instance.GetGlobalKey("nomap"))
			{
				return !ServerFlag("PingMapDisabled");
			}
			return false;
		}

		private static bool ServerFlag(string field)
		{
			try
			{
				object value = Traverse.Create(Traverse.Create(xpConfig).Property("Server", (object[])null).GetValue()).Field(field).GetValue();
				bool flag = default(bool);
				int num;
				if (value is bool)
				{
					flag = (bool)value;
					num = 1;
				}
				else
				{
					num = 0;
				}
				return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
			}
			catch
			{
				return false;
			}
		}

		private bool Pinned(Entry e)
		{
			if (e.Key != "")
			{
				return S.pinned.Contains(e.Key);
			}
			return false;
		}

		private long UsedAt(Entry e)
		{
			return S.used.FirstOrDefault((Store.Used u) => u.k == e.Key)?.t ?? 0;
		}

		private static int Rank(Entry e, string q)
		{
			int num = e.Name.IndexOf(q, StringComparison.OrdinalIgnoreCase);
			if (num < 0)
			{
				return -1;
			}
			if (num == 0)
			{
				return 0;
			}
			if (!char.IsLetterOrDigit(e.Name[num - 1]))
			{
				return 1;
			}
			return 2;
		}

		private List<Entry> Matches(string q)
		{
			return (from x in (from e in Portals
					select (e: e, r: Rank(e, q)) into x
					where x.r >= 0
					orderby x.r, (!noDistance) ? x.e.Meters : 0f
					select x).ThenBy<(Entry, int), string>(((Entry e, int r) x) => x.e.Name, StringComparer.OrdinalIgnoreCase)
				select x.e).ToList();
		}

		private Entry SelectedEntry()
		{
			if (!Object.op_Implicit((Object)(object)dropdown))
			{
				return null;
			}
			return entries.FirstOrDefault((Entry e) => e.Index == dropdown.value);
		}

		private string Dist(float m)
		{
			if (!(m < 0f) && !noDistance)
			{
				if (!(m >= 1000f))
				{
					return $"{(int)m} m";
				}
				return $"{m / 1000f:0.0} km";
			}
			return "";
		}

		private static string When(long t)
		{
			if (t <= 0)
			{
				return "";
			}
			long num = DateTimeOffset.UtcNow.ToUnixTimeSeconds() - t;
			if (num < 60)
			{
				return "just now";
			}
			if (num < 3600)
			{
				return $"{num / 60} min ago";
			}
			if (num < 86400)
			{
				return $"{num / 3600} h ago";
			}
			if (num < 172800)
			{
				return "yesterday";
			}
			return $"{num / 86400} days ago";
		}

		private string Direction(Entry e)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (noDistance || e.Meters < 50f)
			{
				return "";
			}
			float num = e.Pos.x - thisPortal.Location.x;
			float num2 = e.Pos.z - thisPortal.Location.z;
			float num3 = (Mathf.Atan2(num, num2) * 57.29578f + 360f + 22.5f) % 360f;
			return (new string[8] { "north", "north-east", "east", "south-east", "south", "south-west", "west", "north-west" })[(int)(num3 / 45f) % 8];
		}

		private void Refresh(bool selectCurrent = false, Entry keep = null)
		{
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			string q = Q;
			Clear((Transform)(object)quickArea);
			Clear((Transform)(object)listContent);
			Clear((Transform)(object)railArea);
			railLetters.Clear();
			Clear((Transform)(object)mapListContent);
			dots.Clear();
			unexplored.Clear();
			nameTags.Clear();
			playerDots.Clear();
			hereDot = null;
			youTag = null;
			selRing = null;
			hoverRing = null;
			Clear((Transform)(object)dotLayer);
			nav.Clear();
			navRow = 0;
			((Component)quickArea).gameObject.SetActive(tab == "quick");
			((Component)listArea).gameObject.SetActive(tab == "list");
			chipsRow.SetActive(tab == "list");
			((Component)mapArea).gameObject.SetActive(tab == "map");
			foreach (var tab in tabs)
			{
				bool flag = tab.id == this.tab;
				bool flag2 = tab.id == "map" && !MapAvailable();
				((Graphic)tab.img).color = (flag2 ? Hex(1381135) : (flag ? SelCol : TabOff));
				((Graphic)tab.t).color = (flag2 ? Faint : (flag ? Orange : Dim));
				Underline(((Component)tab.img).transform, flag);
			}
			foreach (var chip in chips)
			{
				bool flag3 = chip.id == mode;
				((Graphic)chip.img).color = (flag3 ? SelCol : TabOff);
				((Graphic)chip.t).color = (flag3 ? Orange : Dim);
				Underline(((Component)chip.img).transform, flag3);
			}
			int num = Portals.Count();
			List<Entry> hits = ((q.Length > 0) ? Matches(q) : Portals.ToList());
			clearButton.SetActive(search.text.Length > 0);
			countLabel.text = ((q.Length == 0) ? $"{num} portals" : ((hits.Count == 0) ? "no match" : ((hits.Count == 1) ? "1 match · Enter to link" : $"{hits.Count} of {num} · Enter = top match")));
			if (this.tab == "quick")
			{
				BuildQuick(q, hits);
			}
			else if (this.tab == "map")
			{
				BuildMap(q, hits);
			}
			else
			{
				BuildList(q, hits);
			}
			int num2 = -1;
			bool setTarget = false;
			if (q.Length > 0 && keep == null)
			{
				num2 = ((hits.Count > 0) ? nav.FindIndex((Nav n) => n.Entry == hits[0]) : (-1));
				setTarget = num2 >= 0;
			}
			else
			{
				Entry want = keep ?? SelectedEntry();
				num2 = nav.FindIndex((Nav n) => n.Entry == want);
			}
			Select(num2, setTarget);
			RoundAll((Transform)(object)quickArea);
			RoundAll((Transform)(object)listContent);
			RoundAll((Transform)(object)mapListContent);
			if (ContextOpen)
			{
				ctxMenu.transform.SetAsLastSibling();
			}
		}

		private void BuildQuick(string q, List<Entry> hits)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0157: 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_017a: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: 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_0591: Expected O, but got Unknown
			bool childControlHeight;
			if (q.Length > 0)
			{
				GameObject val = Panel("Matches", (Transform)(object)quickArea, Box);
				VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>();
				childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true);
				((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = childControlHeight;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
				((HorizontalOrVerticalLayoutGroup)obj).spacing = 2f;
				((LayoutGroup)obj).padding = new RectOffset(2, 2, 2, 2);
				val.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
				foreach (Entry item in hits.Take(4))
				{
					Row(val.transform, item, withWhen: false);
				}
				if (hits.Count == 0)
				{
					Hint(val.transform, "No portal matches. Esc clears the search.");
				}
				if (hits.Count > 4)
				{
					Hint(val.transform, $"{hits.Count - 4} more: keep typing, or see them all on the List tab (Ctrl+2).");
				}
			}
			List<Entry> list = (from k in S.pinned
				select Portals.FirstOrDefault((Entry e) => e.Key == k) into e
				where e != null
				select e).Take(6).ToList();
			GameObject val2 = Panel("Pinned", (Transform)(object)quickArea, PinBox);
			VerticalLayoutGroup obj2 = val2.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(12, 12, 8, 12);
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 8f;
			childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			val2.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			SectionHead(val2.transform, "PINNED", (q.Length == 0) ? "1-6 to jump · Ctrl+P pins the selected portal" : "");
			if (list.Count == 0)
			{
				Hint(val2.transform, "Nothing pinned yet. Select a portal and press Pin.");
			}
			else
			{
				Transform grid = Grid(val2.transform, 3, 76f);
				for (int num = 0; num < list.Count; num++)
				{
					Tile(grid, list[num], (num + 1).ToString(), Dist(list[num].Meters), TileCol, pinned: true, q.Length == 0, navRow + num / 3, ((float)(num % 3) + 0.5f) / 3f);
				}
				navRow += (list.Count + 2) / 3;
			}
			if (q.Length > 0)
			{
				return;
			}
			List<Entry> rec = Portals.Where((Entry e) => !Pinned(e) && UsedAt(e) > 0).OrderByDescending(UsedAt).Take(4)
				.ToList();
			GameObject val3 = Panel("Recent", (Transform)(object)quickArea, new Color(0f, 0f, 0f, 0f));
			VerticalLayoutGroup obj3 = val3.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj3).padding = new RectOffset(12, 12, 4, 4);
			((HorizontalOrVerticalLayoutGroup)obj3).spacing = 6f;
			childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true);
			((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false;
			val3.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			SectionHead(val3.transform, "RECENT", "");
			if (rec.Count == 0)
			{
				Hint(val3.transform, "Portals you travel to show up here.");
			}
			else
			{
				Transform grid2 = Grid(val3.transform, 4, 62f);
				for (int num2 = 0; num2 < rec.Count; num2++)
				{
					Tile(grid2, rec[num2], "", string.Join(" · ", new string[2]
					{
						When(UsedAt(rec[num2])),
						Dist(rec[num2].Meters)
					}.Where((string x) => x != "")), RowCol, pinned: false, navigable: true, navRow + num2 / 4, ((float)(num2 % 4) + 0.5f) / 4f);
				}
				navRow += (rec.Count + 3) / 4;
			}
			if (noDistance)
			{
				return;
			}
			int num3 = (list.Count + 2) / 3;
			float num4 = ((list.Count == 0) ? 84f : (50f + (float)num3 * 76f + (float)(num3 - 1) * 10f)) + ((rec.Count == 0) ? 70f : 98f) + 20f;
			int count = Mathf.Clamp(Mathf.FloorToInt((484f - num4 - 10f - 22f - 14f) / 42f), 0, 6);
			List<Entry> list2 = (from e in Portals
				where !Pinned(e) && !rec.Contains(e)
				orderby e.Meters
				select e).Take(count).ToList();
			if (list2.Count == 0)
			{
				return;
			}
			GameObject val4 = Panel("Nearest", (Transform)(object)quickArea, new Color(0f, 0f, 0f, 0f));
			VerticalLayoutGroup obj4 = val4.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj4).padding = new RectOffset(12, 12, 4, 4);
			((HorizontalOrVerticalLayoutGroup)obj4).spacing = 2f;
			childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true);
			((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
			val4.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			SectionHead(val4.transform, "NEAREST", "");
			foreach (Entry item2 in list2)
			{
				Row(val4.transform, item2, withWhen: false);
			}
		}

		private void BuildList(string q, List<Entry> hits)
		{
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			IEnumerable<Entry> source = hits;
			if (mode == "recent")
			{
				source = hits.Where((Entry e) => UsedAt(e) > 0).OrderByDescending(UsedAt);
			}
			else if (mode == "pinned")
			{
				source = hits.Where(Pinned).OrderBy<Entry, string>((Entry e) => e.Name, StringComparer.OrdinalIgnoreCase);
			}
			else if (mode == "nearest")
			{
				source = hits.OrderBy((Entry e) => e.Meters);
			}
			else if (q.Length == 0)
			{
				source = hits.OrderBy<Entry, string>((Entry e) => e.Name, StringComparer.OrdinalIgnoreCase);
			}
			List<Entry> list = source.ToList();
			if (mode == "az" && q.Length == 0)
			{
				Entry entry = entries.FirstOrDefault((Entry e) => e.Key == "");
				if (entry != null)
				{
					Row((Transform)(object)listContent, entry, withWhen: false);
				}
			}
			foreach (Entry item in list)
			{
				Row((Transform)(object)listContent, item, withWhen: true);
			}
			if (list.Count == 0)
			{
				Hint((Transform)(object)listContent, (mode == "recent") ? "No portal used yet." : ((mode == "pinned") ? "Nothing pinned yet." : "No portal matches."));
			}
			listScroll.verticalNormalizedPosition = 1f;
			bool flag = mode == "az" && q.Length == 0;
			((Component)railArea).gameObject.SetActive(flag);
			if (!flag)
			{
				return;
			}
			foreach (string item2 in list.Select((Entry e) => Letter(e.Name)).Distinct())
			{
				GameObject val = NewUi("L", (Transform)(object)railArea);
				val.AddComponent<LayoutElement>().flexibleHeight = 1f;
				Text val2 = Label(val.transform, item2, 13, Dim);
				val2.alignment = (TextAnchor)4;
				val2.fontStyle = (FontStyle)1;
				val2.resizeTextForBestFit = true;
				val2.resizeTextMinSize = 8;
				val2.resizeTextMaxSize = Mathf.RoundToInt(14.95f);
				railLetters.Add((item2, val2));
			}
		}

		private bool MapAvailable()
		{
			if (Object.op_Implicit((Object)(object)Minimap.instance) && Object.op_Implicit((Object)(object)Minimap.instance.m_mapImageLarge) && Object.op_Implicit((Object)(object)Minimap.instance.m_mapTexture) && (!Object.op_Implicit((Object)(object)ZoneSystem.instance) || !ZoneSystem.instance.GetGlobalKey("nomap")))
			{
				return !noDistance;
			}
			return false;
		}

		private void BuildMapArea()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0117: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01c2: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: 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_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Expected O, but got Unknown
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: 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_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Expected O, but got Unknown
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Expected O, but got Unknown
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0617: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NewUi("Map", root.transform);
			mapArea = (RectTransform)val.transform;
			Stretch(mapArea, 20f, 156f, 20f, 80f);
			GameObject val2 = NewUi("MapList", val.transform);
			RectTransform val3 = (RectTransform)val2.transform;
			val3.anchorMin = new Vector2(0f, 0f);
			val3.anchorMax = new Vector2(0f, 1f);
			val3.pivot = new Vector2(0f, 0.5f);
			val3.sizeDelta = new Vector2(260f, 0f);
			val3.anchoredPosition = Vector2.zero;
			((Graphic)val2.AddComponent<Image>()).color = Box;
			ScrollRect obj = val2.AddComponent<ScrollRect>();
			obj.horizontal = false;
			obj.movementType = (MovementType)2;
			obj.scrollSensitivity = 0f;
			GameObject val4 = NewUi("Viewport", val2.transform);
			mapListViewport = (RectTransform)val4.transform;
			mapListViewport.anchorMin = Vector2.zero;
			mapListViewport.anchorMax = Vector2.one;
			mapListViewport.offsetMin = new Vector2(6f, 6f);
			mapListViewport.offsetMax = new Vector2(-6f, -6f);
			val4.AddComponent<RectMask2D>();
			((Graphic)val4.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
			GameObject val5 = NewUi("Content", val4.transform);
			mapListContent = (RectTransform)val5.transform;
			mapListContent.anchorMin = new Vector2(0f, 1f);
			mapListContent.anchorMax = new Vector2(1f, 1f);
			mapListContent.pivot = new Vector2(0.5f, 1f);
			mapListContent.sizeDelta = Vector2.zero;
			VerticalLayoutGroup obj2 = val5.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f;
			bool childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = childControlHeight;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
			val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			obj.viewport = mapListViewport;
			obj.content = mapListContent;
			GameObject val6 = NewUi("MapFrame", val.transform);
			mapFrame = (RectTransform)val6.transform;
			mapFrame.anchorMin = Vector2.zero;
			mapFrame.anchorMax = Vector2.one;
			mapFrame.offsetMin = new Vector2(276f, 0f);
			mapFrame.offsetMax = Vector2.zero;
			((Graphic)val6.AddComponent<Image>()).color = Box;
			val6.AddComponent<RectMask2D>();
			mapView = val6.AddComponent<MapView>();
			mapView.Owner = this;
			GameObject val7 = NewUi("MapImage", val6.transform);
			RectTransform val8 = (RectTransform)val7.transform;
			val8.anchorMin = Vector2.zero;
			val8.anchorMax = Vector2.one;
			Vector2 val9 = (val8.offsetMin = (val8.offsetMax = Vector2.zero));
			mapImage = val7.AddComponent<RawImage>();
			((Graphic)mapImage).raycastTarget = false;
			GameObject val11 = NewUi("Dots", val6.transform);
			dotLayer = (RectTransform)val11.transform;
			dotLayer.anchorMin = Vector2.zero;
			dotLayer.anchorMax = Vector2.one;
			val9 = (dotLayer.offsetMin = (dotLayer.offsetMax = Vector2.zero));
			mapLabel = NewUi("Label", val6.transform);
			RectTransform val13 = (RectTransform)mapLabel.transform;
			val9 = (val13.anchorMin = (val13.anchorMax = Vector2.zero));
			val13.pivot = new Vector2(0f, 0.5f);
			Image obj3 = mapLabel.AddComponent<Image>();
			((Graphic)obj3).color = Hex(789000, 0.92f);
			((Graphic)obj3).raycastTarget = false;
			HorizontalLayoutGroup obj4 = mapLabel.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj4).padding = new RectOffset(10, 10, 4, 4);
			childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = childControlHeight;
			mapLabel.AddComponent<ContentSizeFitter>().horizontalFit = (FitMode)2;
			mapLabel.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			mapLabelText = Label(mapLabel.transform, "", 16, Ink);
			mapLabelText.fontStyle = (FontStyle)1;
			mapLabel.SetActive(false);
			GameObject val15 = NewUi("Hint", val6.transform);
			RectTransform val16 = (RectTransform)val15.transform;
			((Vector2)(ref val9))..ctor(0f, 1f);
			val16.anchorMax = val9;
			val16.anchorMin = val9;
			val16.pivot = new Vector2(0f, 1f);
			val16.anchoredPosition = new Vector2(10f, -10f);
			Image obj5 = val15.AddComponent<Image>();
			((Graphic)obj5).color = Hex(789000, 0.85f);
			((Graphic)obj5).raycastTarget = false;
			HorizontalLayoutGroup obj6 = val15.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj6).padding = new RectOffset(10, 10, 4, 4);
			childControlHeight = (((HorizontalOrVerticalLayoutGroup)obj6).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)obj6).childControlWidth = childControlHeight;
			ContentSizeFitter obj7 = val15.AddComponent<ContentSizeFitter>();
			FitMode horizontalFit = (FitMode)2;
			obj7.verticalFit = (FitMode)2;
			obj7.horizontalFit = horizontalFit;
			Label(val15.transform, "Click a dot to pick · wheel to zoom · drag to move", 13, Dim);
			mapOff = NewUi("Off", val6.transform);
			RectTransform val17 = (RectTransform)mapOff.transform;
			val17.anchorMin = Vector2.zero;
			val17.anchorMax = Vector2.one;
			val9 = (val17.offsetMin = (val17.offsetMax = Vector2.zero));
			Label(mapOff.transform, "The map is off on this server.", 17, Faint).alignment = (TextAnchor)4;
			mapOff.SetActive(false);
		}

		private void BuildMap(string q, List<Entry> hits)
		{
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_015e: 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_0164: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Expected O, but got Unknown
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Expected O, but got Unknown
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0538: Unknown result type (might be due to invalid IL or missing references)
			bool flag = MapAvailable();
			mapOff.SetActive(!flag);
			((Behaviour)mapImage).enabled = flag;
			if (!flag)
			{
				return;
			}
			EnsureMapMaterial();
			List<Entry> list = ((q.Length > 0) ? hits : hits.OrderBy<Entry, string>((Entry e) => e.Name, StringComparer.OrdinalIgnoreCase).ToList());
			Entry entry = entries.FirstOrDefault((Entry e) => e.Key == "");
			if (q.Length == 0 && entry != null)
			{
				Row((Transform)(object)mapListContent, entry, withWhen: false, compact: true);
			}
			foreach (Entry item in list)
			{
				Row((Transform)(object)mapListContent, item, withWhen: false, compact: true);
			}
			Vector2 anchorMin;
			foreach (Entry item2 in list)
			{
				if (!Explored(item2.Pos))
				{
					unexplored.Add(item2);
				}
				GameObject val = NewUi("Dot", (Transform)(object)dotLayer);
				RectTransform rt = (RectTransform)val.transform;
				RectTransform obj = rt;
				anchorMin = (rt.anchorMax = Vector2.zero);
				obj.anchorMin = anchorMin;
				rt.pivot = new Vector2(0.5f, 0.5f);
				Image val2 = val.AddComponent<Image>();
				val2.preserveAspect = true;
				Button obj2 = val.AddComponent<Button>();
				((Selectable)obj2).targetGraphic = (Graphic)(object)val2;
				NoNav((Selectable)(object)obj2);
				Entry entry2 = item2;
				((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
				{
					int num = nav.FindIndex((Nav n) => n.Entry == entry2);
					if (num >= 0)
					{
						Select(num, setTarget: true);
					}
					focusIn = 1;
				});
				RightClick rightClick = val.AddComponent<RightClick>();
				rightClick.OnRight = delegate(Vector2 pos)
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					ShowContext(entry2, pos);
				};
				rightClick.OnDouble = delegate
				{
					LinkTo(entry2);
				};
				Hover hover = val.AddComponent<Hover>();
				hover.Show = delegate
				{
					ShowMapLabel(entry2, rt);
					ShowHoverRing(rt);
				};
				hover.Hide = delegate
				{
					ShowMapLabel(SelectedEntry(), null);
					ShowHoverRing(null);
				};
				dots.Add((item2, rt, val2));
				nameTags.Add(NameTag(item2.Name));
			}
			GameObject val3 = NewUi("Here", (Transform)(object)dotLayer);
			hereDot = (RectTransform)val3.transform;
			RectTransform obj3 = hereDot;
			anchorMin = (hereDot.anchorMax = Vector2.zero);
			obj3.anchorMin = anchorMin;
			hereDot.pivot = new Vector2(0.5f, 0.5f);
			hereDot.sizeDelta = new Vector2(44f, 44f);
			Image val4 = val3.AddComponent<Image>();
			((Graphic)val4).raycastTarget = false;
			val4.preserveAspect = true;
			Image val5 = (Object.op_Implicit((Object)(object)Minimap.instance.m_largeMarker) ? ((Component)Minimap.instance.m_largeMarker).GetComponent<Image>() : null);
			if (Object.op_Implicit((Object)(object)val5) && Object.op_Implicit((Object)(object)val5.sprite))
			{
				val4.sprite = val5.sprite;
				((Graphic)val4).color = ((Graphic)val5).color;
			}
			else
			{
				val4.sprite = RingSprite();
				((Graphic)val4).color = Ink;
			}
			youTag = NameTag("You");
			((Graphic)((Component)youTag).GetComponentInChildren<Text>()).color = Orange;
			GameObject val6 = NewUi("HoverRing", (Transform)(object)dotLayer);
			hoverRing = (RectTransform)val6.transform;
			RectTransform obj4 = hoverRing;
			anchorMin = (hoverRing.anchorMax = Vector2.zero);
			obj4.anchorMin = anchorMin;
			hoverRing.pivot = new Vector2(0.5f, 0.5f);
			hoverRing.sizeDelta = new Vector2(34f, 34f);
			Image obj5 = val6.AddComponent<Image>();
			obj5.sprite = RingSprite();
			((Graphic)obj5).color = new Color(1f, 1f, 1f, 0.85f);
			((Graphic)obj5).raycastTarget = false;
			val6.SetActive(false);
			GameObject val7 = NewUi("SelRing", (Transform)(object)dotLayer);
			selRing = (RectTransform)val7.transform;
			RectTransform obj6 = selRing;
			anchorMin = (selRing.anchorMax = Vector2.zero);
			obj6.anchorMin = anchorMin;
			selRing.pivot = new Vector2(0.5f, 0.5f);
			Image obj7 = val7.AddComponent<Image>();
			obj7.sprite = RingSprite();
			((Graphic)obj7).color = PinOn;
			((Graphic)obj7).raycastTarget = false;
			if (!mapFitted)
			{
				Canvas.ForceUpdateCanvases();
				Entry entry3 = SelectedEntry();
				Vector3 val8 = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? ((Component)Player.m_localPlayer).transform.position : thisPortal.Location);
				mapCenter = ToUv((entry3 != null && entry3.Key != "") ? entry3.Pos : val8);
				mapZoom = ((Store.Data.mapZoom > 0f) ? Mathf.Clamp(Store.Data.mapZoom, 0.01f, 1f) : 0.12f);
				mapFitted = true;
				mapJustFitted = true;
			}
			PlaceMap();
		}

		private bool Explored(Vector3 p)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if ((object)mIsExplored == null)
			{
				mIsExplored = AccessTools.Method(typeof(Minimap), "IsExplored", new Type[1] { typeof(Vector3) }, (Type[])null);
			}
			try
			{
				return mIsExplored == null || (bool)mIsExplored.Invoke(Minimap.instance, new object[1] { p });
			}
			catch
			{
				return true;
			}
		}

		private void EnsureMapMaterial()
		{
			if (!Object.op_Implicit((Object)(object)mapMat))
			{
				mapMat = Object.Instantiate<Material>(((Graphic)Minimap.instance.m_mapImageLarge).material);
				((Graphic)mapImage).material = mapMat;
				mapImage.texture = (Texture)(object)Minimap.instance.m_mapTexture;
			}
		}

		private Vector2 ToUv(Vector3 p)
		{
			//IL_0014: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			Minimap val = Minimap.instance;
			float num = (float)val.m_textureSize / 2f;
			return new Vector2((p.x / val.m_pixelSize + num) / (float)val.m_textureSize, (p.z / val.m_pixelSize + num) / (float)val.m_textureSize);
		}

		private Vector3 ToWorld(Vector2 uv)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			Minimap val = Minimap.instance;
			float num = (float)val.m_textureSize / 2f;
			return new Vector3((uv.x * (float)val.m_textureSize - num) * val.m_pixelSize, 0f, (uv.y * (float)val.m_textureSize - num) * val.m_pixelSize);
		}

		public void ZoomMap(float steps, Vector2 pointer01)
		{
			//IL_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_007e: 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)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			float num = mapZoom;
			mapZoom = Mathf.Clamp(mapZoom * Mathf.Pow(0.8f, steps), 0.01f, 1f);
			Store.Data.mapZoom = mapZoom;
			mapZoomDirty = true;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(num * Aspect, num);
			Vector2 val2 = mapCenter + Vector2.Scale(pointer01 - new Vector2(0.5f, 0.5f), val);
			mapCenter = val2 - Vector2.Scale(pointer01 - new Vector2(0.5f, 0.5f), new Vector2(mapZoom * Aspect, mapZoom));
			PlaceMap();
		}

		public void PanMap(Vector2 delta01)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			mapCenter -= Vector2.Scale(delta01, new Vector2(mapZoom * Aspect, mapZoom));
			PlaceMap();
		}

		private void PlaceMap()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_0102: 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_0118: 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_0120: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: 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_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: 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_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: 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_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)mapMat) || !Object.op_Implicit((Object)(object)mapFrame))
			{
				return;
			}
			mapCenter = new Vector2(Mathf.Clamp01(mapCenter.x), Mathf.Clamp01(mapCenter.y));
			float w = mapZoom * Aspect;
			float h = mapZoom;
			mapImage.uvRect = new Rect(mapCenter.x - w / 2f, mapCenter.y - h / 2f, w, h);
			mapMat.SetFloat("_zoom", mapZoom);
			mapMat.SetFloat("_pixelSize", 200f / mapZoom);
			mapMat.SetVector("_mapCenter", Vector4.op_Implicit(ToWorld(mapCenter)));
			Rect rect = mapFrame.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			Entry selected = SelectedEntry();
			float num = Mathf.Clamp01((0.08f - mapZoom) / 0.02f);
			for (int i = 0; i < dots.Count; i++)
			{
				(Entry e, RectTransform rt, Image img) tuple = dots[i];
				Entry item = tuple.e;
				RectTransform item2 = tuple.rt;
				Image item3 = tuple.img;
				Vector2 val = Local(item.Pos);
				((Component)item2).gameObject.SetActive(Inside(val) && (item == selected || !unexplored.Contains(item)));
				((Component)nameTags[i]).gameObject.SetActive(false);
				item2.anchoredPosition = val;
				bool flag = item == selected;
				bool flag2 = Pinned(item);
				item3.sprite = (flag2 ? PinSprite() : DotSprite());
				((Graphic)item3).color = (flag2 ? PinOn : (flag ? PinOn : Ink));
				item2.sizeDelta = (flag2 ? new Vector2(28f, 28f) : new Vector2((float)(flag ? 18 : 14), (float)(flag ? 18 : 14)));
				if (flag)
				{
					((Transform)item2).SetAsLastSibling();
				}
			}
			if (num > 0.01f)
			{
				List<Rect> list = new List<Rect>();
				Vector2 mid = size / 2f;
				Vector3 p = (Object.op_Implicit((Object)(object)Player.m_localPlayer) ? ((Component)Player.m_localPlayer).transform.position : thisPortal.Location);
				Vector2 val2 = MapLocal(p);
				list.Add(new Rect(val2.x - 22f, val2.y - 22f, 44f, 44f));
				list.Add(TagRect(val2 + new Vector2(0f, -24f), "You"));
				tmpPlayers.Clear();
				try
				{
					ZNet obj = ZNet.instance;
					if (obj != null)
					{
						obj.GetOtherPublicPlayers(tmpPlayers);
					}
				}
				catch
				{
				}
				foreach (PlayerInfo tmpPlayer in tmpPlayers)
				{
					Vector2 val3 = MapLocal(tmpPlayer.m_position);
					list.Add(new Rect(val3.x - 15f, val3.y - 15f, 30f, 30f));
					list.Add(TagRect(val3 + new Vector2(0f, -18f), tmpPlayer.m_name ?? ""));
				}
				foreach (int item5 in (from index in Enumerable.Range(0, dots.Count)
					where ((Component)dots[index].rt).gameObject.activeSelf && dots[index].e != selected
					orderby (!Pinned(dots[index].e)) ? 1 : 0
					select index).ThenBy(delegate(int index)
				{
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0021: Unknown result type (might be due to invalid IL or missing references)
					//IL_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)
					Vector2 val6 = dots[index].rt.anchoredPosition - mid;
					return ((Vector2)(ref val6)).sqrMagnitude;
				}))
				{
					(Entry e, RectTransform rt, Image img) tuple2 = dots[item5];
					Entry item4 = tuple2.e;
					Vector2 val4 = tuple2.rt.anchoredPosition + new Vector2(0f, (float)(-(Pinned(item4) ? 18 : 12)));
					Rect r = TagRect(val4, item4.Name);
					if (!list.Any((Rect o) => ((Rect)(ref o)).Overlaps(r)))
					{
						list.Add(r);
						CanvasGroup obj3 = nameTags[item5];
						((Component)obj3).gameObject.SetActive(true);
						obj3.alpha = num;
						((RectTransform)((Component)obj3).transform).anchoredPosition = val4;
					}
				}
			}
			if (Object.op_Implicit((Object)(object)selRing))
			{
				(Entry, RectTransform, Image) tuple3 = dots.FirstOrDefault(((Entry e, RectTransform rt, Image img) x) => x.e == selected);
				bool flag3 = Object.op_Implicit((Object)(object)tuple3.Item2) && ((Component)tuple3.Item2).gameObject.activeSelf;
				((Component)selRing).gameObject.SetActive(flag3);
				if (flag3)
				{
					selRing.anchoredPosition = tuple3.Item2.anchoredPosition;
					selRing.sizeDelta = new Vector2(40f, 40f);
					((Transform)selRing).SetAsLastSibling();
					((Transform)tuple3.Item2).SetAsLastSibling();
				}
			}
			if (Object.op_Implicit((Object)(object)hereDot))
			{
				Vector2 val5 = Local(Object.op_Implicit((Object)(object)Player.m_localPlayer) ? ((Component)Player.m_localPlayer).transform.position : thisPortal.Location);
				hereDot.anchoredPosition = val5;
				((Component)hereDot).gameObject.SetActive(Inside(val5));
				((Transform)hereDot).SetAsLastSibling();
				if (Object.op_Implicit((Object)(object)youTag))
				{
					((Component)youTag).gameObject.SetActive(Inside(val5));
					youTag.alpha = 1f;
					((RectTransform)((Component)youTag).transform).anchoredPosition = val5 + new Vector2(0f, -24f);
					((Component)youTag).transform.SetAsLastSibling();
				}
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					RectTransform obj4 = hereDot;
					Quaternion rotation = ((Component)Player.m_localPlayer).transform.rotation;
					((Transform)obj4).localRotation = Quaternion.Euler(0f, 0f, 0f - ((Quaternion)(ref rotation)).eulerAngles.y);
				}
			}
			PlacePlayers();
			ShowMapLabel(selected, null);
			bool Inside(Vector2 v)
			{
				//IL_0000: 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_001a: 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)
				if (v.x > -20f && v.y > -20f && v.x < size.x + 20f)
				{
					return v.y < size.y + 20f;
				}
				return false;
			}
			Vector2 Local(Vector3 p2)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val6 = ToUv(p2);
				return new Vector2((val6.x - (mapCenter.x - w / 2f)) / w * size.x, (val6.y - (mapCenter.y - h / 2f)) / h * size.y);
			}
			static Rect TagRect(Vector2 at, string text)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				float num2 = (float)text.Length * 7.5f + 12f;
				return new Rect(at.x - num2 / 2f, at.y - 18f, num2, 18f);
			}
		}

		private Vector2 MapLocal(Vector3 p)
		{
			//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_0024: 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_002b: 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_0031: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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)
			float num = mapZoom * Aspect;
			float num2 = mapZoom;
			Rect rect = mapFrame.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			Vector2 val = ToUv(p);
			return new Vector2((val.x - (mapCenter.x - num / 2f)) / num * size.x, (val.y - (mapCenter.y - num2 / 2f)) / num2 * size.y);
		}

		private void PlacePlayers()
		{
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_006b: 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_0071: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)dotLayer) || !Object.op_Implicit((Object)(object)ZNet.instance) || !Object.op_Implicit((Object)(object)mapMat))
			{
				return;
			}
			tmpPlayers.Clear();
			try
			{
				ZNet.instance.GetOtherPublicPlayers(tmpPlayers);
			}
			catch
			{
				return;
			}
			while (playerDots.Count < tmpPlayers.Count)
			{
				GameObject obj2 = NewUi("Player", (Transform)(object)dotLayer);
				RectTransform val = (RectTransform)obj2.transform;
				Vector2 anchorMin = (val.anchorMax = Vector2.zero);
				val.anchorMin = anchorMin;
				val.pivot = new Vector2(0.5f, 0.5f);
				val.sizeDelta = new Vector2(30f, 30f);
				Image val2 = obj2.AddComponent<Image>();
				((Graphic)val2).raycastTarget = false;
				val2.preserveAspect = true;
				Sprite val3 = PlayerIcon();
				if (Object.op_Implicit((Object)(object)val3))
				{
					val2.sprite = val3;
				}
				else
				{
					val2.sprite = DotSprite();
					((Graphic)val2).color = FriendBlue;
				}
				CanvasGroup val4 = NameTag("");
				Text componentInChildren = ((Component)val4).GetComponentInChildren<Text>();
				((Graphic)componentInChildren).color = FriendBlue;
				playerDots.Add((val, val4, componentInChildren));
			}
			Rect rect = mapFrame.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			for (int i = 0; i < playerDots.Count; i++)
			{
				(RectTransform rt, CanvasGroup tag, Text text) tuple = playerDots[i];
				RectTransform item = tuple.rt;
				CanvasGroup item2 = tuple.tag;
				Text item3 = tuple.text;
				bool flag = i < tmpPlayers.Count;
				Vector2 val5 = (flag ? MapLocal(tmpPlayers[i].m_position) : Vector2.zero);
				flag = flag && val5.x > -20f && val5.y > -20f && val5.x < size.x + 20f && val5.y < size.y + 20f;
				((Component)item).gameObject.SetActive(flag);
				((Component)item2).gameObject.SetActive(flag);
				if (flag)
				{
					item.anchoredPosition = val5;
					((Transform)item).SetAsLastSibling();
					string text = tmpPlayers[i].m_name;
					try
					{
						string text2 = text;
						PlayerInfo val6 = tmpPlayers[i];
						text = CensorShittyWords.FilterUGC(text2, (UGCType)2, ((ZDOID)(ref val6.m_characterID)).UserID);
					}
					catch
					{
					}
					item3.text = text;
					item2.alpha = 1f;
					((RectTransform)((Component)item2).transform).anchoredPosition = val5 + new Vector2(0f, -18f);
					((Component)item2).transform.SetAsLastSibling();
				}
			}
		}

		private static Sprite PlayerIcon()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (playerIconLooked)
			{
				return playerIcon;
			}
			playerIconLooked = true;
			try
			{
				playerIcon = Minimap.instance.m_icons.Find((SpriteData x) => (int)x.m_name == 10).m_icon;
			}
			catch
			{
			}
			return playerIcon;
		}

		private CanvasGroup NameTag(string name)
		{
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = NewUi("Tag", (Transform)(object)dotLayer);
			RectTransform val2 = (RectTransform)val.transform;
			Vector2 anchorMin = (val2.anchorMax = Vector2.zero);
			val2.anchorMin = anchorMin;
			val2.pivot = new Vector2(0.5f, 1f);
			Image obj = val.AddComponent<Image>();
			((Graphic)obj).color = new Color(0f, 0f, 0f, 0.35f);
			((Graphic)obj).raycastTarget = false;
			HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj2).padding = new RectOffset(5, 5, 1, 1);
			bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = childControlWidth;
			ContentSizeFitter obj3 = val.AddComponent<ContentSizeFitter>();
			FitMode horizontalFit = (FitMode)2;
			obj3.verticalFit = (FitMode)2;
			obj3.horizontalFit = horizontalFit;
			Label(val.transform, name, 11, Ink);
			CanvasGroup obj4 = val.AddComponent<CanvasGroup>();
			obj4.blocksRaycasts = false;
			obj4.interactable = false;
			val.SetActive(false);
			return obj4;
		}

		private void ShowHoverRing(RectTransform at)
		{
			//IL_0040: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)hoverRing))
			{
				bool flag = Object.op_Implicit((Object)(object)at) && ((Component)at).gameObject.activeSelf;
				((Component)hoverRing).gameObject.SetActive(flag);
				if (flag)
				{
					hoverRing.anchoredPosition = at.anchoredPosition;
					float num = Mathf.Max(at.sizeDelta.x, 14f) + 14f;
					hoverRing.sizeDelta = new Vector2(num, num);
					((Transform)hoverRing).SetAsLastSibling();
					((Transform)at).SetAsLastSibling();
				}
			}
		}

		private void ShowMapLabel(Entry e, RectTransform at)
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)mapLabel))
			{
				return;
			}
			if ((Object)(object)at == (Object)null)
			{
				at = dots.FirstOrDefault(((Entry e, RectTransform rt, Image img) d) => d.e == e).rt;
			}
			bool flag = e != null && e.Key != "" && Object.op_Implicit((Object)(object)at) && ((Component)at).gameObject.activeSelf;
			mapLabel.SetActive(flag);
			if (flag)
			{
				mapLabelText.text = e.Name;
				RectTransform val = (RectTransform)mapLabel.transform;
				float num = mapLabelText.preferredWidth + 20f;
				float num2 = at.anchoredPosition.x + Mathf.Max(at.sizeDelta.x / 2f, 20f) + 6f;
				float y = at.anchoredPosition.y;
				Rect rect = mapFrame.rect;
				float num3 = Mathf.Clamp(y, 18f, ((Rect)(ref rect)).height - 18f);
				float num4 = num2 + num;
				rect = mapFrame.rect;
				bool flag2 = num4 > ((Rect)(ref rect)).width;
				val.pivot = new Vector2((float)(flag2 ? 1 : 0), 0.5f);
				val.anchoredPosition = new Vector2(flag2 ? (at.anchoredPosition.x - Mathf.Max(at.sizeDelta.x / 2f, 20f) - 6f) : num2, num3);
				mapLabel.transform.SetAsLastSibling();
			}
		}

		private void MapFollowSelection()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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)
			Entry entry = SelectedEntry();
			if (mapJustFitted)
			{
				mapJustFitted = false;
			}
			else if (entry != null && entry.Key != "" && Object.op_Implicit((Object)(object)mapMat))
			{
				Vector2 val = ToUv(entry.Pos);
				float num = mapZoom * Aspect;
				float num2 = mapZoom;
				if (Mathf.Abs(val.x - mapCenter.x) > num * 0.45f || Mathf.Abs(val.y - mapCenter.y) > num2 * 0.45f)
				{
					mapCenter = val;
				}
			}
			PlaceMap();
		}

		private static Sprite DotSprite()
		{
			if (!Object.op_Implicit((Object)(object)dotSprite))
			{
				return dotSprite = CircleSprite(ring: false);
			}
			return dotSprite;
		}

		private static Sprite RingSprite()
		{
			if (!Object.op_Implicit((Object)(object)ringSprite))
			{
				return ringSprite = CircleSprite(ring: true);
			}
			return ringSprite;
		}

		private static Sprite CircleSprite(bool ring)
		{
			//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: Expected O, but got Unknown
			//IL_0135: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown resul