Decompiled source of Compass v1.3.0

Compass.dll

Decompiled 6 months 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.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Compass;

[BepInPlugin("aedenthorn.Compass", "Compass", "1.3.0")]
public class BepInExPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Hud), "Awake")]
	private static class Hud_Awake_Patch
	{
		private static void Postfix(Hud __instance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Expected O, but got Unknown
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Expected O, but got Unknown
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_02a3: 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_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Expected O, but got Unknown
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: 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_04f0: Expected O, but got Unknown
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Expected O, but got Unknown
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Expected O, but got Unknown
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Expected O, but got Unknown
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Compass");
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true, true);
			try
			{
				byte[] array = File.ReadAllBytes(Path.Combine(path, compassFile.Value));
				ImageConversion.LoadImage(val, array);
			}
			catch (Exception arg)
			{
				Dbgl($"Invalid compass file {compassFile.Value}: {arg}");
				return;
			}
			Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, true, true);
			try
			{
				byte[] array2 = File.ReadAllBytes(Path.Combine(path, maskFile.Value));
				ImageConversion.LoadImage(val2, array2);
			}
			catch (Exception arg2)
			{
				Dbgl($"Invalid mask file {maskFile.Value}: {arg2}");
				return;
			}
			Texture2D val3 = new Texture2D(2, 2, (TextureFormat)4, true, true);
			try
			{
				byte[] array3 = File.ReadAllBytes(Path.Combine(path, centerFile.Value));
				ImageConversion.LoadImage(val3, array3);
			}
			catch (Exception arg3)
			{
				Dbgl($"Invalid center file {centerFile.Value}: {arg3}");
				return;
			}
			Dbgl("Loaded image files");
			float num = (float)((Texture)val).width / 2f;
			Sprite sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
			Sprite sprite2 = Sprite.Create(val2, new Rect(0f, 0f, num, (float)((Texture)val2).height), Vector2.zero);
			Sprite sprite3 = Sprite.Create(val3, new Rect(0f, 0f, (float)((Texture)val3).width, (float)((Texture)val3).height), Vector2.zero);
			Sprite sprite4 = null;
			Sprite sprite5 = null;
			Texture2D val4 = null;
			if (overlayFile.Value.Length > 0)
			{
				try
				{
					val4 = new Texture2D(2, 2, (TextureFormat)4, true, true);
					byte[] array4 = File.ReadAllBytes(Path.Combine(path, overlayFile.Value));
					ImageConversion.LoadImage(val4, array4);
					sprite4 = Sprite.Create(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), Vector2.zero);
				}
				catch
				{
					Dbgl("Invalid overlay file");
				}
			}
			Texture2D val5 = null;
			if (underlayFile.Value.Length > 0)
			{
				try
				{
					val5 = new Texture2D(2, 2, (TextureFormat)4, true, true);
					byte[] array5 = File.ReadAllBytes(Path.Combine(path, underlayFile.Value));
					ImageConversion.LoadImage(val5, array5);
					sprite5 = Sprite.Create(val5, new Rect(0f, 0f, (float)((Texture)val5).width, (float)((Texture)val5).height), Vector2.zero);
				}
				catch
				{
					Dbgl("Invalid underlay file");
				}
			}
			parentObject = new GameObject();
			((Object)parentObject).name = "Compass";
			RectTransform val6 = parentObject.AddComponent<RectTransform>();
			((Transform)val6).SetParent(__instance.m_rootObject.transform);
			if ((Object)(object)val4 != (Object)null)
			{
				GameObject val7 = new GameObject();
				((Object)val7).name = "Overlay";
				RectTransform val8 = val7.AddComponent<RectTransform>();
				((Transform)val8).SetParent(parentObject.transform);
				((Transform)val8).localScale = Vector3.one * compassScale.Value;
				val8.sizeDelta = new Vector2((float)((Texture)val4).width, (float)((Texture)val4).height);
				val8.anchoredPosition = Vector2.zero;
				Image val9 = val7.AddComponent<Image>();
				val9.sprite = sprite4;
				val9.preserveAspect = true;
			}
			if ((Object)(object)val5 != (Object)null)
			{
				GameObject val10 = new GameObject();
				((Object)val10).name = "Underlay";
				RectTransform val11 = val10.AddComponent<RectTransform>();
				((Transform)val11).SetParent(parentObject.transform);
				((Transform)val11).localScale = Vector3.one * compassScale.Value;
				val11.sizeDelta = new Vector2((float)((Texture)val5).width, (float)((Texture)val5).height);
				val11.anchoredPosition = Vector2.zero;
				Image val12 = val10.AddComponent<Image>();
				val12.sprite = sprite5;
				val12.preserveAspect = true;
			}
			GameObject val13 = new GameObject();
			((Object)val13).name = "Mask";
			RectTransform val14 = val13.AddComponent<RectTransform>();
			((Transform)val14).SetParent(parentObject.transform);
			val14.sizeDelta = new Vector2(num, (float)((Texture)val).height);
			((Transform)val14).localScale = Vector3.one * compassScale.Value;
			val14.anchoredPosition = Vector2.zero;
			Image val15 = val13.AddComponent<Image>();
			val15.sprite = sprite2;
			val15.preserveAspect = true;
			Mask val16 = val13.AddComponent<Mask>();
			val16.showMaskGraphic = false;
			compassObject = new GameObject();
			((Object)compassObject).name = "Image";
			RectTransform val17 = compassObject.AddComponent<RectTransform>();
			((Transform)val17).SetParent(val13.transform);
			((Transform)val17).localScale = Vector3.one;
			val17.anchoredPosition = Vector2.zero;
			val17.sizeDelta = new Vector2((float)((Texture)val).width, (float)((Texture)val).height);
			Image val18 = compassObject.AddComponent<Image>();
			val18.sprite = sprite;
			val18.preserveAspect = true;
			centerObject = new GameObject();
			((Object)centerObject).name = "CenterImage";
			RectTransform val19 = centerObject.AddComponent<RectTransform>();
			((Transform)val19).SetParent(val13.transform);
			((Transform)val19).localScale = Vector3.one;
			val19.anchoredPosition = Vector2.zero;
			val19.sizeDelta = new Vector2((float)((Texture)val3).width, (float)((Texture)val3).height);
			Image val20 = centerObject.AddComponent<Image>();
			val20.sprite = sprite3;
			val20.preserveAspect = true;
			pinsObject = new GameObject();
			((Object)pinsObject).name = "Pins";
			val17 = pinsObject.AddComponent<RectTransform>();
			((Transform)val17).SetParent(val13.transform);
			((Transform)val17).localScale = Vector3.one;
			val17.anchoredPosition = Vector2.zero;
			val17.sizeDelta = new Vector2(num, (float)((Texture)val).height);
			Dbgl("Added compass to hud");
		}
	}

	[HarmonyPatch(typeof(Hud), "Update")]
	private static class Hud_Update_Patch
	{
		private static void Prefix(Hud __instance)
		{
			//IL_0059: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0137: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Expected O, but got Unknown
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: 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_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Expected O, but got Unknown
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			if (!modEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				return;
			}
			float num = ((!usePlayerDirection.Value) ? ((Component)GameCamera.instance).transform.eulerAngles.y : ((Component)Player.m_localPlayer).transform.eulerAngles.y);
			if (num > 180f)
			{
				num -= 360f;
			}
			num *= -(float)Math.PI / 180f;
			Rect rect = compassObject.GetComponent<Image>().sprite.rect;
			float scaleFactor = GameObject.Find("LoadingGUI").GetComponent<CanvasScaler>().scaleFactor;
			((Transform)compassObject.GetComponent<RectTransform>()).localPosition = Vector3.right * (((Rect)(ref rect)).width / 2f) * num / ((float)Math.PI * 2f) - new Vector3(((Rect)(ref rect)).width * 0.125f, 0f, 0f);
			((Graphic)compassObject.GetComponent<Image>()).color = compassColor.Value;
			((Transform)parentObject.GetComponent<RectTransform>()).localScale = Vector3.one * compassScale.Value;
			parentObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, ((float)Screen.height / scaleFactor - (float)((Texture)compassObject.GetComponent<Image>().sprite.texture).height * compassScale.Value) / 2f) - Vector2.up * compassYOffset.Value;
			((Graphic)centerObject.GetComponent<Image>()).color = centerColor.Value;
			centerObject.SetActive(showCenterMarker.Value);
			int childCount = pinsObject.transform.childCount;
			List<string> list = new List<string>();
			foreach (Transform item in pinsObject.transform)
			{
				Transform val = item;
				if (!enableMarkers.Value)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
				else
				{
					list.Add(((Object)val).name);
				}
			}
			if (!enableMarkers.Value)
			{
				return;
			}
			List<PinData> list2 = new List<PinData>();
			list2.AddRange(AccessTools.DeclaredField(typeof(Minimap), "m_pins").GetValue(Minimap.instance) as List<PinData>);
			list2.AddRange((AccessTools.DeclaredField(typeof(Minimap), "m_locationPins").GetValue(Minimap.instance) as Dictionary<Vector3, PinData>).Values);
			if (showPlayerMarkers.Value)
			{
				list2.AddRange(AccessTools.DeclaredField(typeof(Minimap), "m_playerPins").GetValue(Minimap.instance) as List<PinData>);
			}
			object? value = AccessTools.DeclaredField(typeof(Minimap), "m_deathPin").GetValue(Minimap.instance);
			PinData val2 = (PinData)((value is PinData) ? value : null);
			if (val2 != null)
			{
				list2.Add(val2);
			}
			Transform transform = ((Component)Player.m_localPlayer).transform;
			float num2 = maxMarkerDistance.Value / (1f - minMarkerScale.Value);
			foreach (PinData item2 in list2)
			{
				string name = ((object)(Vector3)(ref item2.m_pos)).ToString();
				list.Remove(name);
				Transform val3 = pinsObject.transform.Find(name);
				if (ignoredNames.Contains(item2.m_name) || ignoredTypes.Contains<string>(((object)(PinType)(ref item2.m_type)).ToString()) || (ignoredMarkerNames.Value.Contains("*") && Array.Exists(ignoredNames, (string s) => s.EndsWith("*") && name.StartsWith(s.Substring(0, s.Length - 1)))) || Vector3.Distance(transform.position, item2.m_pos) > maxMarkerDistance.Value || Vector3.Distance(transform.position, item2.m_pos) < minMarkerDistance.Value)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						((Component)val3).gameObject.SetActive(false);
					}
					continue;
				}
				if (Object.op_Implicit((Object)(object)val3))
				{
					((Component)val3).gameObject.SetActive(true);
				}
				Vector3 val4 = ((!usePlayerDirection.Value) ? ((Component)GameCamera.instance).transform.InverseTransformPoint(item2.m_pos) : transform.InverseTransformPoint(item2.m_pos));
				num = Mathf.Atan2(val4.x, val4.z);
				RectTransform val6;
				Image val7;
				if (!Object.op_Implicit((Object)(object)val3))
				{
					GameObject val5 = new GameObject();
					((Object)val5).name = ((object)(Vector3)(ref item2.m_pos)).ToString();
					val6 = val5.AddComponent<RectTransform>();
					((Transform)val6).SetParent(pinsObject.transform);
					val6.anchoredPosition = Vector2.zero;
					val7 = val5.AddComponent<Image>();
				}
				else
				{
					GameObject val5 = ((Component)val3).gameObject;
					val6 = ((Component)val3).GetComponent<RectTransform>();
					val7 = ((Component)val3).GetComponent<Image>();
				}
				float num3 = ((minMarkerScale.Value < 1f) ? ((num2 - Vector3.Distance(transform.position, item2.m_pos)) / num2) : 1f);
				((Transform)val6).localScale = Vector3.one * num3 * 0.5f * markerScale.Value;
				((Graphic)val7).color = markerColor.Value;
				val7.sprite = item2.m_icon;
				((Transform)val6).localPosition = Vector3.right * (((Rect)(ref rect)).width / 2f) * num / ((float)Math.PI * 2f);
			}
			foreach (string item3 in list)
			{
				Object.Destroy((Object)(object)((Component)pinsObject.transform.Find(item3)).gameObject);
			}
		}
	}

	[HarmonyPatch(typeof(Terminal), "InputText")]
	private static class InputText_Patch
	{
		private static bool Prefix(Terminal __instance)
		{
			if (!modEnabled.Value)
			{
				return true;
			}
			string text = ((TMP_InputField)__instance.m_input).text;
			if (text.ToLower().Equals(typeof(BepInExPlugin).Namespace.ToLower() + " reset"))
			{
				((BaseUnityPlugin)context).Config.Reload();
				((BaseUnityPlugin)context).Config.Save();
				__instance.AddString(text);
				__instance.AddString(((BaseUnityPlugin)context).Info.Metadata.Name + " config reloaded");
				return false;
			}
			return true;
		}
	}

	private static readonly bool isDebug = true;

	private static BepInExPlugin context;

	private Harmony harmony;

	public static ConfigEntry<bool> modEnabled;

	public static ConfigEntry<int> nexusID;

	public static ConfigEntry<bool> enableMarkers;

	public static ConfigEntry<bool> showPlayerMarkers;

	public static ConfigEntry<bool> usePlayerDirection;

	public static ConfigEntry<bool> showCenterMarker;

	public static ConfigEntry<string> compassFile;

	public static ConfigEntry<string> overlayFile;

	public static ConfigEntry<string> underlayFile;

	public static ConfigEntry<string> maskFile;

	public static ConfigEntry<string> centerFile;

	public static ConfigEntry<Color> compassColor;

	public static ConfigEntry<Color> centerColor;

	public static ConfigEntry<Color> markerColor;

	public static ConfigEntry<float> compassYOffset;

	public static ConfigEntry<float> compassScale;

	public static ConfigEntry<float> markerScale;

	public static ConfigEntry<float> minMarkerDistance;

	public static ConfigEntry<float> maxMarkerDistance;

	public static ConfigEntry<float> minMarkerScale;

	public static ConfigEntry<string> ignoredMarkerNames;

	public static ConfigEntry<string> ignoredMarkerTypes;

	public static GameObject compassObject;

	public static GameObject pinsObject;

	public static GameObject centerObject;

	public static GameObject parentObject;

	public static float lastAngle;

	public static bool dbgl;

	public static string[] ignoredTypes;

	public static string[] ignoredNames;

	public static void Dbgl(string str = "", bool pref = true)
	{
		if (isDebug)
		{
			Debug.Log((object)((pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str));
		}
	}

	private void Awake()
	{
		//IL_02af: 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_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Expected O, but got Unknown
		context = this;
		modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod");
		nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 851, "Nexus mod ID for updates");
		usePlayerDirection = ((BaseUnityPlugin)this).Config.Bind<bool>("Compass", "UsePlayerDirection", false, "Orient the compass based on the player's facing direction, rather than the middle of the screen");
		showCenterMarker = ((BaseUnityPlugin)this).Config.Bind<bool>("Compass", "ShowCenterMarker", true, "Show center marker");
		compassScale = ((BaseUnityPlugin)this).Config.Bind<float>("Compass", "CompassScale", 0.75f, "Compass scale");
		compassYOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Compass", "CompassYOffset", 0f, "Compass offset from top of screen in pixels");
		enableMarkers = ((BaseUnityPlugin)this).Config.Bind<bool>("Markers", "EnableMarkers", true, "Show markers on compass.");
		showPlayerMarkers = ((BaseUnityPlugin)this).Config.Bind<bool>("Markers", "ShowPlayerMarkers", true, "Show player markers on compass.");
		markerScale = ((BaseUnityPlugin)this).Config.Bind<float>("Markers", "MarkerScale", 1f, "Marker scale");
		minMarkerDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Markers", "MinMarkerDistance", 1f, "Minimum marker distance to show on map in metres");
		maxMarkerDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Markers", "MaxMarkerDistance", 100f, "Max marker distance to show on map in metres");
		minMarkerScale = ((BaseUnityPlugin)this).Config.Bind<float>("Markers", "MinMarkerScale", 0.25f, "Marker scale at max marker distance (before applying MarkerScale)");
		ignoredMarkerNames = ((BaseUnityPlugin)this).Config.Bind<string>("Markers", "IgnoredMarkerNames", "Silver,Obsidian,Copper,Tin", "Ignore markers with these names (comma-separated). End a string with * to denote a prefix. Default list is pins added by AutoMapPins");
		ignoredMarkerTypes = ((BaseUnityPlugin)this).Config.Bind<string>("Markers", "IgnoredMarkerTypes", "", "Ignore markers with these types (comma-separated). Possible types include: Icon0,Icon1,Icon2,Icon3,Death,Bed,Icon4,Shout,None,Boss,Player,RandomEvent,Ping,EventArea");
		compassFile = ((BaseUnityPlugin)this).Config.Bind<string>("Files", "CompassFile", "compass.png", "Compass file to use in Compass folder");
		overlayFile = ((BaseUnityPlugin)this).Config.Bind<string>("Files", "OverlayFile", "", "Overlay file to use in Compass folder. This file is just an arbitrary graphic to show on top of the compass, e.g. a frame.");
		underlayFile = ((BaseUnityPlugin)this).Config.Bind<string>("Files", "UnderlayFile", "", "Underlay file to use in Compass folder. This file is just an arbitrary graphic to show below the compass, e.g. a frame.");
		maskFile = ((BaseUnityPlugin)this).Config.Bind<string>("Files", "MaskFile", "mask.png", "Mask file to use in Compass folder");
		centerFile = ((BaseUnityPlugin)this).Config.Bind<string>("Files", "CenterFile", "center.png", "Center file to use in Compass folder");
		compassColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "CompassColor", Color.white, "Compass color");
		centerColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "CenterColor", new Color(1f, 1f, 0f, 0.5f), "Center marker color");
		markerColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Colors", "MarkerColor", Color.white, "Marker color");
		ignoredMarkerNames.SettingChanged += IgnoredMarkerNames_SettingChanged;
		ignoredMarkerTypes.SettingChanged += IgnoredMarkerTypes_SettingChanged;
		ignoredTypes = ignoredMarkerTypes.Value.Split(new char[1] { ',' });
		ignoredNames = ignoredMarkerNames.Value.Split(new char[1] { ',' });
		if (modEnabled.Value)
		{
			harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
			harmony.PatchAll();
		}
	}

	private void IgnoredMarkerTypes_SettingChanged(object sender, EventArgs e)
	{
		ignoredTypes = ignoredMarkerTypes.Value.Split(new char[1] { ',' });
	}

	private void IgnoredMarkerNames_SettingChanged(object sender, EventArgs e)
	{
		ignoredNames = ignoredMarkerNames.Value.Split(new char[1] { ',' });
	}

	private void OnDestroy()
	{
		Dbgl("Destroying plugin");
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchAll((string)null);
		}
	}
}