Decompiled source of MapWarp v1.0.1

MapWarp.dll

Decompiled 13 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GlobalEnums;
using GlobalSettings;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using JetBrains.Annotations;
using MapWarp.Source.Toasts;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.ResourceManagement.ResourceProviders;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MapWarp")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+71c90e3fc42d76111cc44a65a4fd3557d9223fc6")]
[assembly: AssemblyProduct("MapWarp")]
[assembly: AssemblyTitle("MapWarp")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/jakobhellermann/silksongmod-MapWarp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace MapWarp.Source
{
	[HarmonyPatch]
	internal static class CompassAlways
	{
		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void IsEquipped(ToolItem __instance, ref bool __result)
		{
			if (MapWarpPlugin.AlwaysCompass.Value && (Object)(object)__instance == (Object)(object)Gameplay.CompassTool)
			{
				__result = true;
			}
		}
	}
	internal static class InstantMapOpen
	{
		private static bool captured;

		private static float origWait;

		private static float origFade;

		internal static void Apply()
		{
			try
			{
				bool value = MapWarpPlugin.InstantMapOpen.Value;
				PlayMakerFSM[] array = Object.FindObjectsByType<PlayMakerFSM>((FindObjectsInactive)1, (FindObjectsSortMode)0);
				foreach (PlayMakerFSM val in array)
				{
					if (val.FsmName != "Quick Map")
					{
						continue;
					}
					FsmFloat val2 = FindAction<Wait>(val, "Open")?.time;
					FsmFloat val3 = FindAction<FadeNestedFadeGroupV3>(val, "Has Map")?.FadeTime;
					if (val2 != null && val3 != null)
					{
						if (!captured)
						{
							origWait = val2.Value;
							origFade = val3.Value;
							captured = true;
						}
						val2.Value = (value ? 0f : origWait);
						val3.Value = (value ? 0f : origFade);
					}
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}

		private static T? FindAction<T>(PlayMakerFSM fsm, string stateName) where T : FsmStateAction
		{
			FsmState? obj = ((IEnumerable<FsmState>)fsm.FsmStates).FirstOrDefault((Func<FsmState, bool>)((FsmState s) => s.Name == stateName));
			if (obj == null)
			{
				return default(T);
			}
			return obj.Actions.OfType<T>().FirstOrDefault();
		}
	}
	[PublicAPI]
	internal static class Log
	{
		private static ManualLogSource? logSource;

		internal static void Init(ManualLogSource logSource)
		{
			Log.logSource = logSource;
		}

		internal static void Debug(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogError(data);
			}
		}

		internal static void Fatal(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogFatal(data);
			}
		}

		internal static void Info(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogInfo(data);
			}
		}

		internal static void Message(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogMessage(data);
			}
		}

		internal static void Warning(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogWarning(data);
			}
		}
	}
	[HarmonyPatch]
	internal static class MapLifecycle
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMap), "Start")]
		[UsedImplicitly]
		private static void Start()
		{
			Dispatch();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMap), "OnEnable")]
		[UsedImplicitly]
		private static void OnEnable()
		{
			Dispatch();
		}

		internal static void Dispatch()
		{
			Run(MapRoomBorders.Install);
			Run(InstantMapOpen.Apply);
		}

		private static void Run(Action handler)
		{
			try
			{
				handler();
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}
	}
	[RequireComponent(typeof(Camera))]
	public class MapNavigation : MonoBehaviour
	{
		private const float ZoomSpeed = 0.15f;

		private const float MinSize = 1f;

		private const float MaxSize = 30f;

		internal const float DefaultOrthoSize = 8.710664f;

		private Camera cam;

		private Camera? decoratorCam;

		private bool dragging;

		private Vector3 dragOrigin;

		private GUIStyle? previewStyle;

		private float prevSize = -1f;

		internal static bool MapOpen;

		[CompilerGenerated]
		private static Texture2D <DiamondTexture>k__BackingField;

		private static Texture2D DiamondTexture => <DiamondTexture>k__BackingField ?? (<DiamondTexture>k__BackingField = BuildDiamond(24, 3f));

		private void Awake()
		{
			cam = ((Component)this).GetComponent<Camera>();
			GameObject val = GameObject.Find("Decorator Camera");
			decoratorCam = (((Object)(object)val != (Object)null) ? val.GetComponent<Camera>() : null);
			ResetThis();
		}

		private void Update()
		{
			try
			{
				int mapOpen;
				if (Object.op_Implicit((Object)(object)cam))
				{
					Camera val = cam;
					if (val != null && ((Behaviour)val).enabled)
					{
						GameObject gameObject = ((Component)val).gameObject;
						if (gameObject != null)
						{
							mapOpen = (gameObject.activeInHierarchy ? 1 : 0);
							goto IL_0035;
						}
					}
					mapOpen = 0;
				}
				else
				{
					mapOpen = 0;
				}
				goto IL_0035;
				IL_0035:
				MapOpen = (byte)mapOpen != 0;
				if (!MapOpen)
				{
					prevSize = -1f;
					return;
				}
				HandleDrag();
				HandleZoom();
				AnchorZoomToCursor();
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}

		private void OnDisable()
		{
			MapOpen = false;
		}

		private void OnGUI()
		{
			//IL_0098: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_00dc: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Object.op_Implicit((Object)(object)cam) || !((Behaviour)cam).enabled || !((Component)cam).gameObject.activeInHierarchy)
				{
					return;
				}
				string previewRoom = MapTeleport.PreviewRoom;
				if (!string.IsNullOrEmpty(previewRoom))
				{
					DrawRespawnPoints();
					if (previewStyle == null)
					{
						previewStyle = new GUIStyle(GUI.skin.label)
						{
							fontSize = 13,
							fontStyle = (FontStyle)1,
							padding = new RectOffset(5, 5, 3, 3),
							richText = true
						};
					}
					previewStyle.normal.textColor = MapRoomBorders.AreaTint(previewRoom);
					string previewTarget = MapTeleport.PreviewTarget;
					GUIContent val = new GUIContent(string.IsNullOrEmpty(previewTarget) ? previewRoom : (previewRoom + "\n<size=11>" + previewTarget + "</size>"));
					Vector2 val2 = previewStyle.CalcSize(val);
					Vector3 mousePosition = Input.mousePosition;
					Rect val3 = new Rect(mousePosition.x - val2.x, (float)Screen.height - mousePosition.y - val2.y, val2.x, val2.y);
					Color color = GUI.color;
					GUI.color = new Color(0f, 0f, 0f, 0.65f);
					GUI.DrawTexture(val3, (Texture)(object)Texture2D.whiteTexture);
					GUI.color = color;
					GUI.Label(val3, val, previewStyle);
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}

		private void DrawRespawnPoints()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_008c: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if (!MapWarpPlugin.ShowRespawnPoints.Value)
			{
				return;
			}
			Color color = GUI.color;
			GUI.color = Color.white;
			Vector3 world = default(Vector3);
			foreach (var previewCandidate in MapTeleport.PreviewCandidates)
			{
				var (scene, val) = previewCandidate;
				if (((Bounds)(ref val)).size.x <= 0f || ((Bounds)(ref val)).size.y <= 0f)
				{
					continue;
				}
				IReadOnlyList<Vector2> readOnlyList = RespawnPoints.Get(scene);
				if (readOnlyList == null)
				{
					continue;
				}
				foreach (Vector2 item in readOnlyList)
				{
					((Vector3)(ref world))..ctor(((Bounds)(ref val)).min.x + item.x * ((Bounds)(ref val)).size.x, ((Bounds)(ref val)).min.y + item.y * ((Bounds)(ref val)).size.y, 0f);
					Vector2 val2 = MapUtil.WorldToGui(cam, world);
					GUI.DrawTexture(new Rect(val2.x - 6f, val2.y - 6f, 12f, 12f), (Texture)(object)DiamondTexture);
				}
			}
			GUI.color = color;
		}

		private static Texture2D BuildDiamond(int size, float borderPx)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			Color val = default(Color);
			((Color)(ref val))..ctor(0.55f, 0.82f, 0.78f, 0.95f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0.8f);
			Texture2D val3 = new Texture2D(size, size, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1
			};
			float num = (float)(size - 1) / 2f;
			float num2 = num - borderPx * 1.4142137f;
			Color[] array = (Color[])(object)new Color[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = (Mathf.Abs((float)j - num) + Mathf.Abs((float)i - num) - num2) / 1.4142137f;
					float num4 = Mathf.Clamp01(0.5f - num3);
					float num5 = Mathf.Clamp01(0.5f - (num3 - borderPx));
					Color val4 = Color.Lerp(val2, val, num4);
					array[i * size + j] = new Color(val4.r, val4.g, val4.b, num5 * Mathf.Lerp(val2.a, val.a, num4));
				}
			}
			val3.SetPixels(array);
			val3.Apply();
			return val3;
		}

		internal static void ResetView()
		{
			MapNavigation mapNavigation = Object.FindFirstObjectByType<MapNavigation>((FindObjectsInactive)1);
			if ((Object)(object)mapNavigation != (Object)null)
			{
				mapNavigation.ResetThis();
			}
		}

		private void ResetThis()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)cam))
			{
				cam.orthographicSize = 8.710664f;
				((Component)cam).transform.localPosition = Vector3.zero;
				if ((Object)(object)decoratorCam != (Object)null)
				{
					decoratorCam.orthographicSize = 8.710664f;
					((Component)decoratorCam).transform.localPosition = Vector3.zero;
				}
			}
		}

		private Vector3 MouseWorldPoint()
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Vector3 mousePosition = Input.mousePosition;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(mousePosition.x / (float)Screen.width, mousePosition.y / (float)Screen.height, 0f);
			return cam.ViewportToWorldPoint(val);
		}

		private void HandleDrag()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetMouseButtonDown(0))
			{
				dragOrigin = MouseWorldPoint();
				dragging = true;
			}
			if (!Input.GetMouseButton(0))
			{
				dragging = false;
			}
			else if (dragging)
			{
				Vector3 val = MouseWorldPoint();
				Vector3 val2 = dragOrigin - val;
				Transform transform = ((Component)cam).transform;
				transform.position += val2;
				if (Object.op_Implicit((Object)(object)decoratorCam))
				{
					Transform transform2 = ((Component)decoratorCam).transform;
					transform2.position += val2;
				}
			}
		}

		private void HandleZoom()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			float y = Input.mouseScrollDelta.y;
			if (y != 0f)
			{
				cam.orthographicSize = Mathf.Clamp(cam.orthographicSize * (1f - y * 0.15f), 1f, 30f);
			}
		}

		private void AnchorZoomToCursor()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00b4: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			float orthographicSize = cam.orthographicSize;
			if (Object.op_Implicit((Object)(object)decoratorCam))
			{
				decoratorCam.orthographicSize = orthographicSize;
			}
			if (!dragging && prevSize > 0f && !Mathf.Approximately(orthographicSize, prevSize))
			{
				Vector3 mousePosition = Input.mousePosition;
				float num = 2f * (prevSize - orthographicSize);
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(num * (mousePosition.x / (float)Screen.width - 0.5f) * cam.aspect, num * (mousePosition.y / (float)Screen.height - 0.5f), 0f);
				Transform transform = ((Component)cam).transform;
				transform.position += val;
				if (Object.op_Implicit((Object)(object)decoratorCam))
				{
					Transform transform2 = ((Component)decoratorCam).transform;
					transform2.position += val;
				}
			}
			prevSize = orthographicSize;
		}

		public static void Install()
		{
			MapNavigation[] array = Object.FindObjectsByType<MapNavigation>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				Object.Destroy((Object)(object)array[i]);
			}
			GameObject val = GameObject.Find("Map Camera");
			if (!((Object)(object)val == (Object)null))
			{
				val.AddComponent<MapNavigation>();
			}
		}
	}
	[HarmonyPatch(typeof(GameMap), "WorldMap")]
	internal static class MapNavigationPatchWorldMap
	{
		[UsedImplicitly]
		private static void Postfix()
		{
			MapNavigation.ResetView();
		}
	}
	[HarmonyPatch(typeof(GameMap), "TryOpenQuickMap")]
	internal static class MapNavigationPatchQuickMap
	{
		[UsedImplicitly]
		private static void Postfix()
		{
			MapNavigation.ResetView();
		}
	}
	[HarmonyPatch(typeof(InputHandler), "SetCursorEnabled", new Type[] { typeof(bool) })]
	internal static class MapNavigationPatchCursor
	{
		[UsedImplicitly]
		private static void Prefix(ref bool isEnabled)
		{
			if (MapNavigation.MapOpen)
			{
				isEnabled = true;
			}
		}
	}
	[HarmonyPatch]
	internal static class MapReveal
	{
		private static bool Enabled => MapWarpPlugin.UnlockEntireMap.Value;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameMap), "EnableUnlockedAreas")]
		private static void EnableUnlockedAreasPrefix(ref MapZone? setCurrent)
		{
			if (MapWarpPlugin.ShowFullMapInQuickmap.Value)
			{
				setCurrent = null;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMap), "EnableUnlockedAreas")]
		private static void EnableUnlockedAreas(GameMap __instance)
		{
			bool value = MapWarpPlugin.ShowFullMapInQuickmap.Value;
			if (!value && !Enabled)
			{
				return;
			}
			try
			{
				GameMapScene[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<GameMapScene>(true);
				if (value)
				{
					MapUtil.ActivateAllRooms(componentsInChildren, ((Component)__instance).transform);
				}
				GameMapScene[] array = componentsInChildren;
				foreach (GameMapScene val in array)
				{
					Transform parent = ((Component)val).transform.parent;
					if (!((Object)(object)parent == (Object)null) && ((Component)parent).gameObject.activeInHierarchy)
					{
						val.SetVisited();
						val.SetMapped();
					}
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(MapNextAreaDisplay), "Refresh")]
		private static void MapNextAreaDisplayRefresh(ref bool display)
		{
			if (MapWarpPlugin.ShowFullMapInQuickmap.Value)
			{
				display = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void HasAnyMap(ref bool __result)
		{
			if (Enabled)
			{
				__result = true;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMap), "IsLostInAbyssPreMap")]
		private static void IsLostInAbyssPreMap(ref bool __result)
		{
			if (Enabled)
			{
				__result = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMap), "IsLostInAbyssPostMap")]
		private static void IsLostInAbyssPostMap(ref bool __result)
		{
			if (Enabled)
			{
				__result = false;
			}
		}

		internal static void PatchUnlockGate(Harmony harmony)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.PropertyGetter(AccessTools.Inner(typeof(GameMap), "ParentInfo"), "IsUnlocked");
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(AccessTools.Method(typeof(MapReveal), "IsUnlockedPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void IsUnlockedPostfix(ref bool __result)
		{
			if (Enabled)
			{
				__result = true;
			}
		}
	}
	[RequireComponent(typeof(Camera))]
	public class MapRoomBorders : MonoBehaviour
	{
		private static MapRoomBorders? active;

		private Camera cam;

		private GameMap? gameMap;

		private Material mat;

		private (GameMapScene scene, SpriteRenderer sr)[]? scenes;

		private const float LabelWidth = 220f;

		private const float LabelHeight = 22f;

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			cam = ((Component)this).GetComponent<Camera>();
			mat = new Material(Shader.Find("Hidden/Internal-Colored"))
			{
				hideFlags = (HideFlags)61
			};
		}

		private void OnEnable()
		{
			gameMap = Object.FindFirstObjectByType<GameMap>();
			if ((Object)(object)gameMap == (Object)null)
			{
				return;
			}
			GameMapScene[] componentsInChildren = ((Component)gameMap).GetComponentsInChildren<GameMapScene>(true);
			List<(GameMapScene, SpriteRenderer)> list = new List<(GameMapScene, SpriteRenderer)>(componentsInChildren.Length);
			GameMapScene[] array = componentsInChildren;
			foreach (GameMapScene val in array)
			{
				SpriteRenderer component = ((Component)val).GetComponent<SpriteRenderer>();
				if ((Object)(object)component != (Object)null && MapTeleport.IsLoadableScene(val.Name))
				{
					list.Add((val, component));
				}
			}
			scenes = list.ToArray();
			active = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)active == (Object)(object)this)
			{
				active = null;
			}
			Object.Destroy((Object)(object)mat);
		}

		private void OnGUI()
		{
			//IL_009f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!MapWarpPlugin.ShowRoomBorders.Value || !Object.op_Implicit((Object)(object)cam) || !((Behaviour)cam).enabled || !((Component)cam).gameObject.activeInHierarchy || scenes == null || cam.orthographicSize > 8.710664f)
				{
					return;
				}
				(GameMapScene, SpriteRenderer)[] array = scenes;
				for (int i = 0; i < array.Length; i++)
				{
					var (val, val2) = array[i];
					if (((Component)val2).gameObject.activeInHierarchy)
					{
						Camera obj = cam;
						Bounds bounds = ((Renderer)val2).bounds;
						Vector3 val3 = obj.WorldToViewportPoint(((Bounds)(ref bounds)).min);
						Camera obj2 = cam;
						bounds = ((Renderer)val2).bounds;
						Vector3 val4 = obj2.WorldToViewportPoint(((Bounds)(ref bounds)).max);
						if (!(val4.x < 0f) && !(val3.x > 1f) && !(val4.y < 0f) && !(val3.y > 1f))
						{
							Camera obj3 = cam;
							bounds = ((Renderer)val2).bounds;
							float x = ((Bounds)(ref bounds)).min.x;
							bounds = ((Renderer)val2).bounds;
							float y = ((Bounds)(ref bounds)).max.y;
							bounds = ((Renderer)val2).bounds;
							Vector2 val5 = MapUtil.WorldToGui(obj3, new Vector3(x, y, ((Bounds)(ref bounds)).center.z));
							float num = Mathf.Clamp(val5.x, 0f, (float)Screen.width - 220f);
							float num2 = Mathf.Clamp(val5.y, 0f, (float)Screen.height - 22f);
							GUI.Label(new Rect(num, num2, 220f, 22f), ((Object)val).name);
						}
					}
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}

		private void OnPostRender()
		{
			//IL_008f: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			if (!MapWarpPlugin.ShowRoomBorders.Value || !Object.op_Implicit((Object)(object)cam) || !Object.op_Implicit((Object)(object)mat) || scenes == null || scenes.Length == 0)
			{
				return;
			}
			GL.PushMatrix();
			try
			{
				mat.SetPass(0);
				GL.LoadIdentity();
				GL.LoadOrtho();
				GL.Begin(1);
				try
				{
					(GameMapScene, SpriteRenderer)[] array = scenes;
					for (int i = 0; i < array.Length; i++)
					{
						var (val, val2) = array[i];
						if (((Component)val2).gameObject.activeInHierarchy)
						{
							Bounds bounds = ((Renderer)val2).bounds;
							Vector3 val3 = cam.WorldToViewportPoint(((Bounds)(ref bounds)).min);
							Vector3 val4 = cam.WorldToViewportPoint(((Bounds)(ref bounds)).max);
							if (!(val4.x < 0f) && !(val3.x > 1f) && !(val4.y < 0f) && !(val3.y > 1f))
							{
								Color val5 = Color.HSVToRGB((float)(Mathf.Abs(((Object)val).name.GetHashCode()) % 1000) / 1000f, 0.6f, 1f);
								val5.a = 0.8f;
								GL.Color(val5);
								DrawRect(val3.x, val3.y, val4.x, val4.y);
							}
						}
					}
				}
				catch (Exception data)
				{
					Log.Error(data);
				}
				finally
				{
					GL.End();
				}
			}
			finally
			{
				GL.PopMatrix();
			}
		}

		internal static Color AreaTint(string sceneName)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			if ((Object)(object)active != (Object)null && active.scenes != null)
			{
				(GameMapScene, SpriteRenderer)[] array = active.scenes;
				for (int i = 0; i < array.Length; i++)
				{
					var (val, val2) = array[i];
					if (((Object)val).name == sceneName)
					{
						Color color = val2.color;
						color.a = 1f;
						return color;
					}
				}
			}
			return Color.white;
		}

		private static void DrawRect(float x0, float y0, float x1, float y1)
		{
			GL.Vertex3(x0, y0, 0f);
			GL.Vertex3(x1, y0, 0f);
			GL.Vertex3(x1, y0, 0f);
			GL.Vertex3(x1, y1, 0f);
			GL.Vertex3(x1, y1, 0f);
			GL.Vertex3(x0, y1, 0f);
			GL.Vertex3(x0, y1, 0f);
			GL.Vertex3(x0, y0, 0f);
		}

		public static void Install()
		{
			MapRoomBorders[] array = Object.FindObjectsByType<MapRoomBorders>((FindObjectsInactive)1, (FindObjectsSortMode)0);
			for (int i = 0; i < array.Length; i++)
			{
				Object.Destroy((Object)(object)array[i]);
			}
			GameObject val = GameObject.Find("Map Camera");
			if (!((Object)(object)val == (Object)null))
			{
				val.AddComponent<MapRoomBorders>();
				MapNavigation.Install();
			}
		}
	}
	[HarmonyPatch]
	internal static class MapTeleport
	{
		private static readonly FieldRef<GameMap, Vector2> currentSceneSize = AccessTools.FieldRefAccess<GameMap, Vector2>("currentSceneSize");

		private static bool pendingDreamGate;

		private static Vector2 pendingNormalized;

		private static bool pendingExact;

		private static (Vector3 pos, bool facingRight)? lastSafeRespawn;

		private static (Vector3 pos, bool facingRight)? pendingReapplyRespawn;

		internal static string? PreviewRoom;

		internal static readonly List<(string room, Bounds bounds)> PreviewCandidates = new List<(string, Bounds)>();

		internal static string? PreviewTarget;

		private static readonly Dictionary<string, bool> loadableCache = new Dictionary<string, bool>();

		private const bool ExactTeleportEnabled = false;

		internal static bool IsLoadableScene(string sceneName)
		{
			if (loadableCache.TryGetValue(sceneName, out var value))
			{
				return value;
			}
			string text = "Scenes/" + sceneName;
			bool flag = false;
			IList<IResourceLocation> list = default(IList<IResourceLocation>);
			foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators)
			{
				if (resourceLocator.Locate((object)text, typeof(SceneInstance), ref list))
				{
					flag = true;
					break;
				}
			}
			loadableCache[sceneName] = flag;
			return flag;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameMap), "Update")]
		private static void GameMapUpdate(GameMap __instance)
		{
			try
			{
				HandleMap(__instance);
			}
			catch (Exception data)
			{
				ClearPreview();
				Log.Error(data);
			}
		}

		private static void ClearPreview()
		{
			PreviewRoom = null;
			PreviewTarget = null;
			PreviewCandidates.Clear();
		}

		private static void HandleMap(GameMap gameMap)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			if (!MapWarpPlugin.EnableTeleport.Value)
			{
				ClearPreview();
				return;
			}
			GameObject val = (((Component)gameMap).gameObject.activeInHierarchy ? GameObject.Find("Map Camera") : null);
			Camera val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<Camera>() : null);
			if ((Object)(object)val2 == (Object)null || !((Behaviour)val2).isActiveAndEnabled)
			{
				ClearPreview();
				return;
			}
			GameManager instance = GameManager.instance;
			GameMapScene best;
			Vector2 normalized;
			bool flag = TryGetRoomUnderCursor(val2, out best, out normalized);
			PreviewRoom = (flag ? best.Name : null);
			object previewTarget;
			if (false)
			{
				Vector2? val3 = SceneSizes.Get(best.Name);
				if (val3.HasValue)
				{
					Vector2 valueOrDefault = val3.GetValueOrDefault();
					previewTarget = $"{normalized.x * valueOrDefault.x:0}, {normalized.y * valueOrDefault.y:0}";
					goto IL_00d4;
				}
			}
			previewTarget = null;
			goto IL_00d4;
			IL_00d4:
			PreviewTarget = (string?)previewTarget;
			if (!Input.GetMouseButtonDown(1))
			{
				return;
			}
			if (!flag)
			{
				ToastManager.Toast("No room under cursor");
			}
			else if (!((Object)(object)instance == (Object)null))
			{
				bool exact = false;
				string name = best.Name;
				if (name == instance.sceneName)
				{
					Vector2 val4 = currentSceneSize.Invoke(gameMap);
					PlaceHero(new Vector2(normalized.x * val4.x, normalized.y * val4.y), exact);
					return;
				}
				if (!IsLoadableScene(name))
				{
					ToastManager.Toast("Can't teleport: scene '" + name + "' is not loaded");
					return;
				}
				pendingDreamGate = true;
				pendingNormalized = normalized;
				pendingExact = exact;
				instance.BeginSceneTransition(new SceneLoadInfo
				{
					SceneName = name,
					HeroLeaveDirection = (GatePosition)5,
					EntryGateName = "dreamGate",
					EntryDelay = 0f,
					PreventCameraFadeOut = true,
					WaitForSceneTransitionCameraFade = false
				});
			}
		}

		private static bool TryGetRoomUnderCursor(Camera mapCam, out GameMapScene best, out Vector2 normalized)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_008f: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			best = null;
			normalized = default(Vector2);
			PreviewCandidates.Clear();
			Vector2 val = Vector2.op_Implicit(Input.mousePosition);
			float num = float.MaxValue;
			Bounds val2 = default(Bounds);
			GameMapScene[] array = Object.FindObjectsByType<GameMapScene>((FindObjectsInactive)0, (FindObjectsSortMode)0);
			foreach (GameMapScene val3 in array)
			{
				SpriteRenderer component = ((Component)val3).GetComponent<SpriteRenderer>();
				if ((Object)(object)component == (Object)null || (Object)(object)component.sprite == (Object)null)
				{
					continue;
				}
				Bounds bounds = ((Renderer)component).bounds;
				Vector2 val4 = MapUtil.WorldToScreen(mapCam, ((Bounds)(ref bounds)).min);
				bounds = ((Renderer)component).bounds;
				Vector2 val5 = MapUtil.WorldToScreen(mapCam, ((Bounds)(ref bounds)).max);
				float num2 = Mathf.Min(val4.x, val5.x);
				float num3 = Mathf.Max(val4.x, val5.x);
				float num4 = Mathf.Min(val4.y, val5.y);
				float num5 = Mathf.Max(val4.y, val5.y);
				if (!(val.x < num2) && !(val.x > num3) && !(val.y < num4) && !(val.y > num5) && IsLoadableScene(val3.Name))
				{
					PreviewCandidates.Add((val3.Name, ((Renderer)component).bounds));
					float num6 = SceneCursorScore(mapCam, val3.Name, ((Renderer)component).bounds, val);
					if (num6 < num)
					{
						num = num6;
						best = val3;
						val2 = ((Renderer)component).bounds;
					}
				}
			}
			if (num == float.MaxValue)
			{
				return false;
			}
			Vector2 val6 = MapUtil.WorldToScreen(mapCam, ((Bounds)(ref val2)).min);
			Vector2 val7 = MapUtil.WorldToScreen(mapCam, ((Bounds)(ref val2)).max);
			normalized = new Vector2(Mathf.Clamp01((val.x - val6.x) / (val7.x - val6.x)), Mathf.Clamp01((val.y - val6.y) / (val7.y - val6.y)));
			return true;
		}

		private static float SceneCursorScore(Camera mapCam, string scene, Bounds worldBounds, Vector2 mouse)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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)
			//IL_007d: 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_009b: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			IReadOnlyList<Vector2> readOnlyList = RespawnPoints.Get(scene);
			Vector2 val;
			if (readOnlyList == null || readOnlyList.Count == 0)
			{
				val = MapUtil.WorldToScreen(mapCam, ((Bounds)(ref worldBounds)).center) - mouse;
				return ((Vector2)(ref val)).sqrMagnitude;
			}
			float num = float.MaxValue;
			Vector3 world = default(Vector3);
			foreach (Vector2 item in readOnlyList)
			{
				((Vector3)(ref world))..ctor(((Bounds)(ref worldBounds)).min.x + item.x * ((Bounds)(ref worldBounds)).size.x, ((Bounds)(ref worldBounds)).min.y + item.y * ((Bounds)(ref worldBounds)).size.y, ((Bounds)(ref worldBounds)).center.z);
				val = MapUtil.WorldToScreen(mapCam, world) - mouse;
				float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
				}
			}
			return num;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameManager), "PositionHeroAtSceneEntrance")]
		private static void PositionHeroAtSceneEntrance(GameManager __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (pendingDreamGate)
			{
				pendingDreamGate = false;
				PlaceHero(new Vector2(pendingNormalized.x * __instance.GetSceneWidth(), pendingNormalized.y * __instance.GetSceneHeight()), pendingExact);
				pendingReapplyRespawn = lastSafeRespawn;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(HeroController), "FinishedEnteringScene")]
		private static void ReapplyHazardRespawnAfterEntry(HeroController __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			(Vector3, bool)? tuple = pendingReapplyRespawn;
			if (tuple.HasValue)
			{
				(Vector3, bool) valueOrDefault = tuple.GetValueOrDefault();
				pendingReapplyRespawn = null;
				__instance.SetHazardRespawn(valueOrDefault.Item1, valueOrDefault.Item2);
			}
		}

		private static void PlaceHero(Vector2 target, bool exact)
		{
			//IL_0000: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_007b: 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)
			//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)
			Vector3 safeSpot;
			bool flag = TryFindNearestSafeSpot(target, out safeSpot);
			HeroController instance = HeroController.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				if (flag)
				{
					instance.SetHazardRespawn(safeSpot, instance.cState.facingRight);
					lastSafeRespawn = (safeSpot, instance.cState.facingRight);
				}
				else
				{
					lastSafeRespawn = null;
				}
				if (exact)
				{
					instance.transform.position = new Vector3(target.x, target.y, instance.transform.position.z);
				}
				else if (flag)
				{
					PlaceHeroOnGround(Vector2.op_Implicit(safeSpot));
				}
				else
				{
					PlaceHeroOnGround(target);
				}
			}
		}

		private static bool TryFindNearestSafeSpot(Vector2 target, out Vector3 safeSpot)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00b8: 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_00d0: 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)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			safeSpot = Vector3.zero;
			bool result = false;
			HazardRespawnMarker[] array = Object.FindObjectsByType<HazardRespawnMarker>((FindObjectsSortMode)0);
			Vector2 val2;
			foreach (HazardRespawnMarker val in array)
			{
				val2 = Vector2.op_Implicit(((Component)val).transform.position) - target;
				float sqrMagnitude = ((Vector2)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					Vector3 position = ((Component)val).transform.position;
					num = sqrMagnitude;
					safeSpot = position;
					result = true;
				}
			}
			TransitionPoint[] array2 = Object.FindObjectsByType<TransitionPoint>((FindObjectsSortMode)0);
			foreach (TransitionPoint val3 in array2)
			{
				Vector3 val4 = (((Object)(object)val3.respawnMarker != (Object)null) ? ((Component)val3.respawnMarker).transform.position : ((Component)val3).transform.position);
				val2 = Vector2.op_Implicit(val4) - target;
				float sqrMagnitude2 = ((Vector2)(ref val2)).sqrMagnitude;
				if (sqrMagnitude2 < num)
				{
					Vector3 position = val4;
					num = sqrMagnitude2;
					safeSpot = position;
					result = true;
				}
			}
			return result;
		}

		private static void PlaceHeroOnGround(Vector2 target)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001f: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			HeroController instance = HeroController.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				Vector3 val = instance.FindGroundPoint(target, true);
				instance.transform.position = new Vector3(val.x, val.y, instance.transform.position.z);
			}
		}
	}
	internal static class MapUtil
	{
		internal static void ActivateAllRooms(GameMapScene[] scenes, Transform root)
		{
			for (int i = 0; i < scenes.Length; i++)
			{
				Transform val = ((Component)scenes[i]).transform;
				while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root)
				{
					if (!((Component)val).gameObject.activeSelf)
					{
						((Component)val).gameObject.SetActive(true);
					}
					val = val.parent;
				}
			}
		}

		private static (float dx, float dy, float dw, float dh) MapRect(Camera cam)
		{
			float num = Screen.width;
			float num2 = Screen.height;
			float aspect = cam.aspect;
			if (num / num2 > aspect)
			{
				float num3 = num2 * aspect;
				return (dx: (num - num3) * 0.5f, dy: 0f, dw: num3, dh: num2);
			}
			float num4 = num / aspect;
			return (dx: 0f, dy: (num2 - num4) * 0.5f, dw: num, dh: num4);
		}

		internal static Vector2 ViewportToScreen(Camera cam, Vector3 vp)
		{
			//IL_0022: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			var (num, num2, num3, num4) = MapRect(cam);
			return new Vector2(num + vp.x * num3, num2 + vp.y * num4);
		}

		internal static Vector2 WorldToScreen(Camera cam, Vector3 world)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			return ViewportToScreen(cam, cam.WorldToViewportPoint(world));
		}

		internal static Vector2 WorldToGui(Camera cam, Vector3 world)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = WorldToScreen(cam, world);
			return new Vector2(val.x, (float)Screen.height - val.y);
		}
	}
	[BepInPlugin("io.github.jakobhellermann.mapwarp", "MapWarp", "1.0.1")]
	public class MapWarpPlugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> EnableTeleport;

		internal static ConfigEntry<bool> ShowRoomBorders;

		internal static ConfigEntry<bool> ShowFullMapInQuickmap;

		internal static ConfigEntry<bool> UnlockEntireMap;

		internal static ConfigEntry<bool> InstantMapOpen;

		internal static ConfigEntry<bool> ShowRespawnPoints;

		internal static ConfigEntry<bool> AlwaysCompass;

		private Harmony harmony;

		public const string Id = "io.github.jakobhellermann.mapwarp";

		public static string Name => "MapWarp";

		public static string Version => "1.0.1";

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			Log.Info("Plugin " + Name + " (io.github.jakobhellermann.mapwarp) has loaded!");
			try
			{
				EnableTeleport = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleport", "Enable teleport", true, "Right-click a room on the map to warp to the the nearest safe spot (hold Shift exact spot.)");
				UnlockEntireMap = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "Unlock entire map", true, "Open and pan the whole map even in zones you haven't acquired it for.");
				ShowFullMapInQuickmap = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "Show full map in quickmap", false, "Show the entire map instead of the current area in quickmap");
				InstantMapOpen = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "Instant map open", true, "Open the quick map instantly instead of waiting for the open animation.");
				InstantMapOpen.SettingChanged += delegate
				{
					MapWarp.Source.InstantMapOpen.Apply();
				};
				ShowRoomBorders = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Show Room Borders", false, "Outline each room on the map and label it with its scene name.");
				ShowRespawnPoints = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleport", "Show respawn points", true, "When hovering a room on the map, mark its safe respawn points (transition / hazard-respawn spots).");
				AlwaysCompass = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "Always show compass", false, "Always show your position on the map, as if the Compass tool were equipped.");
				harmony = Harmony.CreateAndPatchAll(((object)this).GetType().Assembly, (string)null);
				MapReveal.PatchUnlockGate(harmony);
				ToastManager.Install();
				MapLifecycle.Dispatch();
			}
			catch (Exception arg)
			{
				Log.Info(string.Format("Plugin {0} ({1}) failed to initialize: {2}", Name, "io.github.jakobhellermann.mapwarp", arg));
			}
		}

		private void OnDestroy()
		{
			try
			{
				harmony.UnpatchSelf();
				MapRoomBorders[] array = Object.FindObjectsByType<MapRoomBorders>((FindObjectsInactive)1, (FindObjectsSortMode)0);
				for (int i = 0; i < array.Length; i++)
				{
					Object.Destroy((Object)(object)array[i]);
				}
				MapNavigation[] array2 = Object.FindObjectsByType<MapNavigation>((FindObjectsInactive)1, (FindObjectsSortMode)0);
				for (int i = 0; i < array2.Length; i++)
				{
					Object.Destroy((Object)(object)array2[i]);
				}
				ToastManager[] array3 = Object.FindObjectsByType<ToastManager>((FindObjectsInactive)1, (FindObjectsSortMode)0);
				for (int i = 0; i < array3.Length; i++)
				{
					Object.Destroy((Object)(object)((Component)array3[i]).gameObject);
				}
			}
			catch (Exception arg)
			{
				Log.Info(string.Format("Plugin {0} ({1}) failed to clean up: {2}", Name, "io.github.jakobhellermann.mapwarp", arg));
			}
			Log.Info("Plugin " + Name + " (io.github.jakobhellermann.mapwarp) has been unloaded!");
		}
	}
	internal static class RespawnPoints
	{
		private const string ResourceName = "mapwarp_respawns.json";

		[CompilerGenerated]
		private static Dictionary<string, List<Vector2>> <Data>k__BackingField;

		private static Dictionary<string, List<Vector2>> Data => <Data>k__BackingField ?? (<Data>k__BackingField = LoadEmbedded());

		private static Dictionary<string, List<Vector2>> LoadEmbedded()
		{
			try
			{
				Assembly assembly = typeof(RespawnPoints).Assembly;
				string text = Array.Find(assembly.GetManifestResourceNames(), (string n) => n.EndsWith("mapwarp_respawns.json", StringComparison.Ordinal));
				if (text == null)
				{
					return new Dictionary<string, List<Vector2>>();
				}
				using Stream stream = assembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return new Dictionary<string, List<Vector2>>();
				}
				using StreamReader streamReader = new StreamReader(stream);
				Dictionary<string, List<Vector2>> dictionary = Parse(streamReader.ReadToEnd());
				Log.Info($"Respawn points: {dictionary.Count} embedded scenes");
				return dictionary;
			}
			catch (Exception data)
			{
				Log.Error(data);
				return new Dictionary<string, List<Vector2>>();
			}
		}

		private static Dictionary<string, List<Vector2>> Parse(string json)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, List<Vector2>> dictionary = new Dictionary<string, List<Vector2>>();
			Dictionary<string, List<float[]>> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, List<float[]>>>(json);
			if (dictionary2 == null)
			{
				return dictionary;
			}
			foreach (KeyValuePair<string, List<float[]>> item in dictionary2)
			{
				item.Deconstruct(out var key, out var value);
				string key2 = key;
				List<float[]> list = value;
				List<Vector2> list2 = new List<Vector2>(list.Count);
				foreach (float[] item2 in list)
				{
					if (item2.Length >= 2)
					{
						list2.Add(new Vector2(item2[0], item2[1]));
					}
				}
				dictionary[key2] = list2;
			}
			return dictionary;
		}

		internal static IReadOnlyList<Vector2>? Get(string scene)
		{
			return Data.GetValueOrDefault(scene);
		}
	}
	internal static class SceneSizes
	{
		private const string ResourceName = "mapwarp_scene_sizes.json";

		[CompilerGenerated]
		private static Dictionary<string, Vector2> <Data>k__BackingField;

		private static Dictionary<string, Vector2> Data => <Data>k__BackingField ?? (<Data>k__BackingField = LoadEmbedded());

		private static Dictionary<string, Vector2> LoadEmbedded()
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Assembly assembly = typeof(SceneSizes).Assembly;
				string text = Array.Find(assembly.GetManifestResourceNames(), (string n) => n.EndsWith("mapwarp_scene_sizes.json", StringComparison.Ordinal));
				if (text == null)
				{
					return new Dictionary<string, Vector2>();
				}
				using Stream stream = assembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return new Dictionary<string, Vector2>();
				}
				using StreamReader streamReader = new StreamReader(stream);
				Dictionary<string, float[]> dictionary = JsonConvert.DeserializeObject<Dictionary<string, float[]>>(streamReader.ReadToEnd());
				Dictionary<string, Vector2> dictionary2 = new Dictionary<string, Vector2>(dictionary?.Count ?? 0);
				if (dictionary != null)
				{
					foreach (var (key, array2) in dictionary)
					{
						if (array2.Length >= 2)
						{
							dictionary2[key] = new Vector2(array2[0], array2[1]);
						}
					}
				}
				Log.Info($"Scene sizes: {dictionary2.Count} embedded scenes");
				return dictionary2;
			}
			catch (Exception data)
			{
				Log.Error(data);
				return new Dictionary<string, Vector2>();
			}
		}

		internal static Vector2? Get(string scene)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!Data.TryGetValue(scene, out var value))
			{
				return null;
			}
			return value;
		}
	}
}
namespace MapWarp.Source.Toasts
{
	public class ToastManager : MonoBehaviour
	{
		private record struct ToastMessage(float StartTime, string Text);

		private const float MaxToastAge = 5f;

		private static ToastManager? instance;

		private readonly List<ToastMessage> toasts = new List<ToastMessage>();

		private RectTransform canvasRt;

		private Text toastText;

		private float lastKnownCanvasHeight;

		private int maxToastCount;

		private bool toastsDirty;

		private static float Now => Time.time;

		public static void Install()
		{
			//IL_0013: 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_001e: Expected O, but got Unknown
			if (!((Object)(object)instance != (Object)null))
			{
				GameObject val = new GameObject("MapWarpToasts");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<ToastManager>();
			}
		}

		[PublicAPI]
		public static void Toast(object? message)
		{
			string text = message?.ToString() ?? "null";
			Log.Info("Toast: " + text);
			instance?.AddToastMessage(text);
		}

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Canvas val = ((Component)this).gameObject.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			((Component)this).gameObject.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
			canvasRt = ((Component)val).GetComponent<RectTransform>();
			GameObject val2 = new GameObject("Toast");
			val2.transform.SetParent((Transform)(object)canvasRt);
			toastText = val2.AddComponent<Text>();
			toastText.alignment = (TextAnchor)8;
			toastText.fontSize = 8;
			((Graphic)toastText).color = Color.white;
			toastText.text = "";
			toastText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			RectTransform component = ((Component)toastText).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(0f, 10f);
			component.offsetMax = new Vector2(-10f, 0f);
			instance = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)instance == (Object)(object)this)
			{
				instance = null;
			}
		}

		private void Update()
		{
			try
			{
				if (toasts.Count == 0 && !toastsDirty)
				{
					return;
				}
				float now = Now;
				toastsDirty |= toasts.RemoveAll((ToastMessage toast) => now - toast.StartTime > 5f) > 0;
				RefreshMaxToastCount();
				if (toastsDirty)
				{
					toastText.text = string.Join('\n', toasts.Select((ToastMessage toast) => toast.Text));
					toastsDirty = false;
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
		}

		private void AddToastMessage(string message)
		{
			RefreshMaxToastCount();
			if (maxToastCount == 0)
			{
				maxToastCount = 1;
			}
			if (toasts.Count >= maxToastCount)
			{
				toasts.RemoveAt(0);
			}
			toasts.Add(new ToastMessage(Now, message));
			toastsDirty = true;
		}

		private int ComputeMaxToastCount()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Font font = toastText.font;
			float num = (float)font.lineHeight * ((float)toastText.fontSize / (float)font.fontSize) * toastText.lineSpacing;
			Rect rect = canvasRt.rect;
			return Mathf.Max(1, Mathf.FloorToInt(((Rect)(ref rect)).height * 0.9f / num));
		}

		private void RefreshMaxToastCount()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = canvasRt.rect;
			float height = ((Rect)(ref rect)).height;
			if (height != lastKnownCanvasHeight)
			{
				lastKnownCanvasHeight = height;
				maxToastCount = ComputeMaxToastCount();
			}
		}
	}
}