Decompiled source of PerfectMapIcons v1.5.0

BepInEx/plugins/PerfectMapIcons.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.5.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.0.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
[BepInPlugin("PerfectMapIcons", "PerfectMapIcons", "1.5.0")]
public sealed class PerfectMapIcons : BaseUnityPlugin
{
	[HarmonyPatch]
	private class StartMap
	{
		private static MethodBase TargetMethod()
		{
			if (!(MapType != null))
			{
				return null;
			}
			return AccessTools.Method(MapType, "Start", (Type[])null, (Type[])null);
		}

		private static void Postfix(object __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			try
			{
				PerfectMapIcons instance = Instance;
				if ((Object)instance != (Object)null)
				{
					instance.Setup(__instance);
				}
			}
			catch (Exception ex)
			{
				if ((Object)Instance != (Object)null)
				{
					((BaseUnityPlugin)Instance).Logger.LogError((object)ex);
				}
			}
		}
	}

	[HarmonyPatch]
	private class SpriteLookup
	{
		private static MethodBase TargetMethod()
		{
			if (!(MapType != null))
			{
				return null;
			}
			return AccessTools.Method(MapType, "GetSprite", (Type[])null, (Type[])null);
		}

		private static bool Prefix(object[] __args, ref Sprite __result)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			try
			{
				if (__args == null || __args.Length == 0)
				{
					return true;
				}
				object obj = __args[0];
				if (!(obj is Enum))
				{
					return true;
				}
				if (ById.TryGetValue(Convert.ToInt32(obj), out var value) && (Object)value != (Object)null)
				{
					__result = value;
					return false;
				}
			}
			catch (Exception e)
			{
				WarnOnce("GetSprite", e);
			}
			return true;
		}
	}

	[HarmonyPatch]
	private class LocationLookup
	{
		private static MethodBase TargetMethod()
		{
			if (!(MapType != null))
			{
				return null;
			}
			return AccessTools.Method(MapType, "GetLocationIcon", (Type[])null, (Type[])null);
		}

		private static void Postfix(object[] __args, ref Sprite __result)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			try
			{
				if ((Object)(object)__result == (Object)null)
				{
					return;
				}
				PerfectMapIcons instance = Instance;
				if ((Object)instance == (Object)null || Sprites.Count == 0)
				{
					return;
				}
				string text = ((__args != null && __args.Length != 0) ? (__args[0] as string) : null);
				if (!string.IsNullOrEmpty(text))
				{
					int num = instance.LocationIndex(text);
					if (num >= 0 && num < Sprites.Count && (Object)Sprites[num] != (Object)null)
					{
						__result = Sprites[num];
					}
				}
			}
			catch (Exception e)
			{
				WarnOnce("GetLocationIcon", e);
			}
		}
	}

	[HarmonyPatch]
	private class Add
	{
		private static MethodBase TargetMethod()
		{
			if (!(MapType != null))
			{
				return null;
			}
			return AccessTools.Method(MapType, "AddPin", (Type[])null, (Type[])null);
		}

		private static void Prefix(object __instance)
		{
			try
			{
				Extend(__instance);
			}
			catch (Exception e)
			{
				WarnOnce("AddPin", e);
			}
		}

		private static void Postfix(object __instance, object __result)
		{
			try
			{
				if (__result != null)
				{
					ApplyBoss(__result);
					ApplyCoopPlayerPin(__result);
					Image image = GetImage(Get(__result, "m_iconElement"));
					if (IsPlayerPlacedShipPin(__result))
					{
						ForceScale(image, 2.5f);
					}
					else if (!IsCoopPlayerPin(__result) && !IsVanillaPingPin(__result))
					{
						ScaleIcon(image);
					}
				}
			}
			catch (Exception e)
			{
				WarnOnce("AddPinPostfix", e);
			}
		}
	}

	[HarmonyPatch]
	private class MapClicks
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			if (MapType == null)
			{
				yield break;
			}
			string[] array = new string[5] { "OnMapDblClick", "OnMapLeftDown", "OnMapLeftClick", "OnMapMiddleClick", "RemovePinUnderPointer" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				MethodBase methodBase = AccessTools.Method(MapType, text, (Type[])null, (Type[])null);
				if (methodBase != null)
				{
					yield return methodBase;
				}
			}
		}

		private static bool Prefix()
		{
			try
			{
				return !PointerBlocked();
			}
			catch
			{
				return true;
			}
		}
	}

	private const float IconScale = 1.25f;

	private const float ShipPinScale = 2f;

	private const float PlayerScale = 0.765f;

	internal static PerfectMapIcons Instance;

	internal static readonly Dictionary<int, Sprite> Custom;

	private static readonly List<Sprite> Sprites;

	private static readonly int[] Manual;

	private static readonly HashSet<int> Removed;

	private static readonly HashSet<Image> ScaledIcons;

	private static readonly HashSet<Image> ReducedLargeShipMarkers;

	private static readonly Dictionary<Image, Vector2> PlacedShipPinBaseSizes;

	private static readonly Dictionary<Image, Vector2> MinimapPinBaseSizes;

	private static readonly string[] ShipFields;

	private static readonly string[] PlayerFields;

	private static TMP_FontAsset UIFont;

	private static Sprite PlayerSprite;

	private static Sprite PlayerShipSprite;

	private static Sprite CoopPlayerSprite;

	private static readonly List<Texture2D> Textures;

	private static readonly string[] Names;

	private static readonly Dictionary<string, int> Types;

	internal static Type MapType;

	private static Type pinType;

	private Harmony harmony;

	private GameObject panel;

	private RectTransform panelRect;

	private Canvas panelCanvas;

	private TMP_Text status;

	private ConfigEntry<string> locationOverrides;

	private readonly HashSet<string> reported = new HashSet<string>();

	private readonly Dictionary<string, int> overrides = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

	private readonly Dictionary<string, int> locationMemo = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);

	private static readonly Dictionary<string, int> BossMemo;

	private static readonly Dictionary<int, Sprite> ById;

	private static readonly Dictionary<Type, Dictionary<string, FieldInfo>> FieldCache;

	private static readonly Dictionary<RectTransform, Vector2> BasePos;

	private static readonly HashSet<string> Warned;

	private static readonly string[][] BossAliases;

	private static bool locReady;

	private static string[] LocTokens;

	private static object bossPinType;

	private object currentMap;

	private Coroutine shipWatch;

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

	private static Type UIInputHandlerType;

	private static MethodInfo SelectIconMethod;

	private static Type PinType
	{
		get
		{
			if (pinType == null && MapType != null)
			{
				pinType = MapType.GetNestedType("PinType", BindingFlags.Public | BindingFlags.NonPublic);
			}
			return pinType;
		}
	}

	private static void ScaleIcon(Image img)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_0043: Expected O, but got Unknown
		if (!((Object)img == (Object)null))
		{
			float scale = 1.25f;
			if (Sprites.Count > 27 && (Object)img.sprite == (Object)Sprites[27])
			{
				scale = 2.5f;
			}
			ForceScale(img, scale);
		}
	}

	private static FieldInfo FieldOf(Type t, string n)
	{
		if (!FieldCache.TryGetValue(t, out var value))
		{
			value = new Dictionary<string, FieldInfo>();
			FieldCache[t] = value;
		}
		if (!value.TryGetValue(n, out var value2))
		{
			return value[n] = AccessTools.Field(t, n);
		}
		return value2;
	}

	internal static object Get(object o, string n)
	{
		if (o == null)
		{
			return null;
		}
		FieldInfo fieldInfo = FieldOf(o.GetType(), n);
		if (!(fieldInfo == null))
		{
			return fieldInfo.GetValue(o);
		}
		return null;
	}

	internal static void Set(object o, string n, object v)
	{
		if (o != null)
		{
			FieldInfo fieldInfo = FieldOf(o.GetType(), n);
			if (fieldInfo != null)
			{
				fieldInfo.SetValue(o, v);
			}
		}
	}

	private static void WarnOnce(string where, Exception e)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		if (!((Object)Instance == (Object)null) && Warned.Add(where))
		{
			((BaseUnityPlugin)Instance).Logger.LogError((object)(where + ": " + e));
		}
	}

	private void Awake()
	{
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		Instance = this;
		try
		{
			if (MapType == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"PerfectMapIcons: type Minimap not found, plugin disabled.");
				((Behaviour)this).enabled = false;
				return;
			}
			locationOverrides = ((BaseUnityPlugin)this).Config.Bind<string>("Icons", "LocationOverrides", "", "Exact location name=atlas index (0..30), separated by semicolons. Unknown locations use the runestone and are logged.");
			locationOverrides.SettingChanged += OnOverridesChanged;
			LoadAtlas("map-atlas.png", 5, 5);
			LoadAtlas("extra-atlas.png", 3, 2);
			LoadNewArtwork();
			for (int i = 0; i < 31; i++)
			{
				Custom[100 + i] = (Removed.Contains(i) ? Sprites[3] : Sprites[i]);
			}
			BuildSpriteIndex();
			ParseOverrides();
			harmony = new Harmony("PerfectMapIcons");
			harmony.PatchAll(typeof(PerfectMapIcons).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PerfectMapIcons 1.5.0 loaded: minimap pins enlarged by 5 px; vanilla Ping and world-spawn markers excluded; ship watcher throttled.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
			try
			{
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
				harmony = null;
			}
			catch
			{
			}
			((Behaviour)this).enabled = false;
		}
	}

	private void OnOverridesChanged(object sender, EventArgs e)
	{
		ParseOverrides();
	}

	private void ParseOverrides()
	{
		overrides.Clear();
		locationMemo.Clear();
		try
		{
			string[] array = locationOverrides.Value.Split(';');
			foreach (string text in array)
			{
				if (text.Length == 0)
				{
					continue;
				}
				string[] array2 = text.Split('=');
				if (array2.Length == 2)
				{
					string text2 = array2[0].Trim();
					if (text2.Length != 0 && int.TryParse(array2[1].Trim(), out var result) && result >= 0 && result < Sprites.Count && !Removed.Contains(result))
					{
						overrides[text2] = result;
					}
				}
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("LocationOverrides parse failed: " + ex.Message));
		}
	}

	private static void BuildSpriteIndex()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Expected O, but got Unknown
		ById.Clear();
		for (int i = 0; i < 31; i++)
		{
			if (Custom.TryGetValue(100 + i, out var value) && (Object)value != (Object)null)
			{
				ById[100 + i] = value;
			}
		}
		if (!(PinType != null))
		{
			return;
		}
		foreach (KeyValuePair<string, int> type in Types)
		{
			try
			{
				int key = Convert.ToInt32(Enum.Parse(PinType, type.Key));
				Sprite val = Sprites[type.Value];
				if ((Object)val != (Object)null)
				{
					ById[key] = val;
				}
			}
			catch
			{
			}
		}
	}

	private static void LoadAtlas(string path, int cols, int rows)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
		byte[] array = ReadBytes(path);
		if (!ImageConversion.LoadImage(val, array))
		{
			throw new IOException("Cannot load " + path);
		}
		((Texture)val).filterMode = (FilterMode)1;
		((Texture)val).wrapMode = (TextureWrapMode)1;
		Textures.Add(val);
		int[] array2 = ((cols == 5) ? new int[6] { 0, 276, 499, 745, 988, 1254 } : new int[4] { 0, 512, 1024, 1536 });
		int[] array3 = ((rows == 5) ? new int[6] { 0, 261, 506, 741, 989, 1254 } : new int[3] { 0, 512, 1024 });
		for (int i = 0; i < rows; i++)
		{
			for (int j = 0; j < cols; j++)
			{
				if (Removed.Contains(Sprites.Count))
				{
					Sprites.Add(null);
					continue;
				}
				int num = array2[j];
				int num2 = array2[j + 1];
				int num3 = array3[i];
				int num4 = array3[i + 1];
				Sprite val2 = Sprite.Create(val, new Rect((float)num, (float)(((Texture)val).height - num4), (float)(num2 - num), (float)(num4 - num3)), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
				((Object)val2).name = "PerfectMapIcons_" + Sprites.Count;
				Sprites.Add(val2);
			}
		}
		val.Apply(false, true);
	}

	internal static void Extend(object map)
	{
		if (map != null && Get(map, "m_visibleIconTypes") is bool[] array && array.Length < 131)
		{
			bool[] array2 = new bool[131];
			Array.Copy(array, array2, array.Length);
			for (int i = array.Length; i < array2.Length; i++)
			{
				array2[i] = true;
			}
			Set(map, "m_visibleIconTypes", array2);
		}
	}

	private static byte[] ReadBytes(string file)
	{
		using Stream stream = typeof(PerfectMapIcons).Assembly.GetManifestResourceStream("PerfectMapIcons.Assets." + file);
		if (stream == null)
		{
			throw new IOException("Missing embedded asset: " + file);
		}
		byte[] array = new byte[stream.Length];
		int num;
		for (int i = 0; i < array.Length; i += num)
		{
			num = stream.Read(array, i, array.Length - i);
			if (num <= 0)
			{
				break;
			}
		}
		return array;
	}

	private static Texture2D ReadTexture(string file)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Expected O, but got Unknown
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
		if (!ImageConversion.LoadImage(val, ReadBytes(file)))
		{
			throw new IOException(file);
		}
		((Texture)val).filterMode = (FilterMode)1;
		((Texture)val).wrapMode = (TextureWrapMode)1;
		Textures.Add(val);
		return val;
	}

	private static void Release(Texture2D t)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		if (!((Object)t == (Object)null))
		{
			Textures.Remove(t);
			Object.Destroy((Object)t);
		}
	}

	private static Sprite MakeSprite(Texture2D t, Rect rect, string name)
	{
		//IL_0001: 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)
		Sprite obj = Sprite.Create(t, rect, new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
		((Object)obj).name = name;
		return obj;
	}

	private static void LoadNewArtwork()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: 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_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Expected O, but got Unknown
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Expected O, but got Unknown
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Expected O, but got Unknown
		Texture2D val = ReadTexture("ship.png");
		int num = Math.Max(((Texture)val).width, ((Texture)val).height);
		Texture2D val2 = new Texture2D(num, num, (TextureFormat)4, false);
		Color32[] array = (Color32[])(object)new Color32[num * num];
		Color32[] pixels = val.GetPixels32();
		int num2 = (num - ((Texture)val).width) / 2;
		int num3 = (num - ((Texture)val).height) / 2;
		for (int i = 0; i < ((Texture)val).height; i++)
		{
			Array.Copy(pixels, i * ((Texture)val).width, array, (num3 + i) * num + num2, ((Texture)val).width);
		}
		val2.SetPixels32(array);
		val2.Apply();
		((Texture)val2).filterMode = (FilterMode)1;
		((Texture)val2).wrapMode = (TextureWrapMode)1;
		Textures.Add(val2);
		PlayerShipSprite = MakeSprite(val2, new Rect(0f, 0f, (float)num, (float)num), "PMI_PlayerShipMarker");
		val2.Apply(false, true);
		Release(val);
		Texture2D val3 = ReadTexture("player.png");
		PlayerSprite = MakeSprite(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), "PMI_Player");
		val3.Apply(false, true);
		Texture2D val4 = ReadTexture("player2.png");
		CoopPlayerSprite = MakeSprite(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), "PMI_CoopPlayer");
		val4.Apply(false, true);
		Texture2D val5 = ReadTexture("bosses-portal-forge.png");
		Color32[] pixels2 = val5.GetPixels32();
		int[,] array2 = new int[10, 4]
		{
			{ 39, 32, 395, 373 },
			{ 484, 45, 694, 390 },
			{ 792, 21, 1191, 389 },
			{ 1210, 30, 1555, 389 },
			{ 1594, 98, 1947, 370 },
			{ 8, 411, 426, 767 },
			{ 496, 398, 731, 770 },
			{ 822, 406, 1160, 765 },
			{ 1222, 412, 1525, 768 },
			{ 1573, 397, 1965, 780 }
		};
		for (int j = 0; j < 10; j++)
		{
			int num4 = array2[j, 0] - 2;
			int num5 = array2[j, 1] - 2;
			int num6 = array2[j, 2] + 2;
			int num7 = array2[j, 3] + 2;
			int num8 = num6 - num4;
			int num9 = num7 - num5;
			int num10 = Math.Max(num8, num9) + 24;
			Color32[] array3 = (Color32[])(object)new Color32[num10 * num10];
			int num11 = (num10 - num8) / 2;
			int num12 = (num10 - num9) / 2;
			for (int k = 0; k < num9; k++)
			{
				Array.Copy(pixels2, (((Texture)val5).height - num7 + k) * ((Texture)val5).width + num4, array3, (num12 + k) * num10 + num11, num8);
			}
			Texture2D val6 = new Texture2D(num10, num10, (TextureFormat)4, false);
			val6.SetPixels32(array3);
			val6.Apply();
			((Texture)val6).filterMode = (FilterMode)1;
			((Texture)val6).wrapMode = (TextureWrapMode)1;
			Textures.Add(val6);
			Sprite val7 = MakeSprite(val6, new Rect(0f, 0f, (float)num10, (float)num10), "PMI_New_" + j);
			val6.Apply(false, true);
			if (j == 0)
			{
				Object.Destroy((Object)Sprites[4]);
				Sprites[4] = val7;
			}
			else
			{
				Sprites.Add(val7);
			}
		}
		Release(val5);
		Texture2D val8 = ReadTexture("portal.png");
		Sprite value = MakeSprite(val8, new Rect(0f, 0f, (float)((Texture)val8).width, (float)((Texture)val8).height), "PMI_Portal_Custom");
		if (Sprites.Count > 4 && (Object)(object)Sprites[4] != (Object)null)
		{
			Object.Destroy((Object)Sprites[4]);
			Sprites[4] = value;
		}
		val8.Apply(false, true);
	}

	private static void InitLocalization()
	{
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Expected O, but got Unknown
		if (locReady)
		{
			return;
		}
		locReady = true;
		try
		{
			Type type = AccessTools.TypeByName("Localization");
			if (type == null)
			{
				return;
			}
			PropertyInfo propertyInfo = AccessTools.Property(type, "instance");
			if (propertyInfo == null)
			{
				return;
			}
			object value = propertyInfo.GetValue(null, null);
			if (value == null)
			{
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(type, "Localize", new Type[1] { typeof(string) }, (Type[])null);
			if (!(methodInfo == null))
			{
				string[] array = new string[8] { "$enemy_eikthyr", "$enemy_gdking", "$enemy_bonemass", "$enemy_dragon", "$enemy_goblinking", "$enemy_seekerqueen", "$enemy_fader", "$enemy_frozenking" };
				string[] array2 = new string[array.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array2[i] = methodInfo.Invoke(value, new object[1] { array[i] }) as string;
				}
				LocTokens = array2;
			}
		}
		catch (Exception ex)
		{
			if ((Object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Localization lookup failed: " + ex.Message));
			}
		}
	}

	private static int BossIndex(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			return -1;
		}
		if (BossMemo.TryGetValue(name, out var value))
		{
			return value;
		}
		int num = -1;
		string text = name.ToLowerInvariant();
		for (int i = 0; i < BossAliases.Length; i++)
		{
			if (num >= 0)
			{
				break;
			}
			string[] array = BossAliases[i];
			foreach (string value2 in array)
			{
				if (text.Contains(value2))
				{
					num = 8;
					break;
				}
			}
		}
		if (num < 0)
		{
			InitLocalization();
			if (LocTokens != null)
			{
				for (int k = 0; k < LocTokens.Length; k++)
				{
					if (string.Equals(name, LocTokens[k], StringComparison.OrdinalIgnoreCase))
					{
						num = 8;
						break;
					}
				}
			}
		}
		BossMemo[name] = num;
		return num;
	}

	private static bool IsBossPin(object pin)
	{
		if (pin == null || PinType == null)
		{
			return false;
		}
		if (bossPinType == null)
		{
			try
			{
				bossPinType = Enum.Parse(PinType, "Boss");
			}
			catch
			{
				return false;
			}
		}
		object obj2 = Get(pin, "m_type");
		if (obj2 != null)
		{
			return bossPinType.Equals(obj2);
		}
		return false;
	}

	private static bool IsPlayerPlacedShipPin(object pin)
	{
		if (pin == null)
		{
			return false;
		}
		object obj = Get(pin, "m_type");
		if (obj != null)
		{
			try
			{
				int num = Convert.ToInt32(obj);
				if (num == 127 || num == 27)
				{
					return true;
				}
			}
			catch
			{
			}
		}
		object obj3 = Get(pin, "m_icon");
		Sprite val = (Sprite)((obj3 is Sprite) ? obj3 : null);
		if ((Object)(object)val != (Object)null && Sprites.Count > 27 && (Object)(object)val == (Object)(object)Sprites[27])
		{
			return true;
		}
		Image image = GetImage(Get(pin, "m_iconElement"));
		if ((Object)(object)image != (Object)null && Sprites.Count > 27)
		{
			return (Object)(object)image.sprite == (Object)(object)Sprites[27];
		}
		return false;
	}

	private static bool IsVanillaPingPin(object pin)
	{
		if (pin == null)
		{
			return false;
		}
		object obj = Get(pin, "m_type");
		if (obj == null)
		{
			return false;
		}
		return string.Equals(obj.ToString(), "Ping", StringComparison.OrdinalIgnoreCase);
	}

	private static bool IsCoopPlayerPin(object pin)
	{
		if (pin == null)
		{
			return false;
		}
		object obj = Get(pin, "m_type");
		if (obj != null)
		{
			return string.Equals(obj.ToString(), "Player", StringComparison.OrdinalIgnoreCase);
		}
		return false;
	}

	private static void ApplyCoopPlayerPin(object pin)
	{
		if (IsCoopPlayerPin(pin) && !((Object)(object)CoopPlayerSprite == (Object)null))
		{
			Set(pin, "m_icon", CoopPlayerSprite);
			Image image = GetImage(Get(pin, "m_iconElement"));
			if ((Object)(object)image != (Object)null && (Object)(object)image.sprite != (Object)(object)CoopPlayerSprite)
			{
				image.sprite = CoopPlayerSprite;
			}
			if ((Object)(object)image != (Object)null)
			{
				ScaleIcon(image);
			}
		}
	}

	private static void ApplyPublicPositionIcon(object map)
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Expected O, but got Unknown
		if (map == null || (Object)(object)CoopPlayerSprite == (Object)null)
		{
			return;
		}
		object obj = Get(map, "m_publicPosition");
		Component val = (Component)((obj is Component) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Image[] componentsInChildren = val.GetComponentsInChildren<Image>(true);
		Image val2 = null;
		Image[] array = componentsInChildren;
		foreach (Image val3 in array)
		{
			if (!((Object)(object)val3 == (Object)null) && (((Object)((Component)val3).gameObject).name ?? string.Empty).IndexOf("icon", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				val2 = val3;
				break;
			}
		}
		if ((Object)(object)val2 == (Object)null && componentsInChildren.Length > 1)
		{
			val2 = componentsInChildren[^1];
		}
		if ((Object)(object)val2 == (Object)null && obj is Image)
		{
			val2 = (Image)obj;
		}
		if ((Object)(object)val2 != (Object)null)
		{
			val2.sprite = CoopPlayerSprite;
		}
	}

	private static void ApplyBoss(object pin)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_0072: 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_0082: Expected O, but got Unknown
		//IL_0082: Expected O, but got Unknown
		if (!IsBossPin(pin))
		{
			return;
		}
		int num = BossIndex(Get(pin, "m_name") as string);
		Sprite val = Sprites[(num >= 0) ? num : 8];
		if ((Object)val == (Object)null)
		{
			return;
		}
		Set(pin, "m_icon", val);
		Image image = GetImage(Get(pin, "m_iconElement"));
		if ((Object)image != (Object)null)
		{
			if ((Object)image.sprite != (Object)val)
			{
				image.sprite = val;
			}
			ScaleIcon(image);
		}
	}

	private static void RefreshBossPins(object map)
	{
		if (Get(map, "m_pins") is IList list)
		{
			for (int i = 0; i < list.Count; i++)
			{
				ApplyBoss(list[i]);
			}
		}
	}

	internal void Setup(object map)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		if (map == null)
		{
			return;
		}
		if (map == currentMap && (Object)panel != (Object)null)
		{
			ApplyShipPins(map);
			return;
		}
		try
		{
			SetupCore(map);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("PerfectMapIcons setup failed: " + ex));
			WarnOnce("Setup", ex);
		}
	}

	private void SetupCore(object map)
	{
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Expected O, but got Unknown
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Expected O, but got Unknown
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Expected O, but got Unknown
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Expected O, but got Unknown
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Expected O, but got Unknown
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Expected O, but got Unknown
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Expected O, but got Unknown
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Expected O, but got Unknown
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Expected O, but got Unknown
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Expected O, but got Unknown
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Expected O, but got Unknown
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Expected O, but got Unknown
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Expected O, but got Unknown
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Expected O, but got Unknown
		//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Expected O, but got Unknown
		//IL_0406: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Expected O, but got Unknown
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_0508: Unknown result type (might be due to invalid IL or missing references)
		//IL_050f: Expected O, but got Unknown
		//IL_0511: Unknown result type (might be due to invalid IL or missing references)
		//IL_051c: Expected O, but got Unknown
		//IL_0525: Unknown result type (might be due to invalid IL or missing references)
		//IL_0530: Expected O, but got Unknown
		MinimapPinBaseSizes.Clear();
		PlacedShipPinBaseSizes.Clear();
		Extend(map);
		Dictionary<Sprite, Sprite> dictionary = new Dictionary<Sprite, Sprite>();
		IList list = Get(map, "m_icons") as IList;
		if (list != null)
		{
			for (int i = 0; i < list.Count; i++)
			{
				object obj = list[i];
				object obj2 = Get(obj, "m_name");
				if (obj2 != null && Types.TryGetValue(obj2.ToString(), out var value))
				{
					object obj3 = Get(obj, "m_icon");
					Sprite val = (Sprite)((obj3 is Sprite) ? obj3 : null);
					if ((Object)val != (Object)null)
					{
						dictionary[val] = Sprites[value];
					}
					Set(obj, "m_icon", Sprites[value]);
					list[i] = obj;
				}
			}
		}
		IList list2 = Get(map, "m_locationIcons") as IList;
		if (list2 != null)
		{
			for (int j = 0; j < list2.Count; j++)
			{
				object obj4 = list2[j];
				string name = Get(obj4, "m_name") as string;
				object obj5 = Get(obj4, "m_icon");
				Sprite val2 = (Sprite)((obj5 is Sprite) ? obj5 : null);
				Sprite val3 = Sprites[LocationIndex(name)];
				if ((Object)val3 == (Object)null)
				{
					val3 = Sprites[3];
				}
				if ((Object)val2 != (Object)null)
				{
					dictionary[val2] = val3;
				}
				Set(obj4, "m_icon", val3);
				list2[j] = obj4;
			}
		}
		Component val4 = (Component)((map is Component) ? map : null);
		if ((Object)val4 != (Object)null)
		{
			Image[] componentsInChildren = val4.GetComponentsInChildren<Image>(true);
			foreach (Image val5 in componentsInChildren)
			{
				if ((Object)val5.sprite != (Object)null && dictionary.TryGetValue(val5.sprite, out var value2))
				{
					val5.sprite = value2;
				}
			}
		}
		IList list3 = Get(map, "m_pins") as IList;
		if (list3 != null)
		{
			for (int l = 0; l < list3.Count; l++)
			{
				object o = list3[l];
				object obj6 = Get(o, "m_icon");
				Sprite val6 = (Sprite)((obj6 is Sprite) ? obj6 : null);
				if ((Object)val6 != (Object)null && dictionary.TryGetValue(val6, out var value3))
				{
					Set(o, "m_icon", value3);
					Image image = GetImage(Get(o, "m_iconElement"));
					if ((Object)image != (Object)null)
					{
						image.sprite = value3;
					}
				}
			}
		}
		object obj7 = Get(map, "m_pinPrefab");
		GameObject val7 = (GameObject)((obj7 is GameObject) ? obj7 : null);
		if ((Object)val7 != (Object)null)
		{
			Transform val8 = val7.transform.Find("Checked");
			if ((Object)val8 != (Object)null)
			{
				Image component = ((Component)val8).GetComponent<Image>();
				if ((Object)component != (Object)null)
				{
					component.sprite = Sprites[23];
				}
			}
		}
		string[] shipFields = ShipFields;
		foreach (string text in shipFields)
		{
			Image image2 = GetImage(Get(map, text));
			if ((Object)image2 != (Object)null)
			{
				image2.sprite = PlayerShipSprite;
				ForceScale(image2, (text == "m_largeShipMarker") ? 1.3541666f : 1.625f);
			}
		}
		shipFields = PlayerFields;
		foreach (string n in shipFields)
		{
			Image image3 = GetImage(Get(map, n));
			if ((Object)image3 != (Object)null && (Object)PlayerSprite != (Object)null)
			{
				image3.sprite = PlayerSprite;
				((Transform)((Graphic)image3).rectTransform).localScale = new Vector3(0.765f, 0.765f, 1f);
			}
		}
		currentMap = map;
		ApplyShipPins(map);
		if (shipWatch == null)
		{
			shipWatch = ((MonoBehaviour)this).StartCoroutine(ShipWatch());
		}
		if (list3 != null)
		{
			for (int m = 0; m < list3.Count; m++)
			{
				object obj8 = list3[m];
				ApplyCoopPlayerPin(obj8);
				if (!IsBossPin(obj8) && !IsCoopPlayerPin(obj8) && !IsVanillaPingPin(obj8))
				{
					Image image4 = GetImage(Get(obj8, "m_iconElement"));
					if (IsPlayerPlacedShipPin(obj8))
					{
						ForceScale(image4, 2.5f);
					}
					else
					{
						ScaleIcon(image4);
					}
				}
			}
		}
		object obj9 = Get(map, "m_biomeNameLarge");
		TMP_Text val9 = (TMP_Text)((obj9 is TMP_Text) ? obj9 : null);
		if ((Object)val9 != (Object)null && (Object)val9.font != (Object)null)
		{
			UIFont = val9.font;
		}
		if (list != null && list2 != null)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Applied icon replacements to " + list.Count + " pin entries and " + list2.Count + " location entries."));
		}
		RefreshBossPins(map);
		BuildUI(map);
	}

	private int LocationIndex(string name)
	{
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Expected O, but got Unknown
		if (string.IsNullOrEmpty(name))
		{
			return 21;
		}
		if (locationMemo.TryGetValue(name, out var value))
		{
			return value;
		}
		int num;
		if (overrides.TryGetValue(name, out value))
		{
			num = value;
		}
		else
		{
			string text = name.ToLowerInvariant();
			if (text.Contains("upgradestation"))
			{
				num = 31;
			}
			else
			{
				int num2 = BossIndex(name);
				if (num2 >= 0)
				{
					num = num2;
				}
				else if (text.Contains("hildir"))
				{
					num = (text.Contains("crypt") ? 13 : ((!text.Contains("cave")) ? (text.Contains("tower") ? 15 : 18) : 14));
				}
				else if (text.Contains("bogwitch") || text.Contains("witch"))
				{
					num = 19;
				}
				else if (text.Contains("vendor") || text.Contains("haldor") || text.Contains("trader"))
				{
					num = 17;
				}
				else if (text.Contains("start") || text.Contains("sacrific") || text.Contains("megalith"))
				{
					num = 20;
				}
				else if (text.Contains("boss") || text.Contains("eikthyr") || text.Contains("bonemass") || text.Contains("dragonqueen") || text.Contains("goblinking") || text.Contains("queen") || text.Contains("fader"))
				{
					num = 8;
				}
				else
				{
					if (reported.Add(name))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Location icon: " + name + " -> runestone (override in config if needed)"));
					}
					num = 21;
				}
			}
		}
		if (num < 0 || num >= Sprites.Count || (Object)Sprites[num] == (Object)null)
		{
			num = 21;
		}
		locationMemo[name] = num;
		return num;
	}

	private static RectTransform RectNode(string name, Transform parent, Vector2 position, Vector2 size)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		RectTransform component = new GameObject(name, new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
		((Transform)component).SetParent(parent, false);
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0f, 1f);
		component.pivot = val;
		Vector2 val2 = val;
		val = (component.anchorMax = val2);
		Vector2 anchorMin = val;
		component.anchorMin = anchorMin;
		component.anchoredPosition = position;
		component.sizeDelta = size;
		return component;
	}

	private static TMP_Text Label(Transform parent, string value, Vector2 pos, Vector2 size, int font)
	{
		//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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		TextMeshProUGUI val = ((Component)RectNode("Label", parent, pos, size)).gameObject.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)UIFont != (Object)null)
		{
			((TMP_Text)val).font = UIFont;
		}
		((TMP_Text)val).text = value;
		((TMP_Text)val).fontSize = font;
		((TMP_Text)val).alignment = (TextAlignmentOptions)514;
		((Graphic)val).color = Color.white;
		((Graphic)val).raycastTarget = false;
		return (TMP_Text)val;
	}

	private static void ForceScale(Image img, float scale)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)img == (Object)null))
		{
			RectTransform rectTransform = ((Graphic)img).rectTransform;
			Vector3 localScale = ((Transform)rectTransform).localScale;
			if (!(Mathf.Abs(localScale.x - scale) < 0.001f) || !(Mathf.Abs(localScale.y - scale) < 0.001f))
			{
				localScale.x = scale;
				localScale.y = scale;
				((Transform)rectTransform).localScale = localScale;
			}
		}
	}

	internal static Image GetImage(object o)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		if (o == null)
		{
			return null;
		}
		Component val = (Component)((o is Component) ? o : null);
		if ((Object)val != (Object)null)
		{
			return val.GetComponent<Image>();
		}
		GameObject val2 = (GameObject)((o is GameObject) ? o : null);
		if ((Object)val2 != (Object)null)
		{
			return val2.GetComponent<Image>();
		}
		return null;
	}

	private IEnumerator ShipWatch()
	{
		while (true)
		{
			if (currentMap != null)
			{
				ApplyShipPins(currentMap);
				RefreshPlacedShipPinSizes(currentMap);
			}
			yield return (object)new WaitForSecondsRealtime(0.25f);
		}
	}

	private static bool IsSmallMapMode(object map)
	{
		if (map == null)
		{
			return false;
		}
		object obj = Get(map, "m_mode");
		if (obj == null)
		{
			return false;
		}
		string text = obj.ToString();
		if (text.IndexOf("small", StringComparison.OrdinalIgnoreCase) < 0)
		{
			return text.IndexOf("mini", StringComparison.OrdinalIgnoreCase) >= 0;
		}
		return true;
	}

	private static bool IsWorldSpawnCirclePin(object pin)
	{
		if (pin == null)
		{
			return false;
		}
		object obj = Get(pin, "m_type");
		if (obj != null)
		{
			string text = obj.ToString();
			if (text.IndexOf("Spawn", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Start", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				return true;
			}
		}
		string text2 = Get(pin, "m_name") as string;
		if (!string.IsNullOrEmpty(text2))
		{
			if (text2.IndexOf("spawn", StringComparison.OrdinalIgnoreCase) < 0)
			{
				return text2.IndexOf("start", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return true;
		}
		return false;
	}

	private static void RefreshPlacedShipPinSizes(object map)
	{
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (!(Get(map, "m_pins") is IList list))
		{
			return;
		}
		bool flag = IsSmallMapMode(map);
		Vector2 val = default(Vector2);
		Vector2 val3 = default(Vector2);
		foreach (object item in list)
		{
			if (IsVanillaPingPin(item) || IsWorldSpawnCirclePin(item))
			{
				continue;
			}
			Image image = GetImage(Get(item, "m_iconElement"));
			if ((Object)(object)image == (Object)null)
			{
				continue;
			}
			RectTransform rectTransform = ((Graphic)image).rectTransform;
			if (!MinimapPinBaseSizes.TryGetValue(image, out var value))
			{
				value = rectTransform.sizeDelta;
				MinimapPinBaseSizes[image] = value;
			}
			Vector2 val2;
			if (IsPlayerPlacedShipPin(item))
			{
				float num = (flag ? 7f : 2f);
				((Vector2)(ref val))..ctor(Mathf.Max(1f, value.x + num), Mathf.Max(1f, value.y + num));
				val2 = rectTransform.sizeDelta - val;
				if (((Vector2)(ref val2)).sqrMagnitude > 0.01f)
				{
					rectTransform.sizeDelta = val;
				}
			}
			else if (flag && !IsWorldSpawnCirclePin(item))
			{
				((Vector2)(ref val3))..ctor(Mathf.Max(1f, value.x + 5f), Mathf.Max(1f, value.y + 5f));
				val2 = rectTransform.sizeDelta - val3;
				if (((Vector2)(ref val2)).sqrMagnitude > 0.01f)
				{
					rectTransform.sizeDelta = val3;
				}
			}
		}
	}

	private static void ApplyPlacedShipPinScales(object map)
	{
		if (!(Get(map, "m_pins") is IList list))
		{
			return;
		}
		for (int i = 0; i < list.Count; i++)
		{
			object obj = list[i];
			if (IsPlayerPlacedShipPin(obj))
			{
				Image image = GetImage(Get(obj, "m_iconElement"));
				if ((Object)(object)image != (Object)null)
				{
					ForceScale(image, 2.5f);
				}
			}
		}
	}

	internal void ApplyShipPins(object map)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: 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)
		if (map == null || (Object)(object)PlayerShipSprite == (Object)null || !Object.op_Implicit((Object)((map is Component) ? map : null)))
		{
			return;
		}
		Image image = GetImage(Get(map, "m_smallShipMarker"));
		if ((Object)(object)image != (Object)null)
		{
			if ((Object)(object)image.sprite != (Object)(object)PlayerShipSprite)
			{
				image.sprite = PlayerShipSprite;
			}
			ForceScale(image, 1.625f);
		}
		Image image2 = GetImage(Get(map, "m_largeShipMarker"));
		if ((Object)(object)image2 != (Object)null)
		{
			if ((Object)(object)image2.sprite != (Object)(object)PlayerShipSprite)
			{
				image2.sprite = PlayerShipSprite;
			}
			ForceScale(image2, 1.3541666f);
			if (ReducedLargeShipMarkers.Add(image2))
			{
				RectTransform rectTransform = ((Graphic)image2).rectTransform;
				Vector2 sizeDelta = rectTransform.sizeDelta;
				sizeDelta.x = Mathf.Max(1f, sizeDelta.x - 25f);
				sizeDelta.y = Mathf.Max(1f, sizeDelta.y - 25f);
				rectTransform.sizeDelta = sizeDelta;
			}
		}
	}

	private static void ShiftX(RectTransform rt, float fraction)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0031: 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_0045: 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_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_002a: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)rt == (Object)null))
		{
			if (!BasePos.TryGetValue(rt, out var value))
			{
				value = rt.anchoredPosition;
				BasePos[rt] = value;
			}
			rt.anchoredPosition = new Vector2(value.x + rt.sizeDelta.x * fraction, value.y);
		}
	}

	private static void ScaleY(RectTransform rt, float factor)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: 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_002a: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)rt == (Object)null))
		{
			if (!BasePos.TryGetValue(rt, out var value))
			{
				value = rt.anchoredPosition;
				BasePos[rt] = value;
			}
			rt.anchoredPosition = new Vector2(value.x, value.y * factor);
		}
	}

	private void BuildUI(object map)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Expected O, but got Unknown
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00c4: Expected O, but got Unknown
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Expected O, but got Unknown
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Expected O, but got Unknown
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Expected O, but got Unknown
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Expected O, but got Unknown
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Expected O, but got Unknown
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Expected O, but got Unknown
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Expected O, but got Unknown
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Expected O, but got Unknown
		//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f0: Expected O, but got Unknown
		//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fd: Expected O, but got Unknown
		//IL_0512: Unknown result type (might be due to invalid IL or missing references)
		//IL_051d: Expected O, but got Unknown
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Expected O, but got Unknown
		//IL_0385: 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_039c: Expected O, but got Unknown
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0645: Expected O, but got Unknown
		//IL_0647: Unknown result type (might be due to invalid IL or missing references)
		//IL_0652: Expected O, but got Unknown
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Expected O, but got Unknown
		//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ae: Expected O, but got Unknown
		//IL_0660: Unknown result type (might be due to invalid IL or missing references)
		//IL_066b: Expected O, but got Unknown
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Expected O, but got Unknown
		//IL_0707: Unknown result type (might be due to invalid IL or missing references)
		//IL_0720: Unknown result type (might be due to invalid IL or missing references)
		//IL_0734: Unknown result type (might be due to invalid IL or missing references)
		//IL_0743: Unknown result type (might be due to invalid IL or missing references)
		//IL_074f: Expected O, but got Unknown
		//IL_0771: Unknown result type (might be due to invalid IL or missing references)
		//IL_0778: Unknown result type (might be due to invalid IL or missing references)
		//IL_077a: Unknown result type (might be due to invalid IL or missing references)
		//IL_077c: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cb: Expected O, but got Unknown
		//IL_0539: Unknown result type (might be due to invalid IL or missing references)
		//IL_0540: Expected O, but got Unknown
		//IL_0542: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Expected O, but got Unknown
		//IL_0569: Unknown result type (might be due to invalid IL or missing references)
		//IL_0574: Expected O, but got Unknown
		//IL_0551: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Expected O, but got Unknown
		//IL_0799: Unknown result type (might be due to invalid IL or missing references)
		//IL_079e: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0803: Unknown result type (might be due to invalid IL or missing references)
		//IL_0816: Unknown result type (might be due to invalid IL or missing references)
		//IL_081b: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f8: Expected O, but got Unknown
		//IL_0689: Unknown result type (might be due to invalid IL or missing references)
		//IL_0698: Expected O, but got Unknown
		//IL_0584: Unknown result type (might be due to invalid IL or missing references)
		//IL_058f: Expected O, but got Unknown
		//IL_042c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_043d: Expected O, but got Unknown
		//IL_043d: Expected O, but got Unknown
		//IL_06db: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ea: Expected O, but got Unknown
		//IL_083a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0844: Expected O, but got Unknown
		//IL_05b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b7: Expected O, but got Unknown
		//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c4: Expected O, but got Unknown
		//IL_0459: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Expected O, but got Unknown
		//IL_0908: Unknown result type (might be due to invalid IL or missing references)
		//IL_090f: Expected O, but got Unknown
		//IL_0911: Unknown result type (might be due to invalid IL or missing references)
		//IL_091c: Expected O, but got Unknown
		//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dd: Expected O, but got Unknown
		//IL_046d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0474: Unknown result type (might be due to invalid IL or missing references)
		//IL_047e: Expected O, but got Unknown
		//IL_047e: Expected O, but got Unknown
		//IL_0861: Unknown result type (might be due to invalid IL or missing references)
		//IL_086b: Expected O, but got Unknown
		//IL_0920: Unknown result type (might be due to invalid IL or missing references)
		//IL_0925: Unknown result type (might be due to invalid IL or missing references)
		//IL_0935: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ff: Expected O, but got Unknown
		//IL_0882: Unknown result type (might be due to invalid IL or missing references)
		//IL_088c: Expected O, but got Unknown
		//IL_08af: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b9: Expected O, but got Unknown
		//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
		object obj = Get(map, "m_selectedIcon0");
		Image val = (Image)((obj is Image) ? obj : null);
		if ((Object)val == (Object)null || (Object)((Component)val).transform.parent == (Object)null)
		{
			return;
		}
		Button component = ((Component)((Component)val).transform.parent).GetComponent<Button>();
		if ((Object)component == (Object)null)
		{
			return;
		}
		Transform parent = ((Component)component).transform.parent;
		RectTransform val2 = (RectTransform)((parent is RectTransform) ? parent : null);
		if ((Object)val2 == (Object)null || (Object)panel == (Object)((Component)val2).gameObject)
		{
			return;
		}
		panel = ((Component)val2).gameObject;
		panelRect = val2;
		panelCanvas = ((Component)val2).GetComponentInParent<Canvas>();
		if ((Object)status != (Object)null)
		{
			Object.Destroy((Object)((Component)status).gameObject);
			status = null;
		}
		Vector2 val3 = default(Vector2);
		((Vector2)(ref val3))..ctor(1f, 0f);
		val2.anchorMax = val3;
		Vector2 anchorMin = val3;
		val2.anchorMin = anchorMin;
		val2.pivot = new Vector2(1f, 0f);
		val2.anchoredPosition = new Vector2(-9f, 14f);
		List<Button> list = new List<Button>();
		for (int i = 0; i < 5; i++)
		{
			object obj2 = Get(map, "m_selectedIcon" + i);
			Image val4 = (Image)((obj2 is Image) ? obj2 : null);
			if ((Object)val4 == (Object)null || (Object)((Component)val4).transform.parent == (Object)null)
			{
				return;
			}
			Button component2 = ((Component)((Component)val4).transform.parent).GetComponent<Button>();
			if ((Object)component2 == (Object)null)
			{
				return;
			}
			list.Add(component2);
		}
		IDictionary dictionary = Get(map, "m_selectedIcons") as IDictionary;
		Sprite val5 = (((Object)((Component)component).GetComponent<Image>() != (Object)null) ? ((Component)component).GetComponent<Image>().sprite : null);
		if (UIInputHandlerType == null)
		{
			UIInputHandlerType = AccessTools.TypeByName("UIInputHandler");
		}
		if (SelectIconMethod == null)
		{
			SelectIconMethod = AccessTools.Method(MapType, "SelectIcon", (Type[])null, (Type[])null);
		}
		for (int j = 5; j < Manual.Length; j++)
		{
			int num = Manual[j];
			int value = 100 + num;
			GameObject val6 = Object.Instantiate<GameObject>(((Component)component).gameObject, (Transform)val2, false);
			((Object)val6).name = "PerfectMapIcons_" + Names[num];
			extraButtons.Add(val6);
			Button component3 = val6.GetComponent<Button>();
			if ((Object)component3 == (Object)null)
			{
				Object.Destroy((Object)val6);
				extraButtons.Remove(val6);
				continue;
			}
			object pinId = Enum.ToObject(PinType, value);
			((UnityEventBase)component3.onClick).RemoveAllListeners();
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				try
				{
					if (SelectIconMethod != null)
					{
						SelectIconMethod.Invoke(map, new object[1] { pinId });
					}
				}
				catch (Exception ex)
				{
					if ((Object)Instance != (Object)null)
					{
						((BaseUnityPlugin)Instance).Logger.LogError((object)ex);
					}
				}
			});
			Component val7 = ((UIInputHandlerType != null) ? val6.GetComponent(UIInputHandlerType) : null);
			if ((Object)(object)val7 != (Object)null)
			{
				((Behaviour)val7).enabled = false;
				Object.Destroy((Object)val7);
			}
			Transform val8 = val6.transform.Find("Selected");
			Image val9 = (((Object)val8 != (Object)null) ? ((Component)val8).GetComponent<Image>() : null);
			if ((Object)val9 == (Object)null)
			{
				Object.Destroy((Object)val6);
				extraButtons.Remove(val6);
				continue;
			}
			((Behaviour)val9).enabled = false;
			if (dictionary != null)
			{
				dictionary[pinId] = val9;
			}
			Image[] componentsInChildren = val6.GetComponentsInChildren<Image>(true);
			foreach (Image val10 in componentsInChildren)
			{
				if (!((Object)val10 == (Object)val9) && !(((Object)((Component)val10).gameObject).name == "checked") && (Object)val5 != (Object)null && (Object)val10.sprite == (Object)val5)
				{
					val10.sprite = Sprites[num];
					val10.preserveAspect = true;
				}
			}
			list.Add(component3);
		}
		object obj3 = Get(map, "m_selectedIconDeath");
		Image val11 = (Image)((obj3 is Image) ? obj3 : null);
		if ((Object)val11 != (Object)null)
		{
			Transform parent2 = ((Component)val11).transform.parent;
			Transform val12 = (((Object)parent2 != (Object)null) ? parent2.parent : null);
			RectTransform val13 = (RectTransform)((val12 is RectTransform) ? val12 : null);
			if ((Object)val13 == (Object)null && (Object)val12 != (Object)null)
			{
				val13 = ((Component)val12).GetComponent<RectTransform>();
			}
			if ((Object)val13 != (Object)null)
			{
				ScaleY(val13, 1.3f);
			}
			_ = (Object)val12 != (Object)null;
			object obj4 = Get(map, "m_selectedIconBoss");
			Image val14 = (Image)((obj4 is Image) ? obj4 : null);
			if ((Object)val14 != (Object)null && (Object)((Component)val14).transform.parent != (Object)null)
			{
				Image component4 = ((Component)((Component)val14).transform.parent).GetComponent<Image>();
				if ((Object)component4 != (Object)null)
				{
					component4.sprite = Sprites[8];
				}
			}
		}
		object obj5 = Get(map, "m_publicPosition");
		ApplyPublicPositionIcon(map);
		Component val15 = (Component)((obj5 is Component) ? obj5 : null);
		if ((Object)val15 != (Object)null && (Object)val15.transform.parent != (Object)null)
		{
			Transform parent3 = val15.transform.parent;
			ShiftX((RectTransform)((parent3 is RectTransform) ? parent3 : null), -0.1f);
		}
		Transform parent4 = ((Transform)val2).parent;
		if ((Object)parent4 != (Object)null)
		{
			Transform val16 = parent4.Find("SharedPanel");
			if ((Object)val16 != (Object)null)
			{
				ShiftX((RectTransform)((val16 is RectTransform) ? val16 : null), -0.1f);
			}
		}
		int num3 = (list.Count + 1) / 2;
		val2.sizeDelta = new Vector2(120f, (float)(52 * num3 + 70));
		((Component)val2).transform.SetAsLastSibling();
		status = Label((Transform)val2, GetMarkersLabel(), new Vector2(-108f, -4f), new Vector2(104f, 22f), 15);
		RectTransform rectTransform = status.rectTransform;
		((Vector2)(ref val3))..ctor(1f, 1f);
		rectTransform.anchorMax = val3;
		Vector2 anchorMin2 = val3;
		rectTransform.anchorMin = anchorMin2;
		for (int num4 = 0; num4 < list.Count; num4++)
		{
			RectTransform val17 = (RectTransform)((Component)list[num4]).transform;
			((Vector2)(ref val3))..ctor(0f, 1f);
			val17.anchorMax = val3;
			Vector2 anchorMin3 = val3;
			val17.anchorMin = anchorMin3;
			val17.pivot = new Vector2(0.5f, 0.5f);
			val17.sizeDelta = new Vector2(48f, 48f);
			val17.anchoredPosition = new Vector2((float)(34 + num4 % 2 * 52), (float)(-52 - num4 / 2 * 52));
			Navigation navigation = ((Selectable)list[num4]).navigation;
			((Navigation)(ref navigation)).mode = (Mode)4;
			((Navigation)(ref navigation)).selectOnUp = (Selectable)((num4 >= 2) ? list[num4 - 2] : null);
			((Navigation)(ref navigation)).selectOnDown = (Selectable)((num4 + 2 < list.Count) ? list[num4 + 2] : null);
			((Navigation)(ref navigation)).selectOnLeft = (Selectable)((num4 % 2 == 1) ? list[num4 - 1] : null);
			((Navigation)(ref navigation)).selectOnRight = (Selectable)((num4 % 2 == 0 && num4 + 1 < list.Count) ? list[num4 + 1] : null);
			((Selectable)list[num4]).navigation = navigation;
		}
		Transform val18 = ((Transform)val2).Find("iconhints");
		if ((Object)val18 != (Object)null)
		{
			RectTransform val19 = (RectTransform)((val18 is RectTransform) ? val18 : null);
			if ((Object)val19 != (Object)null)
			{
				Vector2 anchoredPosition = val19.anchoredPosition;
				anchoredPosition.x = -24f;
				val19.anchoredPosition = anchoredPosition;
			}
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Right map toolbar ready: 14 placeable icons; Hildir towers are automatic only.");
	}

	private static string GetMarkersLabel()
	{
		try
		{
			Type type = AccessTools.TypeByName("Localization");
			if (type != null)
			{
				PropertyInfo propertyInfo = AccessTools.Property(type, "instance");
				object obj = ((propertyInfo != null) ? propertyInfo.GetValue(null, null) : null);
				if (obj != null)
				{
					MethodInfo methodInfo = AccessTools.Method(type, "GetSelectedLanguage", Type.EmptyTypes, (Type[])null);
					if (methodInfo == null)
					{
						methodInfo = AccessTools.Method(type, "GetLanguage", Type.EmptyTypes, (Type[])null);
					}
					string text = ((methodInfo != null) ? (methodInfo.Invoke(obj, null) as string) : null);
					if (!string.IsNullOrEmpty(text))
					{
						switch (text.ToLowerInvariant().Replace('-', '_'))
						{
						case "russian":
						case "русский":
							return "Метки";
						case "deutsch":
						case "german":
							return "Markierungen";
						case "french":
						case "français":
							return "Marqueurs";
						case "spanish":
						case "español":
							return "Marcadores";
						case "italian":
						case "italiano":
							return "Marcatori";
						case "polish":
						case "polski":
							return "Znaczniki";
						case "turkish":
						case "türkçe":
							return "İşaretler";
						case "japanese":
						case "日本語":
							return "マーカー";
						case "korean":
						case "한국어":
							return "표식";
						case "chinese":
						case "简体中文":
						case "繁體中文":
							return "标记";
						case "swedish":
						case "svenska":
						case "danish":
						case "norwegian":
						case "norsk":
						case "dansk":
							return "Markörer";
						case "finnish":
						case "suomi":
							return "Merkit";
						case "dutch":
						case "nederlands":
							return "Markeringen";
						case "čeština":
						case "czech":
							return "Značky";
						case "magyar":
						case "hungarian":
							return "Jelölők";
						case "ukrainian":
						case "українська":
							return "Мітки";
						default:
							return "Markers";
						}
					}
				}
			}
		}
		catch (Exception ex)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)("Markers localization failed: " + ex.Message));
			}
		}
		return "Markers";
	}

	internal static bool PointerBlocked()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		PerfectMapIcons instance = Instance;
		if ((Object)instance == (Object)null || (Object)instance.panel == (Object)null || !instance.panel.activeInHierarchy)
		{
			return false;
		}
		if ((Object)instance.panelRect == (Object)null)
		{
			instance.panelRect = instance.panel.GetComponent<RectTransform>();
		}
		if ((Object)instance.panelRect == (Object)null)
		{
			return false;
		}
		if ((Object)instance.panelCanvas == (Object)null)
		{
			instance.panelCanvas = instance.panel.GetComponentInParent<Canvas>();
		}
		Camera val = (((Object)instance.panelCanvas != (Object)null && (int)instance.panelCanvas.renderMode != 0) ? instance.panelCanvas.worldCamera : null);
		return RectTransformUtility.RectangleContainsScreenPoint(instance.panelRect, Vector2.op_Implicit(Input.mousePosition), val);
	}

	private void OnDestroy()
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Expected O, but got Unknown
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Expected O, but got Unknown
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Expected O, but got Unknown
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Expected O, but got Unknown
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Expected O, but got Unknown
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Expected O, but got Unknown
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Expected O, but got Unknown
		Instance = null;
		if (locationOverrides != null)
		{
			locationOverrides.SettingChanged -= OnOverridesChanged;
		}
		if (harmony != null)
		{
			try
			{
				harmony.UnpatchSelf();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)ex.Message);
			}
			harmony = null;
		}
		((MonoBehaviour)this).StopAllCoroutines();
		shipWatch = null;
		if ((Object)status != (Object)null)
		{
			Object.Destroy((Object)((Component)status).gameObject);
			status = null;
		}
		foreach (GameObject extraButton in extraButtons)
		{
			if ((Object)extraButton != (Object)null)
			{
				Object.Destroy((Object)extraButton);
			}
		}
		extraButtons.Clear();
		if ((Object)PlayerSprite != (Object)null)
		{
			Object.Destroy((Object)PlayerSprite);
			PlayerSprite = null;
		}
		if ((Object)CoopPlayerSprite != (Object)null)
		{
			Object.Destroy((Object)CoopPlayerSprite);
			CoopPlayerSprite = null;
		}
		foreach (Sprite sprite in Sprites)
		{
			if ((Object)sprite != (Object)null)
			{
				Object.Destroy((Object)sprite);
			}
		}
		foreach (Texture2D texture in Textures)
		{
			if ((Object)texture != (Object)null)
			{
				Object.Destroy((Object)texture);
			}
		}
		Sprites.Clear();
		Textures.Clear();
		Custom.Clear();
		ScaledIcons.Clear();
		ById.Clear();
		FieldCache.Clear();
		BasePos.Clear();
		BossMemo.Clear();
		locationMemo.Clear();
		overrides.Clear();
		reported.Clear();
		Warned.Clear();
		UIFont = null;
		panel = null;
		panelRect = null;
		panelCanvas = null;
		currentMap = null;
		bossPinType = null;
		LocTokens = null;
	}

	static PerfectMapIcons()
	{
		Custom = new Dictionary<int, Sprite>();
		Sprites = new List<Sprite>();
		Manual = new int[14]
		{
			0, 1, 2, 3, 4, 10, 21, 23, 25, 26,
			27, 28, 29, 30
		};
		Removed = new HashSet<int> { 7, 9, 11, 12, 22, 24 };
		ScaledIcons = new HashSet<Image>();
		ReducedLargeShipMarkers = new HashSet<Image>();
		PlacedShipPinBaseSizes = new Dictionary<Image, Vector2>();
		MinimapPinBaseSizes = new Dictionary<Image, Vector2>();
		ShipFields = new string[2] { "m_smallShipMarker", "m_largeShipMarker" };
		PlayerFields = new string[2] { "m_smallMarker", "m_largeMarker" };
		Textures = new List<Texture2D>();
		Names = new string[31]
		{
			"Костёр", "Дом", "Молот", "Точка", "Портал", "Смерть", "Кровать", "Сообщение", "Босс", "Игрок",
			"Событие", "Пинг", "Область", "Башня I", "Башня II", "Башня III", "Мемориал", "Хальдор", "Хильдир", "Болотная ведьма",
			"Мегалиты", "Рунный камень", "Ветер", "Готово", "Шлем", "Малина", "Гриб", "Корабль", "Пещера тролля", "Крепость",
			"Кирка"
		};
		Types = new Dictionary<string, int>
		{
			{ "Icon0", 0 },
			{ "Icon1", 1 },
			{ "Icon2", 2 },
			{ "Icon3", 3 },
			{ "Icon4", 4 },
			{ "Death", 5 },
			{ "Bed", 6 },
			{ "Boss", 8 },
			{ "RandomEvent", 10 },
			{ "Hildir1", 13 },
			{ "Hildir2", 14 },
			{ "Hildir3", 15 },
			{ "Memorial", 16 }
		};
		MapType = AccessTools.TypeByName("Minimap");
		BossMemo = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
		ById = new Dictionary<int, Sprite>();
		FieldCache = new Dictionary<Type, Dictionary<string, FieldInfo>>();
		BasePos = new Dictionary<RectTransform, Vector2>();
		Warned = new HashSet<string>();
		BossAliases = new string[8][]
		{
			new string[3] { "eikthyr", "эйктюр", "эйктир" },
			new string[4] { "gdking", "the elder", "elder", "древний" },
			new string[2] { "bonemass", "масса костей" },
			new string[5] { "dragonqueen", "$enemy_dragon", "moder", "моудер", "модер" },
			new string[3] { "goblinking", "yagluth", "яглут" },
			new string[3] { "seekerqueen", "the queen", "королева" },
			new string[3] { "fader", "фаутр", "фадер" },
			new string[8] { "frozenking", "kall", "fimbul", "калл", "фимбул", "dn_bossroom", "aesirpassage", "aesir_passage" }
		};
	}
}