Decompiled source of Minimap v1.1.0

Minimap.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using Mimic.Actors;
using Minimap;
using Minimap.API;
using Minimap.MimicUI;
using Minimap.MimicUI.Components;
using Minimap.ModCore;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "MiniMap", "1.1.0", "ToxesFoxes", null)]
[assembly: MelonGame("ReLUGames", "MIMESIS")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Minimap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+cea31e8f01fe192a3de43b03e59752ce2144262b")]
[assembly: AssemblyProduct("Minimap")]
[assembly: AssemblyTitle("Minimap")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 Minimap
{
	public class Core : MelonMod
	{
		[CompilerGenerated]
		private sealed class <RecreateMinimapAfterDelay>d__26 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			object? IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object? IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RecreateMinimapAfterDelay>d__26(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					CreateRoot();
					CreateCamera();
					CreateUI();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static GameObject? mapRootObj;

		private static Camera? mapCamera;

		private static RenderTexture? mapTexture;

		private static GameObject? mapCanvasObj;

		private static RawImage? mapImage;

		private static Transform? playerTransform;

		private static bool isVisible = false;

		private static bool isInDungeon = false;

		private static bool manualDungeonMode = false;

		private static InputAction? toggleAction;

		private static InputAction? settingsAction;

		private static ProtoActor? player;

		private static RectTransform? mapBgRect;

		private static SettingsPage? settingsPage;

		private static CursorLockMode _prevCursorLockMode = (CursorLockMode)1;

		private static bool _prevCursorVisible = false;

		private static readonly List<PlayerInput> _suspendedInputs = new List<PlayerInput>();

		private static readonly float cameraYOffset = 3f;

		private static readonly float nearClipPlane = 1f;

		private static readonly float farClipPlane = 20f;

		private const float zoomMin = 3f;

		private const float zoomMax = 40f;

		private static readonly Compass compass = new Compass();

		private static float OrthoFromZoom(float zoom)
		{
			return 43f - zoom;
		}

		public override void OnInitializeMelon()
		{
			Settings.Initialize();
			MelonLogger.Msg("MiniMap initialized. Press " + (Settings.ToggleKey?.Value ?? "F4") + " to toggle minimap.");
			SetupInput();
			SetupSettingsInput();
			SceneManager.sceneLoaded += OnSceneLoaded;
			MelonLogger.Msg("MiniMap setup complete.");
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			MelonLogger.Msg($"Scene loaded: {((Scene)(ref scene)).name}, minimap was visible: {isVisible}");
			playerTransform = null;
			SettingsInjector.Reset();
			settingsPage = null;
			DestroyUI();
			DestroyCamera();
			DestroyRoot();
			if (isVisible)
			{
				MelonLogger.Msg("Recreating minimap after scene load...");
				MelonCoroutines.Start(RecreateMinimapAfterDelay());
			}
		}

		[IteratorStateMachine(typeof(<RecreateMinimapAfterDelay>d__26))]
		private static IEnumerator RecreateMinimapAfterDelay()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RecreateMinimapAfterDelay>d__26(0);
		}

		private static void SetupInput()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			InputAction? obj = toggleAction;
			if (obj != null)
			{
				InputActionMap actionMap = obj.actionMap;
				if (actionMap != null)
				{
					actionMap.Disable();
				}
			}
			InputActionMap val = new InputActionMap("MiniMap");
			toggleAction = InputActionSetupExtensions.AddAction(val, "Toggle", (InputActionType)0, Settings.GetToggleBinding(), (string)null, (string)null, (string)null, (string)null);
			toggleAction.performed += delegate
			{
				ToggleMap();
			};
			val.Enable();
		}

		public static void RefreshToggleKey()
		{
			SetupInput();
		}

		public static void RefreshSettingsKey()
		{
			SetupSettingsInput();
		}

		private static void SetupSettingsInput()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			InputAction? obj = settingsAction;
			if (obj != null)
			{
				InputActionMap actionMap = obj.actionMap;
				if (actionMap != null)
				{
					actionMap.Disable();
				}
			}
			InputActionMap val = new InputActionMap("MiniMap_Settings");
			settingsAction = InputActionSetupExtensions.AddAction(val, "OpenSettings", (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null);
			int num = Mathf.Clamp(Settings.SettingsModifier?.Value ?? 1, 0, Settings.ModifierPaths.Length - 1);
			string text = Settings.ModifierPaths[num];
			if (num == 0)
			{
				InputActionSetupExtensions.AddBinding(settingsAction, Settings.GetSettingsKeyPath(), (string)null, (string)null, (string)null);
			}
			else
			{
				CompositeSyntax val2 = InputActionSetupExtensions.AddCompositeBinding(settingsAction, "ButtonWithOneModifier", (string)null, (string)null);
				val2 = ((CompositeSyntax)(ref val2)).With("Modifier", text, (string)null, (string)null);
				((CompositeSyntax)(ref val2)).With("Button", Settings.GetSettingsKeyPath(), (string)null, (string)null);
			}
			settingsAction.performed += delegate
			{
				ToggleSettingsPanel();
			};
			val.Enable();
		}

		private static void CreateSettingsUI()
		{
			Transform topCanvas = UIManagerAPI.GetTopCanvas();
			if ((Object)(object)topCanvas == (Object)null)
			{
				MelonLogger.Warning("[MiniMap] Hub/UIManager/Canvas/1 - top not found, settings UI deferred.");
				return;
			}
			settingsPage = new SettingsPage(topCanvas);
			settingsPage.Hide();
			MelonLogger.Msg("[MiniMap] Settings UI created in Hub/UIManager/Canvas/1 - top.");
		}

		public static void ToggleSettingsPanel()
		{
			if (settingsPage == null || !settingsPage.IsValid)
			{
				settingsPage = null;
				CreateSettingsUI();
			}
			bool flag = settingsPage?.IsVisible ?? false;
			settingsPage?.Toggle();
			bool flag2 = settingsPage?.IsVisible ?? false;
			if (!flag && flag2)
			{
				OnSettingsOpened();
			}
			else if (flag && !flag2)
			{
				OnSettingsClosed();
			}
			MelonLogger.Msg("[MiniMap] Settings panel: " + (flag2 ? "shown" : "hidden"));
		}

		private static void OnSettingsOpened()
		{
			//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)
			_prevCursorLockMode = Cursor.lockState;
			_prevCursorVisible = Cursor.visible;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			_suspendedInputs.Clear();
			PlayerInput[] array = Object.FindObjectsByType<PlayerInput>((FindObjectsSortMode)0);
			foreach (PlayerInput val in array)
			{
				val.DeactivateInput();
				_suspendedInputs.Add(val);
			}
		}

		private static void OnSettingsClosed()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			Cursor.lockState = _prevCursorLockMode;
			Cursor.visible = _prevCursorVisible;
			foreach (PlayerInput suspendedInput in _suspendedInputs)
			{
				if ((Object)(object)suspendedInput != (Object)null)
				{
					suspendedInput.ActivateInput();
				}
			}
			_suspendedInputs.Clear();
		}

		public static void RefreshCompassVisibility()
		{
			compass.SetVisible(Settings.CompassVisible?.Value ?? true);
		}

		public static void RefreshMapPosition()
		{
			ApplyPosition(Settings.Position);
		}

		public static void RefreshMapZoom(float zoom)
		{
			if ((Object)(object)mapCamera != (Object)null)
			{
				mapCamera.orthographicSize = OrthoFromZoom(zoom);
			}
		}

		public static void RefreshMapSize(float size)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mapBgRect != (Object)null)
			{
				mapBgRect.sizeDelta = new Vector2(size, size);
			}
		}

		private static void DestroyUI()
		{
			if ((Object)(object)mapCanvasObj != (Object)null)
			{
				compass.DestroyCompass();
				Object.Destroy((Object)(object)mapCanvasObj);
				mapCanvasObj = null;
				mapImage = null;
				mapBgRect = null;
			}
		}

		private static void DestroyCamera()
		{
			if ((Object)(object)mapCamera != (Object)null)
			{
				if ((Object)(object)((Component)mapCamera).gameObject != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)mapCamera).gameObject);
				}
				mapCamera = null;
				mapTexture = null;
			}
		}

		private static void DestroyRoot()
		{
			if ((Object)(object)mapRootObj != (Object)null)
			{
				Object.Destroy((Object)(object)mapRootObj);
				mapRootObj = null;
			}
		}

		private static void ToggleMap()
		{
			isVisible = !isVisible;
			MelonLogger.Msg("Toggling MiniMap: " + (isVisible ? "Enabled" : "Disabled"));
			if (isVisible)
			{
				if ((Object)(object)mapRootObj == (Object)null)
				{
					CreateRoot();
				}
				if ((Object)(object)mapCamera == (Object)null)
				{
					CreateCamera();
				}
				if ((Object)(object)mapCanvasObj == (Object)null)
				{
					CreateUI();
				}
				if ((Object)(object)mapCamera != (Object)null)
				{
					((Behaviour)mapCamera).enabled = true;
				}
			}
			else
			{
				DestroyUI();
				DestroyCamera();
				DestroyRoot();
			}
		}

		private static void CreateRoot()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!((Object)(object)mapRootObj != (Object)null))
			{
				mapRootObj = new GameObject("MiniMapRoot");
				Object.DontDestroyOnLoad((Object)(object)mapRootObj);
			}
		}

		private static void CreateCamera()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00c9: Expected O, but got Unknown
			if (!((Object)(object)mapCamera != (Object)null))
			{
				if ((Object)(object)mapRootObj == (Object)null)
				{
					CreateRoot();
				}
				GameObject val = new GameObject("MiniMapCamera");
				val.transform.SetParent(mapRootObj.transform, false);
				mapCamera = val.AddComponent<Camera>();
				mapCamera.orthographic = true;
				mapCamera.orthographicSize = OrthoFromZoom(Settings.MapZoom?.Value ?? 33f);
				mapCamera.clearFlags = (CameraClearFlags)2;
				mapCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
				mapCamera.cullingMask = -1;
				mapTexture = new RenderTexture(512, 512, 16, (RenderTextureFormat)0);
				mapTexture.Create();
				mapCamera.targetTexture = mapTexture;
				mapCamera.nearClipPlane = (isInDungeon ? nearClipPlane : 0.1f);
				mapCamera.farClipPlane = (isInDungeon ? farClipPlane : 100f);
			}
		}

		private static void CreateUI()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_010b: 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_0136: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mapCanvasObj != (Object)null))
			{
				if ((Object)(object)mapRootObj == (Object)null)
				{
					CreateRoot();
				}
				mapCanvasObj = new GameObject("MiniMapCanvas");
				mapCanvasObj.transform.SetParent(mapRootObj.transform, false);
				mapCanvasObj.AddComponent<Canvas>().renderMode = (RenderMode)0;
				mapCanvasObj.AddComponent<CanvasScaler>();
				mapCanvasObj.AddComponent<GraphicRaycaster>();
				GameObject val = new GameObject("MiniMapBG");
				val.transform.SetParent(mapCanvasObj.transform, false);
				Image obj = val.AddComponent<Image>();
				((Graphic)obj).color = new Color(0f, 0f, 0f, 0.4f);
				RectTransform component = ((Component)obj).GetComponent<RectTransform>();
				float num = Settings.MapSize?.Value ?? 256f;
				component.sizeDelta = new Vector2(num, num);
				ApplyPosition(Settings.Position, component);
				mapBgRect = component;
				GameObject val2 = new GameObject("MiniMapImage");
				val2.transform.SetParent(val.transform, false);
				mapImage = val2.AddComponent<RawImage>();
				mapImage.texture = (Texture)(object)mapTexture;
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = new Vector2(5f, 5f);
				component2.offsetMax = new Vector2(-5f, -5f);
				compass.CreateCompass(val.transform);
				compass.SetVisible(Settings.CompassVisible?.Value ?? true);
			}
		}

		private static void ApplyPosition(MinimapPosition position, RectTransform? bgRect = null)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bgRect == (Object)null)
			{
				if ((Object)(object)mapCanvasObj == (Object)null)
				{
					return;
				}
				Transform val = mapCanvasObj.transform.Find("MiniMapBG");
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				bgRect = ((Component)val).GetComponent<RectTransform>();
				if ((Object)(object)bgRect == (Object)null)
				{
					return;
				}
			}
			switch (position)
			{
			case MinimapPosition.TopLeft:
				bgRect.anchorMin = new Vector2(0f, 1f);
				bgRect.anchorMax = new Vector2(0f, 1f);
				bgRect.pivot = new Vector2(0f, 1f);
				bgRect.anchoredPosition = new Vector2(10f, -10f);
				break;
			case MinimapPosition.TopCenter:
				bgRect.anchorMin = new Vector2(0.5f, 1f);
				bgRect.anchorMax = new Vector2(0.5f, 1f);
				bgRect.pivot = new Vector2(0.5f, 1f);
				bgRect.anchoredPosition = new Vector2(0f, -10f);
				break;
			case MinimapPosition.TopRight:
				bgRect.anchorMin = new Vector2(1f, 1f);
				bgRect.anchorMax = new Vector2(1f, 1f);
				bgRect.pivot = new Vector2(1f, 1f);
				bgRect.anchoredPosition = new Vector2(-10f, -10f);
				break;
			case MinimapPosition.MiddleLeft:
				bgRect.anchorMin = new Vector2(0f, 0.5f);
				bgRect.anchorMax = new Vector2(0f, 0.5f);
				bgRect.pivot = new Vector2(0f, 0.5f);
				bgRect.anchoredPosition = new Vector2(10f, 0f);
				break;
			case MinimapPosition.MiddleRight:
				bgRect.anchorMin = new Vector2(1f, 0.5f);
				bgRect.anchorMax = new Vector2(1f, 0.5f);
				bgRect.pivot = new Vector2(1f, 0.5f);
				bgRect.anchoredPosition = new Vector2(-10f, 0f);
				break;
			case MinimapPosition.BottomLeft:
				bgRect.anchorMin = new Vector2(0f, 0f);
				bgRect.anchorMax = new Vector2(0f, 0f);
				bgRect.pivot = new Vector2(0f, 0f);
				bgRect.anchoredPosition = new Vector2(10f, 10f);
				break;
			case MinimapPosition.BottomCenter:
				bgRect.anchorMin = new Vector2(0.5f, 0f);
				bgRect.anchorMax = new Vector2(0.5f, 0f);
				bgRect.pivot = new Vector2(0.5f, 0f);
				bgRect.anchoredPosition = new Vector2(0f, 10f);
				break;
			default:
				bgRect.anchorMin = new Vector2(1f, 0f);
				bgRect.anchorMax = new Vector2(1f, 0f);
				bgRect.pivot = new Vector2(1f, 0f);
				bgRect.anchoredPosition = new Vector2(-10f, 10f);
				break;
			case MinimapPosition.Manual:
				bgRect.anchorMin = new Vector2(0.5f, 0.5f);
				bgRect.anchorMax = new Vector2(0.5f, 0.5f);
				bgRect.pivot = new Vector2(0.5f, 0.5f);
				bgRect.anchoredPosition = new Vector2(Settings.MapPosX?.Value ?? 0f, Settings.MapPosY?.Value ?? 0f);
				break;
			}
		}

		public static ProtoActor? GetCurrentSpectatingActor()
		{
			ProtoActor[] alivePlayers = ActorAPI.GetAlivePlayers();
			if (alivePlayers == null)
			{
				return null;
			}
			if (alivePlayers.Length != 0)
			{
				CameraManager cameraManager = HubAPI.GetCameraManager();
				if ((Object)(object)cameraManager != (Object)null)
				{
					int? spectatorTargetActorID = cameraManager.SpectatorTargetActorID;
					if (spectatorTargetActorID.HasValue)
					{
						return ActorAPI.GetActorByID(spectatorTargetActorID);
					}
				}
			}
			return null;
		}

		public static bool IsActorInDungeon(ProtoActor? actor)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)actor == (Object)null)
			{
				return false;
			}
			MelonPreferences_Entry<bool>? dungeonModeAuto = Settings.DungeonModeAuto;
			if (dungeonModeAuto != null && !dungeonModeAuto.Value)
			{
				return manualDungeonMode;
			}
			if (actor == null)
			{
				return false;
			}
			Transform transform = ((Component)actor).transform;
			return ((transform != null) ? new float?(transform.position.y) : null) < -10f;
		}

		public static void SetManualDungeonMode(bool value)
		{
			manualDungeonMode = value;
		}

		public static void SetCurrentPlayer(ProtoActor? newPlayer)
		{
			ProtoActor val = player;
			player = newPlayer;
			isInDungeon = IsActorInDungeon(player);
			if ((Object)(object)newPlayer == (Object)null && (Object)(object)val != (Object)null)
			{
				MelonLogger.Msg("No player to follow on minimap.");
			}
			else if ((Object)(object)val == (Object)null && (Object)(object)newPlayer != (Object)null)
			{
				MelonLogger.Msg("Now following player " + ActorAPI.GetActorName(newPlayer) + " on minimap.");
			}
			else if (((val != null) ? new int?(val.ActorID) : null) != ((newPlayer != null) ? new int?(newPlayer.ActorID) : null))
			{
				MelonLogger.Msg("Current player changed to " + ActorAPI.GetActorName(newPlayer) + ".");
			}
		}

		public override void OnLateUpdate()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			SettingsInjector.TryInject();
			if (!isVisible || (Object)(object)mapCamera == (Object)null)
			{
				return;
			}
			ProtoActor localPlayer = ActorAPI.GetLocalPlayer();
			if ((Object)(object)localPlayer != (Object)null && localPlayer != null && localPlayer.dead)
			{
				ProtoActor currentSpectatingActor = GetCurrentSpectatingActor();
				if (!((Object)(object)currentSpectatingActor != (Object)null))
				{
					SetCurrentPlayer(null);
					return;
				}
				SetCurrentPlayer(currentSpectatingActor);
			}
			else
			{
				SetCurrentPlayer(localPlayer);
			}
			if (!Object.op_Implicit((Object)(object)player))
			{
				return;
			}
			playerTransform = ((Component)player).transform;
			if ((Object)(object)playerTransform != (Object)null)
			{
				Vector3 position = playerTransform.position;
				float num = position.y + cameraYOffset;
				Vector3 position2 = default(Vector3);
				((Vector3)(ref position2))..ctor(position.x, Mathf.Round(num), position.z);
				((Component)mapCamera).transform.position = position2;
				((Component)mapCamera).transform.rotation = Quaternion.Euler(90f, playerTransform.eulerAngles.y, 0f);
				mapCamera.nearClipPlane = (isInDungeon ? nearClipPlane : 0.1f);
				mapCamera.farClipPlane = (isInDungeon ? farClipPlane : 100f);
			}
			if ((Object)(object)mapImage != (Object)null)
			{
				if (isInDungeon)
				{
					Material val = new Material(Shader.Find("UI/Default"));
					val.color = new Color(0f, 1f, 0f, 1f);
					((Graphic)mapImage).material = val;
				}
				else
				{
					((Graphic)mapImage).material = null;
				}
			}
			compass.UpdateCompass(player);
		}
	}
}
namespace Minimap.MimicUI
{
	internal class SettingsPage
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__13_0;

			public static Action<string> <>9__13_1;

			public static Action<int> <>9__13_2;

			public static Action<string> <>9__13_3;

			public static Action<bool> <>9__13_4;

			public static Action<bool> <>9__13_5;

			public static Action<float> <>9__13_7;

			public static Action<float> <>9__13_8;

			public static Action<float> <>9__13_9;

			public static Action<float> <>9__13_10;

			internal void <Build>b__13_0()
			{
				Core.ToggleSettingsPanel();
			}

			internal void <Build>b__13_1(string key)
			{
				if (Settings.SettingsKey != null)
				{
					Settings.SettingsKey.Value = key;
				}
				Core.RefreshSettingsKey();
			}

			internal void <Build>b__13_2(int v)
			{
				if (Settings.SettingsModifier != null)
				{
					Settings.SettingsModifier.Value = v;
				}
				Core.RefreshSettingsKey();
			}

			internal void <Build>b__13_3(string key)
			{
				if (Settings.ToggleKey != null)
				{
					Settings.ToggleKey.Value = key;
				}
				Core.RefreshToggleKey();
			}

			internal void <Build>b__13_4(bool v)
			{
				if (Settings.DungeonModeAuto != null)
				{
					Settings.DungeonModeAuto.Value = v;
				}
			}

			internal void <Build>b__13_5(bool v)
			{
				if (Settings.CompassVisible != null)
				{
					Settings.CompassVisible.Value = v;
				}
				Core.RefreshCompassVisibility();
			}

			internal void <Build>b__13_7(float v)
			{
				if (Settings.MapPosX != null)
				{
					Settings.MapPosX.Value = v;
				}
				Core.RefreshMapPosition();
			}

			internal void <Build>b__13_8(float v)
			{
				if (Settings.MapPosY != null)
				{
					Settings.MapPosY.Value = v;
				}
				Core.RefreshMapPosition();
			}

			internal void <Build>b__13_9(float v)
			{
				if (Settings.MapSize != null)
				{
					Settings.MapSize.Value = v;
				}
				Core.RefreshMapSize(v);
			}

			internal void <Build>b__13_10(float v)
			{
				if (Settings.MapZoom != null)
				{
					Settings.MapZoom.Value = v;
				}
				Core.RefreshMapZoom(v);
			}
		}

		private readonly GameObject _root;

		private bool _built;

		private UIKeyBind? _settingsKeyBind;

		private UIDropdown? _settingsModifierDropdown;

		private UIKeyBind? _toggleKeyBind;

		private UIToggle? _dungeonAutoToggle;

		private UIToggle? _compassToggle;

		private UIDropdown? _positionDropdown;

		private UISlider? _zoomSlider;

		private UISlider? _sizeSlider;

		private UISlider? _posXSlider;

		private UISlider? _posYSlider;

		public bool IsVisible => _root.activeSelf;

		public bool IsValid => (Object)(object)_root != (Object)null;

		public SettingsPage(Transform parent)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_003e: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject("MimicUI_MinimapSettings");
			_root.transform.SetParent(parent, false);
			RectTransform obj = _root.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(0.5f, 0.5f);
			obj.anchorMax = new Vector2(0.5f, 0.5f);
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.anchoredPosition = Vector2.zero;
			obj.sizeDelta = new Vector2(420f, 520f);
			Build();
		}

		private void Build()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_0132: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: 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_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: 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_01e6: Expected O, but got Unknown
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_081d: Unknown result type (might be due to invalid IL or missing references)
			if (_built)
			{
				return;
			}
			_built = true;
			((Graphic)_root.AddComponent<Image>()).color = new Color(0.08f, 0.08f, 0.08f, 0.25f);
			RectTransform obj = new GameObject("Title").AddComponent<RectTransform>();
			((Transform)obj).SetParent(_root.transform, false);
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.anchoredPosition = new Vector2(0f, -8f);
			obj.sizeDelta = new Vector2(0f, 36f);
			TextMeshProUGUI obj2 = ((Component)obj).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj2).text = "Minimap Settings";
			((TMP_Text)obj2).fontSize = 18f;
			((TMP_Text)obj2).fontStyle = (FontStyles)1;
			((Graphic)obj2).color = Color.white;
			((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
			GameObject val = new GameObject("CloseBtn");
			val.transform.SetParent(_root.transform, false);
			RectTransform obj3 = val.AddComponent<RectTransform>();
			obj3.anchorMin = new Vector2(1f, 1f);
			obj3.anchorMax = new Vector2(1f, 1f);
			obj3.pivot = new Vector2(1f, 1f);
			obj3.anchoredPosition = new Vector2(-4f, -4f);
			obj3.sizeDelta = new Vector2(30f, 30f);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.55f, 0.1f, 0.1f, 0.9f);
			Button obj4 = val.AddComponent<Button>();
			((Selectable)obj4).targetGraphic = (Graphic)(object)val2;
			ButtonClickedEvent onClick = obj4.onClick;
			object obj5 = <>c.<>9__13_0;
			if (obj5 == null)
			{
				UnityAction val3 = delegate
				{
					Core.ToggleSettingsPanel();
				};
				<>c.<>9__13_0 = val3;
				obj5 = (object)val3;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj5);
			GameObject val4 = new GameObject("Lbl");
			val4.transform.SetParent(val.transform, false);
			RectTransform obj6 = val4.AddComponent<RectTransform>();
			obj6.anchorMin = Vector2.zero;
			obj6.anchorMax = Vector2.one;
			obj6.offsetMin = Vector2.zero;
			obj6.offsetMax = Vector2.zero;
			TextMeshProUGUI obj7 = val4.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj7).text = "×";
			((TMP_Text)obj7).fontSize = 18f;
			((Graphic)obj7).color = Color.white;
			((TMP_Text)obj7).alignment = (TextAlignmentOptions)514;
			RectTransform val5 = new GameObject("Content").AddComponent<RectTransform>();
			((Transform)val5).SetParent(_root.transform, false);
			val5.anchorMin = new Vector2(0f, 0f);
			val5.anchorMax = new Vector2(1f, 1f);
			val5.offsetMin = new Vector2(12f, 8f);
			val5.offsetMax = new Vector2(-12f, -52f);
			VerticalLayoutGroup obj8 = ((Component)val5).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj8).spacing = 6f;
			((LayoutGroup)obj8).childAlignment = (TextAnchor)1;
			((HorizontalOrVerticalLayoutGroup)obj8).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj8).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj8).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj8).childForceExpandHeight = false;
			_settingsKeyBind = new UIKeyBind("SettingsKey", (Transform)(object)val5, "Settings Key", Settings.SettingsKey?.Value ?? "M");
			_settingsKeyBind.Rect.sizeDelta = new Vector2(0f, 36f);
			_settingsKeyBind.OnKeyChanged += delegate(string key)
			{
				if (Settings.SettingsKey != null)
				{
					Settings.SettingsKey.Value = key;
				}
				Core.RefreshSettingsKey();
			};
			_settingsModifierDropdown = new UIDropdown("SettingsModifier", (Transform)(object)val5, "Settings Modifier", new List<string>(Settings.ModifierNames), Settings.SettingsModifier?.Value ?? 1);
			_settingsModifierDropdown.Rect.sizeDelta = new Vector2(0f, 36f);
			_settingsModifierDropdown.OnValueChanged += delegate(int v)
			{
				if (Settings.SettingsModifier != null)
				{
					Settings.SettingsModifier.Value = v;
				}
				Core.RefreshSettingsKey();
			};
			_toggleKeyBind = new UIKeyBind("ToggleKey", (Transform)(object)val5, "Toggle Key", Settings.ToggleKey?.Value ?? "F4");
			_toggleKeyBind.Rect.sizeDelta = new Vector2(0f, 36f);
			_toggleKeyBind.OnKeyChanged += delegate(string key)
			{
				if (Settings.ToggleKey != null)
				{
					Settings.ToggleKey.Value = key;
				}
				Core.RefreshToggleKey();
			};
			_dungeonAutoToggle = new UIToggle("DungeonAuto", (Transform)(object)val5, "Auto Dungeon Mode", Settings.DungeonModeAuto?.Value ?? true);
			_dungeonAutoToggle.Rect.sizeDelta = new Vector2(0f, 36f);
			_dungeonAutoToggle.OnValueChanged += delegate(bool v)
			{
				if (Settings.DungeonModeAuto != null)
				{
					Settings.DungeonModeAuto.Value = v;
				}
			};
			_compassToggle = new UIToggle("CompassVisible", (Transform)(object)val5, "Show Compass", Settings.CompassVisible?.Value ?? true);
			_compassToggle.Rect.sizeDelta = new Vector2(0f, 36f);
			_compassToggle.OnValueChanged += delegate(bool v)
			{
				if (Settings.CompassVisible != null)
				{
					Settings.CompassVisible.Value = v;
				}
				Core.RefreshCompassVisibility();
			};
			List<string> options = new List<string> { "Top Left", "Top Center", "Top Right", "Middle Left", "Middle Right", "Bottom Left", "Bottom Center", "Bottom Right", "Manual" };
			_positionDropdown = new UIDropdown("MapPosition", (Transform)(object)val5, "Map Position", options, Settings.MapPosition?.Value ?? 7);
			_positionDropdown.Rect.sizeDelta = new Vector2(0f, 36f);
			_positionDropdown.OnValueChanged += delegate(int v)
			{
				bool active2 = v == 8;
				_posXSlider?.SetActive(active2);
				_posYSlider?.SetActive(active2);
				if (Settings.MapPosition != null)
				{
					Settings.MapPosition.Value = v;
				}
				Core.RefreshMapPosition();
			};
			_posXSlider = new UISlider("MapPosX", (Transform)(object)val5, "Position X", -960f, 960f, Settings.MapPosX?.Value ?? 0f);
			_posXSlider.Rect.sizeDelta = new Vector2(0f, 36f);
			_posXSlider.OnValueChanged += delegate(float v)
			{
				if (Settings.MapPosX != null)
				{
					Settings.MapPosX.Value = v;
				}
				Core.RefreshMapPosition();
			};
			_posYSlider = new UISlider("MapPosY", (Transform)(object)val5, "Position Y", -540f, 540f, Settings.MapPosY?.Value ?? 0f);
			_posYSlider.Rect.sizeDelta = new Vector2(0f, 36f);
			_posYSlider.OnValueChanged += delegate(float v)
			{
				if (Settings.MapPosY != null)
				{
					Settings.MapPosY.Value = v;
				}
				Core.RefreshMapPosition();
			};
			bool active = (Settings.MapPosition?.Value ?? 7) == 8;
			_posXSlider.SetActive(active);
			_posYSlider.SetActive(active);
			_sizeSlider = new UISlider("MapSize", (Transform)(object)val5, "Map Size", 100f, 512f, Settings.MapSize?.Value ?? 256f);
			_sizeSlider.Rect.sizeDelta = new Vector2(0f, 36f);
			_sizeSlider.OnValueChanged += delegate(float v)
			{
				if (Settings.MapSize != null)
				{
					Settings.MapSize.Value = v;
				}
				Core.RefreshMapSize(v);
			};
			_zoomSlider = new UISlider("MapZoom", (Transform)(object)val5, "Map Zoom", 3f, 40f, Settings.MapZoom?.Value ?? 33f);
			_zoomSlider.Rect.sizeDelta = new Vector2(0f, 36f);
			_zoomSlider.OnValueChanged += delegate(float v)
			{
				if (Settings.MapZoom != null)
				{
					Settings.MapZoom.Value = v;
				}
				Core.RefreshMapZoom(v);
			};
		}

		public void Show()
		{
			_root.SetActive(true);
		}

		public void Hide()
		{
			_root.SetActive(false);
		}

		public void Toggle()
		{
			if (IsVisible)
			{
				Hide();
			}
			else
			{
				Show();
			}
		}

		public void SyncFromSettings()
		{
			_toggleKeyBind?.GetType();
		}
	}
	internal abstract class UIElement
	{
		public GameObject GameObject { get; protected set; }

		public RectTransform Rect { get; protected set; }

		protected UIElement(string name, Transform parent)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			GameObject = new GameObject(name);
			GameObject.transform.SetParent(parent, false);
			Rect = GameObject.AddComponent<RectTransform>();
		}

		public void SetActive(bool active)
		{
			GameObject.SetActive(active);
		}

		protected void StretchToParent()
		{
			//IL_0006: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Rect.anchorMin = Vector2.zero;
			Rect.anchorMax = Vector2.one;
			Rect.offsetMin = Vector2.zero;
			Rect.offsetMax = Vector2.zero;
		}

		protected static RectTransform CreateChild(string name, Transform parent)
		{
			//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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			return val.AddComponent<RectTransform>();
		}

		protected Image AddBackground(Color color)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Image obj = GameObject.AddComponent<Image>();
			((Graphic)obj).color = color;
			return obj;
		}
	}
}
namespace Minimap.MimicUI.Components
{
	internal class UIButton : UIElement
	{
		private readonly TextMeshProUGUI _label;

		private readonly Button _button;

		public UIButton(string name, Transform parent, string labelText, Action onClick)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			Action onClick2 = onClick;
			base..ctor(name + "Button", parent);
			RectTransform val = UIElement.CreateChild(name, base.GameObject.transform);
			Image val2 = ((Component)val).gameObject.AddComponent<Image>();
			Sprite val3 = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == "MM_Title_Menu_Selected"));
			if ((Object)(object)val3 != (Object)null)
			{
				val2.sprite = val3;
			}
			val2.type = (Type)1;
			((Graphic)val2).raycastPadding = new Vector4(0f, 25f, 0f, 25f);
			((Graphic)val2).color = new Color(1f, 1f, 1f, 0f);
			_button = ((Component)val).gameObject.AddComponent<Button>();
			((Selectable)_button).targetGraphic = (Graphic)(object)val2;
			((Selectable)_button).transition = (Transition)0;
			((UnityEvent)_button.onClick).AddListener((UnityAction)delegate
			{
				onClick2();
			});
			((Component)val).gameObject.AddComponent<LayoutElement>();
			HorizontalLayoutGroup obj = ((Component)val).gameObject.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false;
			((LayoutGroup)obj).childAlignment = (TextAnchor)3;
			ContentSizeFitter obj2 = ((Component)val).gameObject.AddComponent<ContentSizeFitter>();
			obj2.horizontalFit = (FitMode)2;
			obj2.verticalFit = (FitMode)0;
			((Component)val).gameObject.AddComponent<EventTrigger>();
			RectTransform val4 = UIElement.CreateChild("Text (TMP)", (Transform)(object)val);
			_label = ((Component)val4).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_label).text = labelText;
			((TMP_Text)_label).fontSize = 26f;
			((Graphic)_label).color = Color.white;
			((TMP_Text)_label).alignment = (TextAlignmentOptions)513;
			((TMP_Text)_label).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)_label).overflowMode = (TextOverflowModes)0;
			((TMP_Text)_label).margin = new Vector4(70f, 0f, 450f, 0f);
			((Component)val).gameObject.AddComponent<UIButtonHover>().Init(val2, _label, _button);
		}

		public void SetLabel(string text)
		{
			((TMP_Text)_label).text = text;
		}
	}
	internal class UIButtonHover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerDownHandler, IPointerUpHandler
	{
		[CompilerGenerated]
		private sealed class <FadeImageAlpha>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public UIButtonHover <>4__this;

			public float target;

			private float <start>5__2;

			private float <t>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FadeImageAlpha>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				UIButtonHover uIButtonHover = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<start>5__2 = ((Graphic)uIButtonHover._image).color.a;
					<t>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<t>5__3 += Time.unscaledDeltaTime;
					break;
				}
				if (<t>5__3 < 0.15f)
				{
					Color color = ((Graphic)uIButtonHover._image).color;
					color.a = Mathf.Lerp(<start>5__2, target, <t>5__3 / 0.15f);
					((Graphic)uIButtonHover._image).color = color;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				Color color2 = ((Graphic)uIButtonHover._image).color;
				color2.a = target;
				((Graphic)uIButtonHover._image).color = color2;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <FadeTextColor>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public UIButtonHover <>4__this;

			public Color target;

			private Color <start>5__2;

			private float <t>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FadeTextColor>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//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_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				UIButtonHover uIButtonHover = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<start>5__2 = ((Graphic)uIButtonHover._label).color;
					<t>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<t>5__3 += Time.unscaledDeltaTime;
					break;
				}
				if (<t>5__3 < 0.15f)
				{
					((Graphic)uIButtonHover._label).color = Color.Lerp(<start>5__2, target, <t>5__3 / 0.15f);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				((Graphic)uIButtonHover._label).color = target;
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static readonly Color HoverTextColor = new Color(0.1608f, 0.1137f, 0f, 1f);

		private const float FadeDuration = 0.15f;

		private Image _image;

		private TextMeshProUGUI _label;

		private Button _button;

		public void Init(Image image, TextMeshProUGUI label, Button button)
		{
			_image = image;
			_label = label;
			_button = button;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (((Selectable)_button).IsInteractable())
			{
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(FadeImageAlpha(1f));
				((MonoBehaviour)this).StartCoroutine(FadeTextColor(HoverTextColor));
			}
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (((Selectable)_button).IsInteractable())
			{
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(FadeImageAlpha(0f));
				((MonoBehaviour)this).StartCoroutine(FadeTextColor(Color.white));
			}
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			if (((Selectable)_button).IsInteractable())
			{
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(FadeImageAlpha(0f));
			}
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			if (((Selectable)_button).IsInteractable())
			{
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(FadeImageAlpha(1f));
			}
		}

		[IteratorStateMachine(typeof(<FadeImageAlpha>d__10))]
		private IEnumerator FadeImageAlpha(float target)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeImageAlpha>d__10(0)
			{
				<>4__this = this,
				target = target
			};
		}

		[IteratorStateMachine(typeof(<FadeTextColor>d__11))]
		private IEnumerator FadeTextColor(Color target)
		{
			//IL_000e: 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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FadeTextColor>d__11(0)
			{
				<>4__this = this,
				target = target
			};
		}
	}
	internal class UIDropdown : UIElement
	{
		private readonly TextMeshProUGUI _label;

		private readonly TextMeshProUGUI _valueText;

		private readonly Button _prevBtn;

		private readonly Button _nextBtn;

		private readonly List<string> _options;

		private int _selected;

		public int Value => _selected;

		public event Action<int>? OnValueChanged;

		public UIDropdown(string name, Transform parent, string labelText, List<string> options, int initialIndex)
			: base(name, parent)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Expected O, but got Unknown
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			base.Rect.sizeDelta = new Vector2(0f, 36f);
			base.Rect.anchorMin = new Vector2(0f, 0f);
			base.Rect.anchorMax = new Vector2(1f, 0f);
			_options = options;
			_selected = Mathf.Clamp(initialIndex, 0, options.Count - 1);
			AddBackground(new Color(0.15f, 0.15f, 0.15f, 0.8f));
			RectTransform val = UIElement.CreateChild("Label", base.GameObject.transform);
			_label = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_label).text = labelText;
			((TMP_Text)_label).fontSize = 14f;
			((Graphic)_label).color = Color.white;
			((TMP_Text)_label).alignment = (TextAlignmentOptions)4097;
			val.anchorMin = new Vector2(0f, 0f);
			val.anchorMax = new Vector2(0.45f, 1f);
			val.offsetMin = new Vector2(8f, 0f);
			val.offsetMax = Vector2.zero;
			RectTransform val2 = UIElement.CreateChild("PrevBtn", base.GameObject.transform);
			val2.anchorMin = new Vector2(0.45f, 0.1f);
			val2.anchorMax = new Vector2(0.55f, 0.9f);
			val2.offsetMin = new Vector2(2f, 0f);
			val2.offsetMax = new Vector2(-2f, 0f);
			Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.25f, 0.25f, 0.25f);
			_prevBtn = ((Component)val2).gameObject.AddComponent<Button>();
			((Selectable)_prevBtn).targetGraphic = (Graphic)(object)val3;
			((UnityEvent)_prevBtn.onClick).AddListener(new UnityAction(Prev));
			TextMeshProUGUI obj = ((Component)UIElement.CreateChild("Lbl", (Transform)(object)val2)).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj).text = "<";
			((TMP_Text)obj).fontSize = 14f;
			((Graphic)obj).color = Color.white;
			((TMP_Text)obj).alignment = (TextAlignmentOptions)514;
			RectTransform component = ((Component)obj).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			RectTransform val4 = UIElement.CreateChild("ValueText", base.GameObject.transform);
			val4.anchorMin = new Vector2(0.55f, 0.1f);
			val4.anchorMax = new Vector2(0.85f, 0.9f);
			val4.offsetMin = new Vector2(2f, 0f);
			val4.offsetMax = new Vector2(-2f, 0f);
			((Graphic)((Component)val4).gameObject.AddComponent<Image>()).color = new Color(0.2f, 0.2f, 0.2f);
			_valueText = ((Component)UIElement.CreateChild("Txt", (Transform)(object)val4)).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_valueText).text = _options[_selected];
			((TMP_Text)_valueText).fontSize = 12f;
			((Graphic)_valueText).color = Color.white;
			((TMP_Text)_valueText).alignment = (TextAlignmentOptions)514;
			RectTransform component2 = ((Component)_valueText).GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			RectTransform val5 = UIElement.CreateChild("NextBtn", base.GameObject.transform);
			val5.anchorMin = new Vector2(0.85f, 0.1f);
			val5.anchorMax = new Vector2(1f, 0.9f);
			val5.offsetMin = new Vector2(2f, 0f);
			val5.offsetMax = new Vector2(-8f, 0f);
			Image val6 = ((Component)val5).gameObject.AddComponent<Image>();
			((Graphic)val6).color = new Color(0.25f, 0.25f, 0.25f);
			_nextBtn = ((Component)val5).gameObject.AddComponent<Button>();
			((Selectable)_nextBtn).targetGraphic = (Graphic)(object)val6;
			((UnityEvent)_nextBtn.onClick).AddListener(new UnityAction(Next));
			TextMeshProUGUI obj2 = ((Component)UIElement.CreateChild("Lbl", (Transform)(object)val5)).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj2).text = ">";
			((TMP_Text)obj2).fontSize = 14f;
			((Graphic)obj2).color = Color.white;
			((TMP_Text)obj2).alignment = (TextAlignmentOptions)514;
			RectTransform component3 = ((Component)obj2).GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
		}

		private void Prev()
		{
			_selected = (_selected - 1 + _options.Count) % _options.Count;
			((TMP_Text)_valueText).text = _options[_selected];
			this.OnValueChanged?.Invoke(_selected);
		}

		private void Next()
		{
			_selected = (_selected + 1) % _options.Count;
			((TMP_Text)_valueText).text = _options[_selected];
			this.OnValueChanged?.Invoke(_selected);
		}

		public void SetValue(int index)
		{
			_selected = Mathf.Clamp(index, 0, _options.Count - 1);
			((TMP_Text)_valueText).text = _options[_selected];
		}
	}
	internal class UIKeyBind : UIElement
	{
		[CompilerGenerated]
		private sealed class <ListenForKeyPress>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public UIKeyBind <>4__this;

			private Keyboard <keyboard>5__2;

			private Key[] <allKeys>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ListenForKeyPress>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<keyboard>5__2 = null;
				<allKeys>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				UIKeyBind uIKeyBind = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<keyboard>5__2 = Keyboard.current;
					if (<keyboard>5__2 == null)
					{
						uIKeyBind._isListening = false;
						((TMP_Text)uIKeyBind._keyText).text = uIKeyBind._currentKey;
						((Graphic)uIKeyBind._keyText).color = Color.white;
						return false;
					}
					<allKeys>5__3 = (Key[])Enum.GetValues(typeof(Key));
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (uIKeyBind._isListening)
				{
					Key[] array = <allKeys>5__3;
					foreach (Key val in array)
					{
						if ((int)val != 0)
						{
							KeyControl val2 = <keyboard>5__2[val];
							if (val2 != null && ((ButtonControl)val2).wasPressedThisFrame)
							{
								string text = ((InputControl)val2).name.ToUpper();
								uIKeyBind._isListening = false;
								uIKeyBind._currentKey = text;
								((TMP_Text)uIKeyBind._keyText).text = text;
								((Graphic)uIKeyBind._keyText).color = Color.white;
								uIKeyBind.OnKeyChanged?.Invoke(text);
								return false;
							}
						}
					}
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private readonly TextMeshProUGUI _label;

		private readonly TextMeshProUGUI _keyText;

		private readonly Button _button;

		private string _currentKey;

		private bool _isListening;

		public string Value => _currentKey;

		public event Action<string>? OnKeyChanged;

		public UIKeyBind(string name, Transform parent, string labelText, string initialKey)
			: base(name, parent)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			base.Rect.sizeDelta = new Vector2(0f, 36f);
			base.Rect.anchorMin = new Vector2(0f, 0f);
			base.Rect.anchorMax = new Vector2(1f, 0f);
			_currentKey = initialKey;
			AddBackground(new Color(0.15f, 0.15f, 0.15f, 0.8f));
			RectTransform val = UIElement.CreateChild("Label", base.GameObject.transform);
			_label = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_label).text = labelText;
			((TMP_Text)_label).fontSize = 14f;
			((Graphic)_label).color = Color.white;
			((TMP_Text)_label).alignment = (TextAlignmentOptions)4097;
			val.anchorMin = new Vector2(0f, 0f);
			val.anchorMax = new Vector2(0.6f, 1f);
			val.offsetMin = new Vector2(8f, 0f);
			val.offsetMax = Vector2.zero;
			RectTransform val2 = UIElement.CreateChild("KeyBtn", base.GameObject.transform);
			val2.anchorMin = new Vector2(0.6f, 0.1f);
			val2.anchorMax = new Vector2(1f, 0.9f);
			val2.offsetMin = new Vector2(-2f, 0f);
			val2.offsetMax = new Vector2(-8f, 0f);
			Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.2f, 0.2f, 0.4f);
			_button = ((Component)val2).gameObject.AddComponent<Button>();
			((Selectable)_button).targetGraphic = (Graphic)(object)val3;
			((UnityEvent)_button.onClick).AddListener(new UnityAction(StartListening));
			RectTransform val4 = UIElement.CreateChild("KeyText", (Transform)(object)val2);
			_keyText = ((Component)val4).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_keyText).text = _currentKey;
			((TMP_Text)_keyText).fontSize = 13f;
			((Graphic)_keyText).color = Color.white;
			((TMP_Text)_keyText).alignment = (TextAlignmentOptions)514;
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
		}

		private void StartListening()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (!_isListening)
			{
				_isListening = true;
				((TMP_Text)_keyText).text = "...";
				((Graphic)_keyText).color = Color.yellow;
				MelonCoroutines.Start(ListenForKeyPress());
			}
		}

		[IteratorStateMachine(typeof(<ListenForKeyPress>d__10))]
		private IEnumerator ListenForKeyPress()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ListenForKeyPress>d__10(0)
			{
				<>4__this = this
			};
		}
	}
	internal class UISlider : UIElement
	{
		private readonly TextMeshProUGUI _label;

		private readonly TextMeshProUGUI _valueText;

		private readonly Slider _slider;

		public float Value => _slider.value;

		public event Action<float>? OnValueChanged;

		public UISlider(string name, Transform parent, string labelText, float min, float max, float initialValue)
			: base(name, parent)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: 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_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			base.Rect.sizeDelta = new Vector2(0f, 36f);
			base.Rect.anchorMin = new Vector2(0f, 0f);
			base.Rect.anchorMax = new Vector2(1f, 0f);
			AddBackground(new Color(0.15f, 0.15f, 0.15f, 0.8f));
			RectTransform val = UIElement.CreateChild("Label", base.GameObject.transform);
			_label = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_label).text = labelText;
			((TMP_Text)_label).fontSize = 14f;
			((Graphic)_label).color = Color.white;
			((TMP_Text)_label).alignment = (TextAlignmentOptions)4097;
			val.anchorMin = new Vector2(0f, 0f);
			val.anchorMax = new Vector2(0.35f, 1f);
			val.offsetMin = new Vector2(8f, 0f);
			val.offsetMax = Vector2.zero;
			RectTransform val2 = UIElement.CreateChild("ValueText", base.GameObject.transform);
			val2.anchorMin = new Vector2(0.85f, 0.1f);
			val2.anchorMax = new Vector2(1f, 0.9f);
			val2.offsetMin = new Vector2(2f, 0f);
			val2.offsetMax = new Vector2(-8f, 0f);
			_valueText = ((Component)val2).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_valueText).text = initialValue.ToString("F1");
			((TMP_Text)_valueText).fontSize = 12f;
			((Graphic)_valueText).color = Color.white;
			((TMP_Text)_valueText).alignment = (TextAlignmentOptions)514;
			RectTransform val3 = UIElement.CreateChild("Slider", base.GameObject.transform);
			val3.anchorMin = new Vector2(0.35f, 0.2f);
			val3.anchorMax = new Vector2(0.85f, 0.8f);
			val3.offsetMin = new Vector2(4f, 0f);
			val3.offsetMax = new Vector2(-4f, 0f);
			_slider = ((Component)val3).gameObject.AddComponent<Slider>();
			_slider.minValue = min;
			_slider.maxValue = max;
			_slider.value = initialValue;
			RectTransform obj = UIElement.CreateChild("Background", (Transform)(object)val3);
			obj.anchorMin = new Vector2(0f, 0.25f);
			obj.anchorMax = new Vector2(1f, 0.75f);
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			Image val4 = ((Component)obj).gameObject.AddComponent<Image>();
			((Graphic)val4).color = new Color(0.3f, 0.3f, 0.3f);
			((Selectable)_slider).targetGraphic = (Graphic)(object)val4;
			RectTransform val5 = UIElement.CreateChild("Fill Area", (Transform)(object)val3);
			val5.anchorMin = new Vector2(0f, 0.25f);
			val5.anchorMax = new Vector2(1f, 0.75f);
			val5.offsetMin = new Vector2(5f, 0f);
			val5.offsetMax = new Vector2(-5f, 0f);
			RectTransform val6 = UIElement.CreateChild("Fill", (Transform)(object)val5);
			val6.anchorMin = Vector2.zero;
			val6.anchorMax = new Vector2(0f, 1f);
			val6.offsetMin = Vector2.zero;
			val6.offsetMax = Vector2.zero;
			((Graphic)((Component)val6).gameObject.AddComponent<Image>()).color = new Color(0.3f, 0.6f, 0.9f);
			_slider.fillRect = val6;
			RectTransform val7 = UIElement.CreateChild("Handle Slide Area", (Transform)(object)val3);
			val7.anchorMin = Vector2.zero;
			val7.anchorMax = Vector2.one;
			val7.offsetMin = new Vector2(10f, 0f);
			val7.offsetMax = new Vector2(-10f, 0f);
			RectTransform val8 = UIElement.CreateChild("Handle", (Transform)(object)val7);
			val8.anchorMin = new Vector2(0f, 0f);
			val8.anchorMax = new Vector2(0f, 1f);
			val8.sizeDelta = new Vector2(20f, 0f);
			Image val9 = ((Component)val8).gameObject.AddComponent<Image>();
			((Graphic)val9).color = Color.white;
			_slider.handleRect = val8;
			((Selectable)_slider).targetGraphic = (Graphic)(object)val9;
			((UnityEvent<float>)(object)_slider.onValueChanged).AddListener((UnityAction<float>)delegate(float v)
			{
				((TMP_Text)_valueText).text = v.ToString("F1");
				this.OnValueChanged?.Invoke(v);
			});
		}

		public void SetValue(float value)
		{
			_slider.value = value;
			((TMP_Text)_valueText).text = value.ToString("F1");
		}
	}
	internal class UIToggle : UIElement
	{
		private readonly TextMeshProUGUI _label;

		private readonly TextMeshProUGUI _stateText;

		private readonly Button _button;

		private bool _value;

		public bool Value => _value;

		public event Action<bool>? OnValueChanged;

		public UIToggle(string name, Transform parent, string labelText, bool initialValue)
			: base(name, parent)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Expected O, but got Unknown
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			base.Rect.sizeDelta = new Vector2(0f, 36f);
			base.Rect.anchorMin = new Vector2(0f, 0f);
			base.Rect.anchorMax = new Vector2(1f, 0f);
			_value = initialValue;
			AddBackground(new Color(0.15f, 0.15f, 0.15f, 0.8f));
			RectTransform val = UIElement.CreateChild("Label", base.GameObject.transform);
			_label = ((Component)val).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_label).text = labelText;
			((TMP_Text)_label).fontSize = 14f;
			((Graphic)_label).color = Color.white;
			((TMP_Text)_label).alignment = (TextAlignmentOptions)4097;
			val.anchorMin = new Vector2(0f, 0f);
			val.anchorMax = new Vector2(0.75f, 1f);
			val.offsetMin = new Vector2(8f, 0f);
			val.offsetMax = new Vector2(0f, 0f);
			RectTransform val2 = UIElement.CreateChild("ToggleBtn", base.GameObject.transform);
			val2.anchorMin = new Vector2(0.75f, 0.1f);
			val2.anchorMax = new Vector2(1f, 0.9f);
			val2.offsetMin = new Vector2(-2f, 0f);
			val2.offsetMax = new Vector2(-8f, 0f);
			Image val3 = ((Component)val2).gameObject.AddComponent<Image>();
			((Graphic)val3).color = (_value ? new Color(0.2f, 0.7f, 0.2f) : new Color(0.5f, 0.1f, 0.1f));
			_button = ((Component)val2).gameObject.AddComponent<Button>();
			((Selectable)_button).targetGraphic = (Graphic)(object)val3;
			((UnityEvent)_button.onClick).AddListener(new UnityAction(Toggle));
			RectTransform val4 = UIElement.CreateChild("StateText", (Transform)(object)val2);
			_stateText = ((Component)val4).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_stateText).text = (_value ? "ON" : "OFF");
			((TMP_Text)_stateText).fontSize = 12f;
			((Graphic)_stateText).color = Color.white;
			((TMP_Text)_stateText).alignment = (TextAlignmentOptions)514;
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = Vector2.zero;
		}

		private void Toggle()
		{
			SetValue(!_value);
			this.OnValueChanged?.Invoke(_value);
		}

		public void SetValue(bool value)
		{
			//IL_0069: 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)
			_value = value;
			((TMP_Text)_stateText).text = (_value ? "ON" : "OFF");
			Image component = ((Component)_button).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).color = (_value ? new Color(0.2f, 0.7f, 0.2f) : new Color(0.5f, 0.1f, 0.1f));
			}
		}
	}
}
namespace Minimap.API
{
	internal class ActorAPI
	{
		public static ProtoActor? GetLocalPlayer()
		{
			return FindActorWhere((ProtoActor a) => a.AmIAvatar());
		}

		public static ProtoActor? GetActorByID(int? actorID)
		{
			if (!actorID.HasValue)
			{
				return null;
			}
			return FindActorWhere((ProtoActor a) => a.ActorID == actorID);
		}

		public static ProtoActor[]? GetAlivePlayers()
		{
			return FindActorsWhere((ProtoActor a) => !a.dead && (int)a.ActorType == 1);
		}

		public static ProtoActor[]? FindActorsWhere(Func<ProtoActor, bool> predicate)
		{
			try
			{
				return UnityObjectAPI.FindObjectsOfType<ProtoActor>().Where(predicate).ToArray();
			}
			catch
			{
				return null;
			}
		}

		public static ProtoActor? FindActorWhere(Func<ProtoActor, bool> predicate)
		{
			try
			{
				return UnityObjectAPI.FindObjectsOfType<ProtoActor>().FirstOrDefault(predicate);
			}
			catch
			{
				return null;
			}
		}

		public static string GetActorName(ProtoActor? actor)
		{
			if ((Object)(object)actor == (Object)null)
			{
				return "Unknown";
			}
			return actor.nickName;
		}
	}
	internal class HubAPI
	{
		public static Hub GetHub()
		{
			return Hub.s;
		}

		public static CameraManager? GetCameraManager()
		{
			Hub hub = GetHub();
			if (!((Object)(object)hub != (Object)null))
			{
				return null;
			}
			return Helpers.GetPropertyValue<CameraManager>(hub, "cameraman");
		}

		public static PersistentData? GetPersistentData()
		{
			Hub hub = GetHub();
			if (!((Object)(object)hub != (Object)null))
			{
				return null;
			}
			return Helpers.GetFieldValue<PersistentData>(hub, "pdata");
		}

		public static GamePlayScene? GetGamePlayScene()
		{
			GameMainBase obj = GetPersistentData()?.main;
			GamePlayScene val = (GamePlayScene)(object)((obj is GamePlayScene) ? obj : null);
			if (val != null)
			{
				return val;
			}
			return null;
		}
	}
	internal class UIManagerAPI
	{
		private const string GameSettingsPath = "Hub/UIManager/Canvas/1 - top/UIPrefab_GameSettings(Clone)";

		private const string TopCanvasPath = "Hub/UIManager/Canvas/1 - top";

		public static Transform? GetTopCanvas()
		{
			GameObject obj = GameObject.Find("Hub/UIManager/Canvas/1 - top");
			if (obj == null)
			{
				return null;
			}
			return obj.transform;
		}

		public static Transform? GetGameSettingsRoot()
		{
			GameObject val = GameObject.Find("Hub/UIManager/Canvas/1 - top/UIPrefab_GameSettings(Clone)");
			if ((Object)(object)val != (Object)null)
			{
				return val.transform;
			}
			RectTransform[] array = Object.FindObjectsByType<RectTransform>((FindObjectsSortMode)0);
			foreach (RectTransform val2 in array)
			{
				if (((Object)val2).name == "UIPrefab_GameSettings(Clone)")
				{
					return ((Component)val2).transform;
				}
			}
			return null;
		}
	}
	internal class UnityObjectAPI
	{
		public static T[] FindObjectsOfType<T>() where T : Component
		{
			return Object.FindObjectsByType<T>((FindObjectsSortMode)0);
		}
	}
}
namespace Minimap.ModCore
{
	internal class Compass
	{
		private List<Vector3> teleporterPositions = new List<Vector3>();

		private GameObject? compassObj;

		private Text? northText;

		private Text? eastText;

		private Text? southText;

		private Text? westText;

		private Vector2 offset = new Vector2(45f, -40f);

		private readonly int heightOffset = 36;

		private readonly int widthOffset = 36;

		private bool useTeleporterAngle;

		private float teleporterAngle;

		public void DestroyCompass()
		{
			if ((Object)(object)compassObj != (Object)null)
			{
				Object.Destroy((Object)(object)compassObj);
				compassObj = null;
				northText = (eastText = (southText = (westText = null)));
			}
		}

		public void SetVisible(bool visible)
		{
			if ((Object)(object)compassObj != (Object)null)
			{
				compassObj.SetActive(visible);
			}
		}

		public void UpdateCompass(ProtoActor actor)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)actor == (Object)null || (Object)(object)((Component)actor).transform == (Object)null)
			{
				return;
			}
			useTeleporterAngle = false;
			GamePlayScene gamePlayScene = HubAPI.GetGamePlayScene();
			if ((Object)(object)gamePlayScene != (Object)null)
			{
				teleporterPositions = ((GameMainBase)gamePlayScene).GetTeleporterPositions(gamePlayScene.CheckActorIsIndoor(actor));
				if (teleporterPositions.Count > 0)
				{
					useTeleporterAngle = true;
					teleporterAngle = CalculateTeleporterAngle(actor, teleporterPositions);
				}
			}
			float y = ((Component)actor).transform.eulerAngles.y;
			float baseAngle = (useTeleporterAngle ? teleporterAngle : (0f - y));
			UpdateCompassLabels(baseAngle);
		}

		private static float CalculateTeleporterAngle(ProtoActor actor, List<Vector3> teleporters)
		{
			//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_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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			float num = float.MaxValue;
			foreach (Vector3 teleporter in teleporters)
			{
				Vector3 val2 = ((Component)actor).transform.position - teleporter;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					val = teleporter;
				}
			}
			Vector3 val3 = val - ((Component)actor).transform.position;
			val3.y = 0f;
			Vector3 forward = ((Component)actor).transform.forward;
			float num2 = Vector3.Angle(val3, forward);
			if (Vector3.Cross(forward, val3).y < 0f)
			{
				num2 = 0f - num2;
			}
			return (num2 + 270f + 360f + 15f) % 360f;
		}

		public void CreateCompass(Transform bgObj)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0033: 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_0053: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			compassObj = new GameObject("MiniMapCompass");
			compassObj.transform.SetParent(((Component)bgObj).transform, false);
			RectTransform obj = compassObj.AddComponent<RectTransform>();
			obj.anchorMin = Vector2.zero;
			obj.anchorMax = Vector2.one;
			obj.pivot = new Vector2(0.5f, 0.5f);
			obj.offsetMin = Vector2.zero;
			obj.offsetMax = Vector2.zero;
			northText = CreateCompassLabel("N", compassObj.transform);
			eastText = CreateCompassLabel("E", compassObj.transform);
			southText = CreateCompassLabel("S", compassObj.transform);
			westText = CreateCompassLabel("W", compassObj.transform);
		}

		private Text CreateCompassLabel(string label, Transform parent)
		{
			//IL_000b: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Compass" + label);
			val.transform.SetParent(parent, false);
			Text obj = val.AddComponent<Text>();
			obj.text = label;
			obj.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			obj.fontSize = 18;
			((Graphic)obj).color = Color.white;
			RectTransform component = ((Component)obj).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			return obj;
		}

		private Vector2 GetCompassEdgePosition(float angleDeg, float w, float h, float margin)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			float num = (angleDeg + (useTeleporterAngle ? 70f : (-105f))) * (MathF.PI / 180f);
			float num2 = Mathf.Sin(num);
			float num3 = Mathf.Cos(num);
			float num4 = (w + (float)widthOffset) / 2f - margin;
			float num5 = (h + (float)heightOffset) / 2f - margin;
			float num6 = Mathf.Abs(num2);
			float num7 = Mathf.Abs(num3);
			float num8 = ((num6 * num5 > num7 * num4) ? (num4 / num6) : (num5 / num7));
			return new Vector2(num2 * num8, num3 * num8) + offset;
		}

		private void UpdateCompassLabels(float baseAngle)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)compassObj == (Object)null))
			{
				RectTransform component = compassObj.GetComponent<RectTransform>();
				Rect rect = component.rect;
				float width = ((Rect)(ref rect)).width;
				rect = component.rect;
				float height = ((Rect)(ref rect)).height;
				float margin = 16f;
				if ((Object)(object)northText != (Object)null)
				{
					((Graphic)northText).rectTransform.anchoredPosition = GetCompassEdgePosition(0f + baseAngle, width, height, margin);
				}
				if ((Object)(object)eastText != (Object)null)
				{
					((Graphic)eastText).rectTransform.anchoredPosition = GetCompassEdgePosition(90f + baseAngle, width, height, margin);
				}
				if ((Object)(object)southText != (Object)null)
				{
					((Graphic)southText).rectTransform.anchoredPosition = GetCompassEdgePosition(180f + baseAngle, width, height, margin);
				}
				if ((Object)(object)westText != (Object)null)
				{
					((Graphic)westText).rectTransform.anchoredPosition = GetCompassEdgePosition(270f + baseAngle, width, height, margin);
				}
			}
		}
	}
	internal class Helpers
	{
		private const BindingFlags DefaultFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static T? GetPropertyValue<T>(object target, string propertyName)
		{
			if (target == null)
			{
				return default(T);
			}
			PropertyInfo property = target.GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (property == null)
			{
				MelonLogger.Msg($"[Helpers] Property '{propertyName}' not found on target of type '{target.GetType()}'");
				return default(T);
			}
			object value = property.GetValue(target);
			if (value != null)
			{
				return (T)value;
			}
			return default(T);
		}

		public static object? GetFieldValue(object target, string fieldName)
		{
			return target?.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(target);
		}

		public static object? GetFieldValue(Type type, string fieldName)
		{
			return type.GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
		}

		public static T? GetFieldValue<T>(object target, string fieldName)
		{
			object fieldValue = GetFieldValue(target, fieldName);
			if (fieldValue != null)
			{
				return (T)fieldValue;
			}
			return default(T);
		}

		public static void SetFieldValue(object target, string fieldName, object value)
		{
			if (target != null)
			{
				FieldInfo field = target.GetType().GetField(fieldName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					field.SetValue(target, value);
				}
			}
		}

		public static object? InvokeMethod(object target, string methodName, params object[] parameters)
		{
			if (target == null)
			{
				return null;
			}
			MethodInfo method = target.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			if (method == null)
			{
				return null;
			}
			return method.Invoke(target, (parameters.Length != 0) ? parameters : null);
		}
	}
	public enum MinimapPosition
	{
		TopLeft,
		TopCenter,
		TopRight,
		MiddleLeft,
		MiddleRight,
		BottomLeft,
		BottomCenter,
		BottomRight,
		Manual
	}
	public static class Settings
	{
		private static MelonPreferences_Category? _category;

		public static readonly string[] ModifierNames = new string[7] { "None", "Left Shift", "Right Shift", "Left Ctrl", "Right Ctrl", "Left Alt", "Right Alt" };

		public static readonly string[] ModifierPaths = new string[7] { "", "<Keyboard>/leftShift", "<Keyboard>/rightShift", "<Keyboard>/leftCtrl", "<Keyboard>/rightCtrl", "<Keyboard>/leftAlt", "<Keyboard>/rightAlt" };

		public static MelonPreferences_Entry<string>? ToggleKey { get; private set; }

		public static MelonPreferences_Entry<bool>? DungeonModeAuto { get; private set; }

		public static MelonPreferences_Entry<bool>? CompassVisible { get; private set; }

		public static MelonPreferences_Entry<int>? MapPosition { get; private set; }

		public static MelonPreferences_Entry<float>? MapZoom { get; private set; }

		public static MelonPreferences_Entry<float>? MapSize { get; private set; }

		public static MelonPreferences_Entry<float>? MapPosX { get; private set; }

		public static MelonPreferences_Entry<float>? MapPosY { get; private set; }

		public static MelonPreferences_Entry<string>? SettingsKey { get; private set; }

		public static MelonPreferences_Entry<int>? SettingsModifier { get; private set; }

		public static MinimapPosition Position => (MinimapPosition)(MapPosition?.Value ?? 7);

		public static void Initialize()
		{
			_category = MelonPreferences.CreateCategory("Minimap");
			ToggleKey = _category.CreateEntry<string>("ToggleKey", "F4", "Toggle Key", (string)null, false, false, (ValueValidator)null, (string)null);
			DungeonModeAuto = _category.CreateEntry<bool>("DungeonModeAuto", true, "Auto Dungeon Mode", (string)null, false, false, (ValueValidator)null, (string)null);
			CompassVisible = _category.CreateEntry<bool>("CompassVisible", true, "Compass Visible", (string)null, false, false, (ValueValidator)null, (string)null);
			MapPosition = _category.CreateEntry<int>("MapPosition", 7, "Map Position", (string)null, false, false, (ValueValidator)null, (string)null);
			MapZoom = _category.CreateEntry<float>("MapZoom", 33f, "Map Zoom", (string)null, false, false, (ValueValidator)null, (string)null);
			MapSize = _category.CreateEntry<float>("MapSize", 256f, "Map Size", (string)null, false, false, (ValueValidator)null, (string)null);
			MapPosX = _category.CreateEntry<float>("MapPosX", 0f, "Map Position X", (string)null, false, false, (ValueValidator)null, (string)null);
			MapPosY = _category.CreateEntry<float>("MapPosY", 0f, "Map Position Y", (string)null, false, false, (ValueValidator)null, (string)null);
			SettingsKey = _category.CreateEntry<string>("SettingsKey", "M", "Settings Open Key", (string)null, false, false, (ValueValidator)null, (string)null);
			SettingsModifier = _category.CreateEntry<int>("SettingsModifier", 1, "Settings Modifier", (string)null, false, false, (ValueValidator)null, (string)null);
		}

		public static string GetToggleBinding()
		{
			string text = ToggleKey?.Value ?? "F4";
			return "<Keyboard>/" + text.ToLower();
		}

		public static string GetSettingsKeyPath()
		{
			string text = SettingsKey?.Value ?? "M";
			return "<Keyboard>/" + text.ToLower();
		}
	}
	internal static class SettingsInjector
	{
		private static bool _injected;

		public static void Reset()
		{
			_injected = false;
		}

		public static void TryInject()
		{
			//IL_0053: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (!_injected)
			{
				Transform gameSettingsRoot = UIManagerAPI.GetGameSettingsRoot();
				if (!((Object)(object)gameSettingsRoot == (Object)null))
				{
					UIButton uIButton = new UIButton("MinimapSettings", gameSettingsRoot, "Minimap", Core.ToggleSettingsPanel);
					uIButton.Rect.anchorMin = new Vector2(0f, 0f);
					uIButton.Rect.anchorMax = new Vector2(0f, 0f);
					uIButton.Rect.pivot = new Vector2(0f, 0f);
					uIButton.Rect.anchoredPosition = new Vector2(180f, 5f);
					uIButton.Rect.sizeDelta = new Vector2(180f, 40f);
					_injected = true;
					MelonLogger.Msg("[MiniMap] Button injected into UIPrefab_GameSettings.");
				}
			}
		}
	}
	internal static class Test
	{
		private const string TargetPath = "Hub/UIManager/Canvas/2 - main/UIPrefab_MainMenu(Clone)/Vertical Layout Group/Host";

		private static bool _done;

		private static int _searchTick;

		public static void TryRun()
		{
			if (!_done)
			{
				_searchTick++;
				if (_searchTick % 120 == 1)
				{
					MelonLogger.Msg(string.Format("[Test] Searching for '{0}' (tick {1})...", "Hub/UIManager/Canvas/2 - main/UIPrefab_MainMenu(Clone)/Vertical Layout Group/Host", _searchTick));
				}
				GameObject val = GameObject.Find("Hub/UIManager/Canvas/2 - main/UIPrefab_MainMenu(Clone)/Vertical Layout Group/Host");
				if (!((Object)(object)val == (Object)null))
				{
					_done = true;
					MelonLogger.Msg("[Test] Found 'Hub/UIManager/Canvas/2 - main/UIPrefab_MainMenu(Clone)/Vertical Layout Group/Host', dumping hierarchy...");
					LogGameObject(val, 0);
					MelonLogger.Msg("[Test] Dump complete.");
				}
			}
		}

		private static