Decompiled source of Location markers v0.2.1

plugins/LocationMarkers/LocationMarkers.dll

Decompiled 8 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.UI;
using UnityEngine;
using UnityEngine.SceneManagement;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LocationMarkers
{
	internal static class MarkerArt
	{
		internal static readonly Dictionary<string, float[][]> Paths = new Dictionary<string, float[][]>
		{
			["Teleporter"] = new float[3][]
			{
				new float[18]
				{
					10f, 52f, 10f, 28f, 14f, 16f, 22f, 9f, 32f, 6f,
					42f, 9f, 50f, 16f, 54f, 28f, 54f, 52f
				},
				new float[14]
				{
					20f, 50f, 20f, 29f, 24f, 21f, 32f, 17f, 40f, 21f,
					44f, 29f, 44f, 50f
				},
				new float[4] { 7f, 55f, 57f, 55f }
			},
			["Newt altar"] = new float[6][]
			{
				new float[10] { 10f, 52f, 54f, 52f, 50f, 58f, 14f, 58f, 10f, 52f },
				new float[26]
				{
					15f, 45f, 21f, 43f, 23f, 36f, 20f, 30f, 22f, 21f,
					31f, 16f, 40f, 18f, 44f, 24f, 43f, 31f, 35f, 35f,
					29f, 30f, 31f, 25f, 36f, 26f
				},
				new float[6] { 22f, 21f, 20f, 13f, 26f, 18f },
				new float[6] { 35f, 18f, 41f, 12f, 40f, 21f },
				new float[4] { 24f, 39f, 30f, 45f },
				new float[4] { 35f, 35f, 42f, 43f }
			},
			["Shrine"] = new float[3][]
			{
				new float[10] { 10f, 55f, 54f, 55f, 49f, 48f, 15f, 48f, 10f, 55f },
				new float[8] { 23f, 48f, 23f, 40f, 41f, 40f, 41f, 48f },
				new float[18]
				{
					32f, 35f, 22f, 30f, 21f, 23f, 28f, 16f, 32f, 7f,
					35f, 19f, 43f, 23f, 42f, 30f, 32f, 35f
				}
			},
			["Chest"] = new float[5][]
			{
				new float[10] { 9f, 28f, 9f, 51f, 55f, 51f, 55f, 28f, 9f, 28f },
				new float[8] { 9f, 28f, 14f, 14f, 50f, 14f, 55f, 28f },
				new float[4] { 9f, 34f, 26f, 34f },
				new float[4] { 38f, 34f, 55f, 34f },
				new float[10] { 26f, 29f, 38f, 29f, 38f, 39f, 26f, 39f, 26f, 29f }
			},
			["Void"] = new float[3][]
			{
				new float[10] { 32f, 7f, 56f, 32f, 32f, 57f, 8f, 32f, 32f, 7f },
				new float[14]
				{
					17f, 32f, 25f, 24f, 39f, 24f, 47f, 32f, 39f, 40f,
					25f, 40f, 17f, 32f
				},
				new float[10] { 32f, 27f, 37f, 32f, 32f, 37f, 27f, 32f, 32f, 27f }
			},
			["Printer"] = new float[7][]
			{
				new float[8] { 15f, 25f, 15f, 9f, 49f, 9f, 49f, 25f },
				new float[4] { 20f, 17f, 44f, 17f },
				new float[10] { 9f, 46f, 9f, 25f, 55f, 25f, 55f, 46f, 46f, 46f },
				new float[4] { 18f, 46f, 9f, 46f },
				new float[10] { 18f, 38f, 46f, 38f, 46f, 56f, 18f, 56f, 18f, 38f },
				new float[4] { 25f, 46f, 39f, 46f },
				new float[4] { 25f, 51f, 36f, 51f }
			},
			["Scrapper"] = new float[6][]
			{
				new float[6] { 19f, 23f, 31f, 8f, 43f, 23f },
				new float[6] { 43f, 14f, 43f, 23f, 34f, 23f },
				new float[6] { 48f, 30f, 57f, 47f, 36f, 47f },
				new float[6] { 42f, 41f, 36f, 47f, 42f, 53f },
				new float[6] { 26f, 47f, 7f, 47f, 16f, 30f },
				new float[6] { 8f, 34f, 16f, 30f, 19f, 39f }
			},
			["Cauldron"] = new float[6][]
			{
				new float[14]
				{
					10f, 28f, 54f, 28f, 49f, 45f, 41f, 51f, 23f, 51f,
					15f, 45f, 10f, 28f
				},
				new float[4] { 7f, 28f, 57f, 28f },
				new float[4] { 21f, 52f, 17f, 58f },
				new float[4] { 43f, 52f, 47f, 58f },
				new float[8] { 23f, 21f, 20f, 16f, 24f, 11f, 23f, 6f },
				new float[8] { 40f, 21f, 37f, 16f, 41f, 11f, 40f, 6f }
			},
			["Drone"] = new float[9][]
			{
				new float[12]
				{
					23f, 25f, 41f, 25f, 45f, 37f, 32f, 46f, 19f, 37f,
					23f, 25f
				},
				new float[4] { 23f, 29f, 12f, 20f },
				new float[4] { 41f, 29f, 52f, 20f },
				new float[4] { 5f, 17f, 19f, 17f },
				new float[4] { 45f, 17f, 59f, 17f },
				new float[4] { 12f, 12f, 12f, 25f },
				new float[4] { 52f, 12f, 52f, 25f },
				new float[4] { 26f, 43f, 21f, 53f },
				new float[4] { 38f, 43f, 43f, 53f }
			},
			["Other"] = new float[2][]
			{
				new float[20]
				{
					32f, 57f, 14f, 33f, 12f, 22f, 17f, 12f, 27f, 7f,
					37f, 7f, 47f, 12f, 52f, 22f, 50f, 33f, 32f, 57f
				},
				new float[18]
				{
					32f, 18f, 39f, 21f, 42f, 28f, 39f, 35f, 32f, 38f,
					25f, 35f, 22f, 28f, 25f, 21f, 32f, 18f
				}
			}
		};

		internal static Texture2D Create(string category)
		{
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			if (!Paths.TryGetValue(category, out var value))
			{
				value = Paths["Other"];
			}
			Color[] array = (Color[])(object)new Color[4096];
			Vector2 val = default(Vector2);
			Vector2 val2 = default(Vector2);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = 0f;
					for (int k = 0; k < 4; k++)
					{
						for (int l = 0; l < 4; l++)
						{
							((Vector2)(ref val))..ctor((float)j + ((float)l + 0.5f) / 4f, (float)i + ((float)k + 0.5f) / 4f);
							bool flag = false;
							float[][] array2 = value;
							foreach (float[] array3 in array2)
							{
								for (int n = 2; n < array3.Length; n += 2)
								{
									((Vector2)(ref val2))..ctor(array3[n - 2], array3[n - 1]);
									Vector2 val3 = new Vector2(array3[n], array3[n + 1]) - val2;
									float num2 = Mathf.Clamp01(Vector2.Dot(val - val2, val3) / Mathf.Max(((Vector2)(ref val3)).sqrMagnitude, 0.001f));
									Vector2 val4 = val - (val2 + val3 * num2);
									if (((Vector2)(ref val4)).sqrMagnitude <= 4f)
									{
										flag = true;
										break;
									}
								}
								if (flag)
								{
									break;
								}
							}
							if (flag)
							{
								num += 0.0625f;
							}
						}
					}
					array[(63 - i) * 64 + j] = new Color(1f, 1f, 1f, num);
				}
			}
			Texture2D val5 = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1
			};
			val5.SetPixels(array);
			val5.Apply();
			return val5;
		}
	}
	[BepInPlugin("local.ror2.locationmarkers", "Location markers", "0.2.1")]
	[DefaultExecutionOrder(10000)]
	public sealed class Plugin : BaseUnityPlugin
	{
		private sealed class Category
		{
			public ConfigEntry<bool> enabled;

			public ConfigEntry<string> color;

			public Texture2D icon;
		}

		private sealed class Marker
		{
			public Component owner;

			public PurchaseInteraction purchase;

			public TeleporterInteraction teleporter;

			public string label;

			public string category;
		}

		private int selectedTab;

		private string selectedType = "Teleporter";

		private string hexDraft = "";

		private string colorError = "";

		private Vector2 displayScroll;

		private bool configDirty;

		private bool oldSaveOnSet;

		private float saveAfter;

		private readonly HashSet<MPEventSystem> menuSystems = new HashSet<MPEventSystem>();

		private GUIStyle panel;

		private GUIStyle heading;

		private GUIStyle small;

		private GUIStyle section;

		private GUIStyle button;

		private GUIStyle field;

		private GUIStyle tab;

		private GUIStyle row;

		private Texture2D panelPixel;

		private CanvasGroup cursorVisual;

		private float cursorAlpha;

		private float resumeScale;

		private bool addedCursorGroup;

		private bool ownsPause;

		private int closedFrame = -1;

		private static Plugin activeSettings;

		private Harmony menuHarmony;

		private static readonly Color Ink = new Color(0.89f, 0.9f, 0.93f);

		private static readonly Color Muted = new Color(0.6f, 0.64f, 0.7f);

		private static readonly Color Accent = new Color(0.72f, 0.69f, 0.83f);

		public const string Id = "local.ror2.locationmarkers";

		private ConfigEntry<bool> modEnabled;

		private ConfigEntry<bool> labels;

		private ConfigEntry<bool> distances;

		private ConfigEntry<bool> edgeMarkers;

		private ConfigEntry<bool> showBusy;

		private ConfigEntry<float> scale;

		private ConfigEntry<float> height;

		private ConfigEntry<float> range;

		private ConfigEntry<float> refresh;

		private ConfigEntry<KeyboardShortcut> toggle;

		private readonly List<Marker> markers = new List<Marker>();

		private readonly Dictionary<string, Category> categories = new Dictionary<string, Category>();

		private float nextScan;

		private bool hidden;

		private bool settings;

		private Rect settingsRect = new Rect(30f, 30f, 740f, 680f);

		private GUIStyle textStyle;

		private void SettingsChanged(object sender, SettingChangedEventArgs args)
		{
			configDirty = true;
			saveAfter = Time.unscaledTime + 0.5f;
		}

		private void SaveSettings()
		{
			try
			{
				((BaseUnityPlugin)this).Config.Save();
				configDirty = false;
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not save marker settings: " + ex.Message));
				saveAfter = Time.unscaledTime + 5f;
			}
		}

		private void SetSettings(bool open)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			if (settings == open)
			{
				return;
			}
			settings = open;
			if (open)
			{
				activeSettings = this;
				if (menuHarmony == null)
				{
					menuHarmony = new Harmony("local.ror2.locationmarkers.settings");
				}
				if (!Harmony.HasAnyPatches("local.ror2.locationmarkers.settings"))
				{
					menuHarmony.Patch((MethodBase)AccessTools.Method(typeof(PauseManager), "TogglePauseScreen", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Plugin), "AllowGamePause", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					menuHarmony.Patch((MethodBase)AccessTools.Method(typeof(MPEventSystemManager), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "KeepSettingsCursor", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
					menuHarmony.Patch((MethodBase)AccessTools.PropertyGetter(typeof(LocalUser), "isUIFocused"), (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "SettingsInputFocus", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				hexDraft = categories[selectedType].color.Value.TrimStart('#');
				colorError = "";
				AcquirePause();
				SyncMenuInput();
			}
			else
			{
				closedFrame = Time.frameCount;
				ReleaseMenuInput();
				ReleasePause();
				if (configDirty)
				{
					SaveSettings();
				}
			}
		}

		private static bool AllowGamePause()
		{
			if (Object.op_Implicit((Object)(object)activeSettings))
			{
				if (!activeSettings.settings)
				{
					return activeSettings.closedFrame != Time.frameCount;
				}
				return false;
			}
			return true;
		}

		private static void SettingsInputFocus(LocalUser __instance, ref bool __result)
		{
			if (Object.op_Implicit((Object)(object)activeSettings) && activeSettings.settings && __instance == LocalUserManager.GetFirstLocalUser())
			{
				__result = true;
			}
		}

		private static IEnumerable<CodeInstruction> KeepSettingsCursor(IEnumerable<CodeInstruction> instructions)
		{
			MethodInfo original = AccessTools.PropertySetter(typeof(Cursor), "visible");
			MethodInfo replacement = AccessTools.Method(typeof(Plugin), "SetGameCursorVisibility", (Type[])null, (Type[])null);
			MethodInfo originalLock = AccessTools.PropertySetter(typeof(Cursor), "lockState");
			MethodInfo replacementLock = AccessTools.Method(typeof(Plugin), "SetGameCursorLock", (Type[])null, (Type[])null);
			foreach (CodeInstruction instruction in instructions)
			{
				if (CodeInstructionExtensions.Calls(instruction, original))
				{
					instruction.operand = replacement;
				}
				else if (CodeInstructionExtensions.Calls(instruction, originalLock))
				{
					instruction.operand = replacementLock;
				}
				yield return instruction;
			}
		}

		private static void SetGameCursorVisibility(bool visible)
		{
			Cursor.visible = visible || (Object.op_Implicit((Object)(object)activeSettings) && activeSettings.settings);
		}

		private static void SetGameCursorLock(CursorLockMode mode)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			Cursor.lockState = (CursorLockMode)((Object.op_Implicit((Object)(object)activeSettings) && activeSettings.settings) ? 2 : ((int)mode));
		}

		private void AcquirePause()
		{
			if (!ownsPause && Object.op_Implicit((Object)(object)Run.instance) && RoR2Application.isInSinglePlayer && !(Time.timeScale <= 0f))
			{
				resumeScale = Time.timeScale;
				ownsPause = true;
				Time.timeScale = 0f;
			}
		}

		private void ReleasePause()
		{
			if (ownsPause)
			{
				ownsPause = false;
				if (Time.timeScale == 0f)
				{
					Time.timeScale = resumeScale;
				}
			}
		}

		private void LateUpdate()
		{
			if (settings)
			{
				if (ownsPause && (!Object.op_Implicit((Object)(object)Run.instance) || !RoR2Application.isInSinglePlayer))
				{
					ReleasePause();
				}
				AcquirePause();
				Cursor.lockState = (CursorLockMode)2;
				Cursor.visible = true;
			}
		}

		private void SyncMenuInput()
		{
			if (!settings)
			{
				return;
			}
			MPEventSystem val = MPEventSystemManager.primaryEventSystem;
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = MPEventSystemManager.kbmEventSystem;
			}
			if (!Object.op_Implicit((Object)(object)val) || menuSystems.Contains(val))
			{
				return;
			}
			ReleaseMenuInput();
			menuSystems.Add(val);
			MPEventSystem obj = val;
			int cursorOpenerCount = obj.cursorOpenerCount;
			obj.cursorOpenerCount = cursorOpenerCount + 1;
			MPEventSystem obj2 = val;
			cursorOpenerCount = obj2.cursorOpenerForGamepadCount;
			obj2.cursorOpenerForGamepadCount = cursorOpenerCount + 1;
			object? obj3 = AccessTools.Field(typeof(MPEventSystem), "cursorIndicatorController")?.GetValue(val);
			Component val2 = (Component)((obj3 is Component) ? obj3 : null);
			if (Object.op_Implicit((Object)(object)val2))
			{
				cursorVisual = val2.GetComponent<CanvasGroup>();
				addedCursorGroup = !Object.op_Implicit((Object)(object)cursorVisual);
				if (!Object.op_Implicit((Object)(object)cursorVisual))
				{
					cursorVisual = val2.gameObject.AddComponent<CanvasGroup>();
				}
				cursorAlpha = cursorVisual.alpha;
				cursorVisual.alpha = 0f;
			}
		}

		private void ReleaseMenuInput()
		{
			foreach (MPEventSystem menuSystem in menuSystems)
			{
				if (Object.op_Implicit((Object)(object)menuSystem))
				{
					int cursorOpenerCount = menuSystem.cursorOpenerCount;
					menuSystem.cursorOpenerCount = cursorOpenerCount - 1;
					cursorOpenerCount = menuSystem.cursorOpenerForGamepadCount;
					menuSystem.cursorOpenerForGamepadCount = cursorOpenerCount - 1;
				}
			}
			menuSystems.Clear();
			if (Object.op_Implicit((Object)(object)cursorVisual))
			{
				cursorVisual.alpha = cursorAlpha;
				if (addedCursorGroup)
				{
					Object.Destroy((Object)(object)cursorVisual);
				}
			}
			cursorVisual = null;
			Cursor.visible = false;
		}

		private void OnDisable()
		{
			SetSettings(open: false);
		}

		public static bool TryReadColor(string value, out Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			color = Color.white;
			string text = (value ?? "").Trim().TrimStart('#');
			if (text.Length != 6 || !uint.TryParse(text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result))
			{
				return false;
			}
			color = new Color((float)((result >> 16) & 0xFF) / 255f, (float)((result >> 8) & 0xFF) / 255f, (float)(result & 0xFF) / 255f, 1f);
			return true;
		}

		private void InitStyles()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_006f: Expected O, but got Unknown
			//IL_010f: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Expected O, but got Unknown
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			//IL_0207: Expected O, but got Unknown
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Expected O, but got Unknown
			//IL_0240: Expected O, but got Unknown
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Expected O, but got Unknown
			if (panel == null)
			{
				panelPixel = new Texture2D(1, 1);
				panelPixel.SetPixel(0, 0, new Color(0.085f, 0.095f, 0.115f, 0.98f));
				panelPixel.Apply();
				panel = new GUIStyle(GUI.skin.window)
				{
					padding = new RectOffset(22, 22, 18, 18)
				};
				panel.normal.background = panelPixel;
				GUIStyleState[] array = (GUIStyleState[])(object)new GUIStyleState[8] { panel.normal, panel.hover, panel.active, panel.focused, panel.onNormal, panel.onHover, panel.onActive, panel.onFocused };
				foreach (GUIStyleState obj in array)
				{
					obj.background = panelPixel;
					obj.textColor = Ink;
				}
				heading = new GUIStyle(GUI.skin.label)
				{
					fontSize = 22,
					fontStyle = (FontStyle)1
				};
				heading.normal.textColor = Ink;
				small = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					wordWrap = true
				};
				small.normal.textColor = Muted;
				section = new GUIStyle(GUI.skin.label)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1
				};
				section.normal.textColor = Ink;
				button = new GUIStyle(GUI.skin.button)
				{
					fontSize = 13,
					fixedHeight = 32f,
					padding = new RectOffset(10, 10, 6, 6)
				};
				field = new GUIStyle(GUI.skin.textField)
				{
					fontSize = 14,
					fixedHeight = 32f,
					padding = new RectOffset(9, 9, 6, 6)
				};
				tab = new GUIStyle(button)
				{
					fixedHeight = 36f
				};
				row = new GUIStyle(button)
				{
					alignment = (TextAnchor)3,
					fixedHeight = 36f
				};
			}
		}

		private void DrawSettingsWindow()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			InitStyles();
			Matrix4x4 matrix = GUI.matrix;
			Color color = GUI.color;
			Color backgroundColor = GUI.backgroundColor;
			Color contentColor = GUI.contentColor;
			float num = Mathf.Min(1.25f, Mathf.Min((float)Screen.width / 800f, (float)Screen.height / 720f));
			num = Mathf.Max(0.25f, num);
			GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f));
			GUI.color = Color.white;
			GUI.contentColor = Ink;
			((Rect)(ref settingsRect)).x = Mathf.Clamp(((Rect)(ref settingsRect)).x, 0f, Mathf.Max(0f, (float)Screen.width / num - ((Rect)(ref settingsRect)).width));
			((Rect)(ref settingsRect)).y = Mathf.Clamp(((Rect)(ref settingsRect)).y, 0f, Mathf.Max(0f, (float)Screen.height / num - ((Rect)(ref settingsRect)).height));
			try
			{
				settingsRect = GUI.Window(716043, settingsRect, new WindowFunction(DrawSettings), "", panel);
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.color = color;
				GUI.backgroundColor = backgroundColor;
				GUI.contentColor = contentColor;
			}
		}

		private void DrawSettings(int id)
		{
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(520f) });
			GUILayout.Label("Location markers", heading, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Ctrl+H to toggle markers   /   F8 or Esc to close", small, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Close", button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
			{
				SetSettings(open: false);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(14f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			TabButton("Display", 0);
			TabButton("Marker types", 1);
			GUILayout.FlexibleSpace();
			modEnabled.Value = GUILayout.Toggle(modEnabled.Value, "Markers enabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) });
			GUILayout.EndHorizontal();
			GUILayout.Space(18f);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(456f) });
			if (selectedTab == 0)
			{
				DrawDisplayTab();
			}
			else
			{
				DrawTypesTab();
			}
			GUILayout.EndHorizontal();
			GUILayout.FlexibleSpace();
			GUILayout.Label(configDirty ? "Saving changes..." : "Changes apply immediately and are saved automatically.", small, Array.Empty<GUILayoutOption>());
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref settingsRect)).width - 100f, 62f));
		}

		private void TabButton(string title, int index)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = ((selectedTab == index) ? Accent : Color.gray);
			if (GUILayout.Button(title, tab, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(145f) }))
			{
				selectedTab = index;
			}
			GUI.backgroundColor = backgroundColor;
		}

		private void DrawDisplayTab()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			displayScroll = GUILayout.BeginScrollView(displayScroll, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(440f),
				GUILayout.Height(456f)
			});
			GUILayout.Label("Visibility", section, Array.Empty<GUILayoutOption>());
			ToggleRow(labels, "Names", "Show localized names below each icon.");
			ToggleRow(distances, "Distances", "Show distance in meters.");
			ToggleRow(edgeMarkers, "Off-screen indicators", "Keep locations at the edge of the screen.");
			ToggleRow(showBusy, "Unavailable interactables", "Includes opened chests and exhausted shrines.");
			GUILayout.Space(12f);
			GUILayout.Label("Placement and performance", section, Array.Empty<GUILayoutOption>());
			SliderRow(scale, "Icon size", 12f, 64f, "0", "px");
			SliderRow(height, "Height above object", 0f, 10f, "0.0", "m");
			SliderRow(range, "Maximum distance", 0f, 5000f, "0", "m", unlimited: true);
			SliderRow(refresh, "Scan interval", 0.25f, 10f, "0.00", "s");
			if (GUILayout.Button("Reset display defaults", button, Array.Empty<GUILayoutOption>()))
			{
				ConfigEntry<bool> obj = labels;
				ConfigEntry<bool> obj2 = distances;
				bool flag = (edgeMarkers.Value = true);
				bool value = (obj2.Value = flag);
				obj.Value = value;
				showBusy.Value = false;
				scale.Value = 24f;
				height.Value = 2f;
				range.Value = 0f;
				refresh.Value = 1f;
			}
			GUILayout.EndScrollView();
			GUILayout.Space(22f);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(222f) });
			GUILayout.Label("Preview", section, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Sample marker appearance", small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(24f);
			DrawPreview(categories[selectedType], useSize: true);
			GUILayout.Space(22f);
			GUILayout.Label(hidden ? "Markers hidden by shortcut" : "Markers visible", section, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(hidden ? "Show markers" : "Hide markers", button, Array.Empty<GUILayoutOption>()))
			{
				hidden = !hidden;
			}
			GUILayout.Space(18f);
			GUILayout.Label("Zero maximum distance means unlimited. Single-player pauses while this panel is open. Multiplayer keeps running.", small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(16f);
			GUILayout.Label("Marker types", section, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Choose a type to adjust its visibility and color, with a preview of its actual icon.", small, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
		}

		private void ToggleRow(ConfigEntry<bool> entry, string title, string description)
		{
			entry.Value = GUILayout.Toggle(entry.Value, title, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(25f) });
			GUILayout.Label(description, small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
		}

		private void SliderRow(ConfigEntry<float> entry, string title, float min, float max, string format, string unit, bool unlimited = false)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(title, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) });
			GUILayout.FlexibleSpace();
			GUILayout.Label((unlimited && entry.Value == 0f) ? "Unlimited" : (entry.Value.ToString(format) + " " + unit), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(125f) });
			GUILayout.EndHorizontal();
			float num = GUILayout.HorizontalSlider(entry.Value, min, max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(20f) });
			if (num != entry.Value)
			{
				entry.Value = num;
			}
			GUILayout.Space(6f);
		}

		private void DrawTypesTab()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: 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_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(345f) });
			GUILayout.Label("Interactables", section, Array.Empty<GUILayoutOption>());
			GUILayout.Space(5f);
			foreach (KeyValuePair<string, Category> category2 in categories)
			{
				Category value = category2.Value;
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				value.enabled.Value = GUILayout.Toggle(value.enabled.Value, "", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(24f),
					GUILayout.Height(36f)
				});
				Color color = GUI.color;
				if (!TryReadColor(value.color.Value, out var color2))
				{
					color2 = Color.white;
				}
				Rect rect = GUILayoutUtility.GetRect(28f, 36f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) });
				GUI.color = color2;
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + 4f, 28f, 28f), (Texture)(object)value.icon);
				GUI.color = color;
				Color backgroundColor = GUI.backgroundColor;
				GUI.backgroundColor = ((selectedType == category2.Key) ? Accent : Color.gray);
				if (GUILayout.Button(category2.Key, row, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(235f) }))
				{
					selectedType = category2.Key;
					hexDraft = value.color.Value.TrimStart('#');
					colorError = "";
					GUI.FocusControl((string)null);
				}
				GUI.backgroundColor = backgroundColor;
				GUILayout.EndHorizontal();
			}
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Show all", button, Array.Empty<GUILayoutOption>()))
			{
				foreach (Category value2 in categories.Values)
				{
					value2.enabled.Value = true;
				}
			}
			if (GUILayout.Button("Hide all", button, Array.Empty<GUILayoutOption>()))
			{
				foreach (Category value3 in categories.Values)
				{
					value3.enabled.Value = false;
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
			GUILayout.Space(25f);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(315f) });
			Category category = categories[selectedType];
			GUILayout.Label(selectedType, section, Array.Empty<GUILayoutOption>());
			DrawPreview(category, useSize: false);
			GUILayout.Space(10f);
			GUILayout.Label("Color", section, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			string text = GUILayout.TextField(hexDraft, 7, field, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
			if (text != hexDraft)
			{
				hexDraft = text;
				colorError = "";
			}
			if (GUILayout.Button("Apply hex", button, Array.Empty<GUILayoutOption>()))
			{
				if (TryReadColor(hexDraft, out var color3))
				{
					SetColor(category, color3);
				}
				else
				{
					colorError = "Enter six hex digits, e.g. B8A8D8.";
				}
			}
			GUILayout.EndHorizontal();
			if (colorError.Length > 0)
			{
				GUILayout.Label(colorError, small, Array.Empty<GUILayoutOption>());
			}
			if (!TryReadColor(category.color.Value, out var color4))
			{
				color4 = Color.white;
			}
			float num = ColorSlider("Red", color4.r);
			float num2 = ColorSlider("Green", color4.g);
			float num3 = ColorSlider("Blue", color4.b);
			if (num != color4.r || num2 != color4.g || num3 != color4.b)
			{
				SetColor(category, new Color(num, num2, num3));
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			string[] array = new string[5] { "E5E5E5", "B8A8D8", "9FB9A8", "C6B58F", "99B6C7" };
			for (int i = 0; i < array.Length; i++)
			{
				TryReadColor(array[i], out var color5);
				Color backgroundColor2 = GUI.backgroundColor;
				GUI.backgroundColor = color5;
				if (GUILayout.Button(" ", button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) }))
				{
					SetColor(category, color5);
				}
				GUI.backgroundColor = backgroundColor2;
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(12f);
			if (GUILayout.Button("Reset this type", button, Array.Empty<GUILayoutOption>()))
			{
				category.enabled.Value = true;
				category.color.Value = (string)((ConfigEntryBase)category.color).DefaultValue;
				hexDraft = category.color.Value;
				colorError = "";
			}
			GUILayout.Label("Custom PNGs in the Icons folder override the built-in symbols after restarting.", small, Array.Empty<GUILayoutOption>());
			GUILayout.EndVertical();
		}

		private float ColorSlider(string label, float value)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(45f) });
			float num = GUILayout.HorizontalSlider(value, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(198f) });
			GUILayout.Label(Mathf.RoundToInt(num * 255f).ToString(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(38f) });
			GUILayout.EndHorizontal();
			return num;
		}

		private void SetColor(Category category, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			category.color.Value = ColorUtility.ToHtmlStringRGB(color);
			hexDraft = category.color.Value;
			colorError = "";
		}

		private void DrawPreview(Category category, bool useSize)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(100f, 110f);
			Color color = GUI.color;
			if (!TryReadColor(category.color.Value, out var color2))
			{
				color2 = Color.white;
			}
			float num = (useSize ? scale.Value : 52f);
			GUI.color = color2;
			GUI.DrawTexture(new Rect(((Rect)(ref rect)).center.x - num / 2f, ((Rect)(ref rect)).y + 8f, num, num), (Texture)(object)category.icon);
			GUI.color = color;
			GUIStyle val = new GUIStyle(small)
			{
				alignment = (TextAnchor)1
			};
			val.normal.textColor = color2;
			string text = (labels.Value ? selectedType : "");
			if (distances.Value)
			{
				text = text + ((text.Length > 0) ? "\n" : "") + "128 m";
			}
			GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + num + 14f, ((Rect)(ref rect)).width, 42f), text, val);
		}

		private void Awake()
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Expected O, but got Unknown
			modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show map-wide location markers.");
			labels = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show names", true, "Show localized interactable names.");
			distances = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show distance", true, "Show distance in meters.");
			edgeMarkers = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Screen edge markers", true, "Keep off-screen locations visible at the screen edge.");
			showBusy = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Show temporarily unavailable", false, "Show unavailable interactables. Off hides exhausted shrines, opened chests, and busy printers.");
			toggle = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Toggle shortcut", new KeyboardShortcut((KeyCode)104, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), "Toggle all markers; F8 opens the settings panel.");
			scale = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Icon size", 24f, new ConfigDescription("Icon size in pixels at 1080p.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(12f, 64f), Array.Empty<object>()));
			height = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Height offset", 2f, new ConfigDescription("Height above interactable.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			range = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "Maximum distance", 0f, new ConfigDescription("0 means unlimited distance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5000f), Array.Empty<object>()));
			refresh = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Scan interval", 1f, new ConfigDescription("Seconds between scene scans. No prefab cloning or per-frame object scans.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 10f), Array.Empty<object>()));
			foreach (KeyValuePair<string, string> item in new Dictionary<string, string>
			{
				["Teleporter"] = "FF6B6B",
				["Newt altar"] = "8BCBFF",
				["Shrine"] = "B494FF",
				["Chest"] = "F4E7BA",
				["Void"] = "DE7EFF",
				["Printer"] = "7BE0F2",
				["Scrapper"] = "7BE0A4",
				["Cauldron"] = "8BCBFF",
				["Drone"] = "EAC66B",
				["Other"] = "EEEEEE"
			})
			{
				Category category = new Category
				{
					enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Interactables", item.Key, true, "Show this marker type."),
					color = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", item.Key, item.Value, "Hex RGB color, e.g. FF6B6B.")
				};
				category.icon = LoadIcon(item.Key);
				categories.Add(item.Key, category);
			}
			oldSaveOnSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			((BaseUnityPlugin)this).Config.SettingChanged += SettingsChanged;
			SceneManager.activeSceneChanged += SceneChanged;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Location markers loaded. Ctrl+H toggles markers; F8 opens settings.");
		}

		private Texture2D LoadIcon(string category)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Icons", category.Replace(' ', '_') + ".png");
			if (File.Exists(text))
			{
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (ImageConversion.LoadImage(val, File.ReadAllBytes(text)))
				{
					return val;
				}
				Object.Destroy((Object)(object)val);
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Invalid custom marker icon: " + text));
			}
			return MarkerArt.Create(category);
		}

		private void SceneChanged(Scene oldScene, Scene newScene)
		{
			SetSettings(open: false);
			markers.Clear();
			nextScan = 0f;
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = toggle.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				hidden = !hidden;
			}
			if (Input.GetKeyDown((KeyCode)289))
			{
				SetSettings(!settings);
			}
			if (settings && Input.GetKeyDown((KeyCode)27))
			{
				SetSettings(open: false);
			}
			SyncMenuInput();
			if (configDirty && Time.unscaledTime >= saveAfter)
			{
				SaveSettings();
			}
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				markers.Clear();
			}
			else if (Time.unscaledTime >= nextScan)
			{
				nextScan = Time.unscaledTime + refresh.Value;
				Scan();
			}
		}

		private void Scan()
		{
			markers.Clear();
			PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>();
			foreach (PurchaseInteraction val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && !string.IsNullOrEmpty(val.displayNameToken))
				{
					string category = Classify(((Object)((Component)val).gameObject).name, val.displayNameToken);
					markers.Add(new Marker
					{
						owner = (Component)(object)val,
						purchase = val,
						category = category,
						label = Language.GetString(val.displayNameToken)
					});
				}
			}
			TeleporterInteraction[] array2 = Object.FindObjectsOfType<TeleporterInteraction>();
			foreach (TeleporterInteraction val2 in array2)
			{
				markers.Add(new Marker
				{
					owner = (Component)(object)val2,
					teleporter = val2,
					category = "Teleporter",
					label = Language.GetString("TELEPORTER_NAME")
				});
			}
		}

		public static string Classify(string objectName, string token)
		{
			string text = (objectName + " " + token).ToLowerInvariant();
			if (text.Contains("newt"))
			{
				return "Newt altar";
			}
			if (text.Contains("void"))
			{
				return "Void";
			}
			if (text.Contains("duplicator") || text.Contains("printer"))
			{
				return "Printer";
			}
			if (text.Contains("scrapper"))
			{
				return "Scrapper";
			}
			if (text.Contains("cauldron") || text.Contains("cleanse"))
			{
				return "Cauldron";
			}
			if (text.Contains("shrine"))
			{
				return "Shrine";
			}
			if (text.Contains("chest") || text.Contains("lockbox") || text.Contains("barrel") || text.Contains("multishop"))
			{
				return "Chest";
			}
			if (text.Contains("drone"))
			{
				return "Drone";
			}
			return "Other";
		}

		private void OnGUI()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_0050: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			if (settings)
			{
				DrawSettingsWindow();
			}
			if (!Object.op_Implicit((Object)(object)Run.instance) || !modEnabled.Value || hidden || (int)Event.current.type != 7)
			{
				return;
			}
			if (textStyle == null)
			{
				textStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)1,
					fontSize = 12,
					fontStyle = (FontStyle)1
				};
			}
			foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && Object.op_Implicit((Object)(object)readOnlyInstances.sceneCam) && readOnlyInstances.localUserViewer != null && !readOnlyInstances.localUserViewer.isUIFocused && Object.op_Implicit((Object)(object)readOnlyInstances.hud) && ((Component)readOnlyInstances.hud).gameObject.activeInHierarchy)
				{
					DrawMarkers(readOnlyInstances.sceneCam);
				}
			}
		}

		private void DrawMarkers(Camera camera)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.height / 1080f;
			float num2 = scale.Value * num;
			Rect pixelRect = camera.pixelRect;
			Vector2 center = ((Rect)(ref pixelRect)).center;
			float num3 = Mathf.Max(30f, num2 * 1.5f);
			Color color = GUI.color;
			Vector2 val3 = default(Vector2);
			Color white = default(Color);
			Rect val4 = default(Rect);
			foreach (Marker marker in markers)
			{
				if (!Object.op_Implicit((Object)(object)marker.owner) || !marker.owner.gameObject.activeInHierarchy || (Object.op_Implicit((Object)(object)marker.purchase) && !showBusy.Value && !marker.purchase.available) || (Object.op_Implicit((Object)(object)marker.teleporter) && marker.teleporter.isInFinalSequence))
				{
					continue;
				}
				Category category = categories[marker.category];
				if (!category.enabled.Value)
				{
					continue;
				}
				Vector3 val = marker.owner.transform.position + Vector3.up * height.Value;
				float num4 = Vector3.Distance(((Component)camera).transform.position, val);
				if (range.Value > 0f && num4 > range.Value)
				{
					continue;
				}
				Vector3 val2 = camera.WorldToScreenPoint(val);
				if (val2.z <= 0f || !((Rect)(ref pixelRect)).Contains(new Vector2(val2.x, val2.y)))
				{
					if (!edgeMarkers.Value)
					{
						continue;
					}
					((Vector2)(ref val3))..ctor(val2.x - center.x, val2.y - center.y);
					if (val2.z < 0f)
					{
						val3 = -val3;
					}
					if (((Vector2)(ref val3)).sqrMagnitude < 0.001f)
					{
						val3 = Vector2.down;
					}
					float num5 = Mathf.Min((((Rect)(ref pixelRect)).width / 2f - num3) / Mathf.Max(Mathf.Abs(val3.x), 0.001f), (((Rect)(ref pixelRect)).height / 2f - num3) / Mathf.Max(Mathf.Abs(val3.y), 0.001f));
					val2.x = center.x + val3.x * num5;
					val2.y = center.y + val3.y * num5;
				}
				val2.y = (float)Screen.height - val2.y;
				GUI.color = Color.black;
				GUI.DrawTexture(new Rect(val2.x - num2 / 2f - 2f, val2.y - num2 / 2f - 2f, num2 + 4f, num2 + 4f), (Texture)(object)category.icon);
				ColorUtility.TryParseHtmlString("#" + category.color.Value.TrimStart('#'), ref white);
				if (white.a == 0f)
				{
					white = Color.white;
				}
				GUI.color = white;
				GUI.DrawTexture(new Rect(val2.x - num2 / 2f, val2.y - num2 / 2f, num2, num2), (Texture)(object)category.icon);
				string text = (labels.Value ? marker.label : "");
				if (distances.Value)
				{
					text = text + ((text.Length == 0) ? "" : "\n") + Mathf.RoundToInt(num4) + " m";
				}
				if (text.Length > 0)
				{
					((Rect)(ref val4))..ctor(val2.x - 115f * num, val2.y + num2 / 2f, 230f * num, 50f * num);
					textStyle.fontSize = Mathf.Max(10, Mathf.RoundToInt(12f * num));
					GUI.color = Color.black;
					GUI.Label(new Rect(((Rect)(ref val4)).x + 1f, ((Rect)(ref val4)).y + 1f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), text, textStyle);
					GUI.color = white;
					GUI.Label(val4, text, textStyle);
				}
			}
			GUI.color = color;
		}

		private void OnDestroy()
		{
			SceneManager.activeSceneChanged -= SceneChanged;
			foreach (Category value in categories.Values)
			{
				if (Object.op_Implicit((Object)(object)value.icon))
				{
					Object.Destroy((Object)(object)value.icon);
				}
			}
			SetSettings(open: false);
			ReleaseMenuInput();
			ReleasePause();
			Harmony obj = menuHarmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			if ((Object)(object)activeSettings == (Object)(object)this)
			{
				activeSettings = null;
			}
			((BaseUnityPlugin)this).Config.SettingChanged -= SettingsChanged;
			if (Object.op_Implicit((Object)(object)panelPixel))
			{
				Object.Destroy((Object)(object)panelPixel);
			}
			if (configDirty)
			{
				SaveSettings();
			}
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = oldSaveOnSet;
			markers.Clear();
		}
	}
}