Decompiled source of LeadMeOut v2.0.1

BepInEx/plugins/LeadMeOut/LeadMeOut.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("LeadMeOut")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyInformationalVersion("2.0.1")]
[assembly: AssemblyProduct("LeadMeOut")]
[assembly: AssemblyTitle("LeadMeOut")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.1.0")]
[module: UnverifiableCode]
namespace LeadMeOut;

public class ExitFinder
{
	private struct PathResult
	{
		public List<Vector3> Points;

		public bool IsLockedDoor;

		public bool IsDeadEnd;

		public bool IsDoorBlocked;
	}

	private class DoorEdge
	{
		public DoorLock door;

		public Vector3 center;

		public Vector3 sideA;

		public Vector3 sideB;

		public int regionA = -1;

		public int regionB = -1;
	}

	private class SidePoint
	{
		public Vector3 pos;

		public int region = -1;

		public DoorEdge owner;

		public bool isSideA;
	}

	private struct DoorwayCrossing
	{
		public int seg;

		public float t;

		public Vector3 centre;

		public Vector3 dir;
	}

	private bool isActive;

	private Transform mainEntranceTarget;

	private Transform mineshaftBottomTarget;

	private Transform mineshaftTopTarget;

	private Transform realMainEntrance;

	private List<Transform> fireExitTargets = new List<Transform>();

	private readonly NavMeshPath scratchPath = new NavMeshPath();

	private readonly NavMeshPath scratchPathDoor = new NavMeshPath();

	private readonly NavMeshPath scratchPathReach = new NavMeshPath();

	private List<LineRenderer> mainEntranceSegments = new List<LineRenderer>();

	private List<LineRenderer> mainEntranceDiamonds = new List<LineRenderer>();

	private List<GameObject> mainEntranceShapes = new List<GameObject>();

	private GameObject mainEntranceRoot;

	private GameObject mainEntranceMarker;

	private List<List<LineRenderer>> fireExitSegmentSets = new List<List<LineRenderer>>();

	private List<List<LineRenderer>> fireExitDiamondSets = new List<List<LineRenderer>>();

	private List<List<GameObject>> fireExitShapeSets = new List<List<GameObject>>();

	private List<GameObject> fireExitRoots = new List<GameObject>();

	private List<GameObject> fireExitMarkers = new List<GameObject>();

	private GameObject compassOverlayRoot;

	private RectTransform mainEntrancePip;

	private RectTransform fireExitPip;

	private float updateTimer = 999f;

	private float pulseTimer;

	private bool wasInsideFactory;

	private float doorSimTimer = 999f;

	private const float DOOR_SIM_INTERVAL = 2f;

	private List<(DoorLock door, Collider col)> cachedLockedDoors;

	private float doorCacheTimer = 999f;

	private const float DOOR_CACHE_INTERVAL = 5f;

	private Vector3 smoothedPlayerPos = Vector3.zero;

	private bool smoothedPosInitialized;

	private float smoothSpeed = 8f;

	private int bezierSteps = 12;

	private NavigationMode lastNavMode;

	private const string COMPASS_PATH = "Systems/UI/Canvas/IngamePlayerHUD";

	private const float COMPASS_WIDTH = 500f;

	private const float COMPASS_HEIGHT_UI = 36.39f;

	private const float COMPASS_ANCHOR_X = 0f;

	private const float COMPASS_ANCHOR_Y = -28f;

	private const float COMPASS_FOV = 240f;

	private const float COMPASS_VERTICAL_OFFSET = 12f;

	private const float COMPASS_FADE_ZONE = 0.15f;

	private const float COMPASS_HIDE_MARGIN = 5f;

	private List<DoorEdge> doorEdges = new List<DoorEdge>();

	private List<SidePoint> graphPoints = new List<SidePoint>();

	private List<Vector3> regionReps = new List<Vector3>();

	private bool graphReady;

	private bool graphBuilding;

	private int graphPointIndex;

	private int graphRepIndex;

	private int graphLockSignature;

	private const int GRAPH_PATHFINDS_PER_TICK = 6;

	private const int GRAPH_MAX_DOORS = 64;

	private const float ELEVATOR_XZ_RADIUS = 10f;

	private Dictionary<Vector3, Vector3> doorSimCache = new Dictionary<Vector3, Vector3>();

	private HashSet<Vector3> doorSimMisses = new HashSet<Vector3>();

	private const float DOORWAY_HINT_RADIUS = 3f;

	private const float DOORWAY_STRAIGHT = 1f;

	private const float DOORWAY_CLEAR_RADIUS = 1.8f;

	private const float DOORWAY_MAX_SHIFT = 1.5f;

	private List<(DoorLock door, Collider col)> GetDoorCache()
	{
		if (cachedLockedDoors == null)
		{
			cachedLockedDoors = new List<(DoorLock, Collider)>();
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			foreach (DoorLock val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					Collider componentInChildren = ((Component)val).GetComponentInChildren<Collider>();
					if (!((Object)(object)componentInChildren == (Object)null))
					{
						cachedLockedDoors.Add((val, componentInChildren));
					}
				}
			}
			Plugin.Logger.LogDebug((object)$"LeadMeOut: Door cache rebuilt — {cachedLockedDoors.Count} door(s) with colliders.");
		}
		return cachedLockedDoors;
	}

	public void Toggle()
	{
		PlayerControllerB localPlayer = GetLocalPlayer();
		bool flag = (Object)(object)localPlayer != (Object)null && localPlayer.isInsideFactory;
		if (Plugin.AutoEnableOnEntry.Value && flag && isActive)
		{
			isActive = false;
			Plugin.Logger.LogInfo((object)"LeadMeOut: Temporarily disabled by hotkey.");
			ClearAll();
			return;
		}
		if (!flag)
		{
			Plugin.Logger.LogInfo((object)"LeadMeOut: Not inside facility, ignoring toggle.");
			return;
		}
		isActive = !isActive;
		Plugin.Logger.LogInfo((object)("LeadMeOut: " + (isActive ? "ON" : "OFF")));
		if (isActive)
		{
			smoothedPosInitialized = false;
			FindExits();
			if (Plugin.NavMode.Value == NavigationMode.CompassMode)
			{
				CreateCompassOverlay();
			}
			else
			{
				CreateLineRoots();
			}
		}
		else
		{
			ClearAll();
		}
	}

	public void Tick(float deltaTime)
	{
		//IL_00bd: 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_00df: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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)
		PlayerControllerB localPlayer = GetLocalPlayer();
		if ((Object)(object)localPlayer != (Object)null)
		{
			bool isInsideFactory = localPlayer.isInsideFactory;
			if (!wasInsideFactory && isInsideFactory && Plugin.AutoEnableOnEntry.Value && !isActive)
			{
				Plugin.Logger.LogInfo((object)"LeadMeOut: Auto-enabling on facility entry.");
				isActive = true;
				smoothedPosInitialized = false;
				FindExits();
				if (Plugin.NavMode.Value == NavigationMode.CompassMode)
				{
					CreateCompassOverlay();
				}
				else
				{
					CreateLineRoots();
				}
			}
			if (wasInsideFactory && !isInsideFactory && isActive)
			{
				Plugin.Logger.LogInfo((object)"LeadMeOut: Player left facility, clearing.");
				isActive = false;
				ClearAll();
			}
			wasInsideFactory = isInsideFactory;
			if (isActive)
			{
				Vector3 position = ((Component)localPlayer).transform.position;
				if (!smoothedPosInitialized)
				{
					smoothedPlayerPos = position;
					smoothedPosInitialized = true;
				}
				else
				{
					smoothedPlayerPos = Vector3.Lerp(smoothedPlayerPos, position, deltaTime * smoothSpeed);
				}
			}
		}
		if (isActive && Plugin.NavMode.Value != lastNavMode)
		{
			lastNavMode = Plugin.NavMode.Value;
			ClearAll();
			FindExits();
			if (lastNavMode == NavigationMode.CompassMode)
			{
				CreateCompassOverlay();
			}
			else
			{
				CreateLineRoots();
			}
		}
		MaintainDoorGraph(deltaTime);
		if (!isActive)
		{
			return;
		}
		pulseTimer += deltaTime;
		doorSimTimer += deltaTime;
		updateTimer += deltaTime;
		int num = Mathf.Clamp(Plugin.PathUpdateRate.Value, 1, 10);
		float num2 = 1f / (float)num;
		if (updateTimer >= num2)
		{
			updateTimer = 0f;
			Plugin.Logger.LogDebug((object)$"LeadMeOut: Tick mode={Plugin.NavMode.Value}");
			if (Plugin.NavMode.Value == NavigationMode.CompassMode)
			{
				UpdateCompassOverlay();
			}
			else
			{
				UpdatePaths();
			}
		}
	}

	private void MaintainDoorGraph(float deltaTime)
	{
		doorCacheTimer += deltaTime;
		if (doorCacheTimer >= 5f)
		{
			doorCacheTimer = 0f;
			cachedLockedDoors = null;
		}
		if (GetDoorCache().Count == 0)
		{
			if (doorEdges.Count > 0)
			{
				ResetDoorGraph();
			}
			graphLockSignature = 0;
			return;
		}
		int num = ComputeLockSignature();
		if (num != graphLockSignature)
		{
			graphLockSignature = num;
			BeginDoorGraph();
		}
		StepDoorGraph();
	}

	private PlayerControllerB GetLocalPlayer()
	{
		GameNetworkManager instance = GameNetworkManager.Instance;
		if ((Object)(object)instance != (Object)null && (Object)(object)instance.localPlayerController != (Object)null)
		{
			return instance.localPlayerController;
		}
		return null;
	}

	private void FindExits()
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: 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)
		mainEntranceTarget = null;
		fireExitTargets.Clear();
		mineshaftBottomTarget = null;
		mineshaftTopTarget = null;
		realMainEntrance = null;
		Transform val = null;
		GameObject[] array = Object.FindObjectsOfType<GameObject>();
		foreach (GameObject val2 in array)
		{
			if (((Object)val2).name.Contains("BottomElevatorPanel"))
			{
				Transform parent = val2.transform.parent;
				if ((Object)(object)parent != (Object)null && ((Object)parent).name.Contains("(Clone)"))
				{
					val = val2.transform;
					Plugin.Logger.LogInfo((object)$"LeadMeOut: BottomElevatorPanel (scene instance) found at {val2.transform.position}, parent={((Object)parent).name}");
					break;
				}
			}
		}
		array = Object.FindObjectsOfType<GameObject>();
		NavMeshHit val4 = default(NavMeshHit);
		foreach (GameObject val3 in array)
		{
			if (((Object)val3).name.Contains("EntranceTeleportA") && ((Object)val3).name.Contains("Clone"))
			{
				realMainEntrance = val3.transform;
				bool flag = false;
				if ((Object)(object)val != (Object)null)
				{
					bool flag2 = NavMesh.SamplePosition(val.position, ref val4, 4f, -1);
					bool flag3 = val.position.y < val3.transform.position.y - 4f;
					flag = flag2 && flag3;
					if (!flag)
					{
						Plugin.Logger.LogWarning((object)($"LeadMeOut: BottomElevatorPanel present but rejected (onNavMesh={flag2}, below={flag3}). " + "Treating as a normal (non-Mineshaft) interior."));
					}
				}
				if (flag)
				{
					mineshaftBottomTarget = val;
					mineshaftTopTarget = val3.transform;
					mainEntranceTarget = val;
					Plugin.Logger.LogInfo((object)$"LeadMeOut: Mineshaft mode — bottom={val.position} top={val3.transform.position}");
				}
				else
				{
					mainEntranceTarget = val3.transform;
					Plugin.Logger.LogInfo((object)$"LeadMeOut: Main entrance at {val3.transform.position}");
				}
			}
			if (((Object)val3).name.Contains("EntranceTeleportB") && ((Object)val3).name.Contains("Clone"))
			{
				fireExitTargets.Add(val3.transform);
				Plugin.Logger.LogInfo((object)$"LeadMeOut: Fire exit #{fireExitTargets.Count} at {val3.transform.position}");
			}
		}
		Plugin.Logger.LogInfo((object)$"LeadMeOut: Found {fireExitTargets.Count} fire exit(s).");
	}

	private void CreateCompassOverlay()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_0073: 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)
		//IL_009d: 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_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: 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_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: 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)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		ClearCompassOverlay();
		GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD");
		if ((Object)(object)val == (Object)null)
		{
			Plugin.Logger.LogInfo((object)"LeadMeOut: Could not find HUD canvas path.");
			return;
		}
		compassOverlayRoot = new GameObject("LeadMeOut_CompassOverlay");
		compassOverlayRoot.transform.SetParent(val.transform, false);
		compassOverlayRoot.AddComponent<CanvasRenderer>();
		RectTransform obj = compassOverlayRoot.AddComponent<RectTransform>();
		obj.anchorMin = new Vector2(0.5f, 0f);
		obj.anchorMax = new Vector2(0.5f, 0f);
		obj.anchoredPosition = new Vector2(0f, 20.39f);
		obj.sizeDelta = new Vector2(500f, 36.39f);
		compassOverlayRoot.transform.SetAsLastSibling();
		ShowLinesPreset value = Plugin.ShowLines.Value;
		if ((Object)(object)mainEntranceTarget != (Object)null && value != ShowLinesPreset.FireExitsOnly)
		{
			Color color = Plugin.ApplyBrightness(Plugin.ResolveColor(Plugin.MainEntranceColorPreset.Value, Plugin.MainEntranceCustomColor.Value, Color.green));
			float width = Plugin.ResolvePipWidth(Plugin.MainEntranceLineWidth.Value);
			mainEntrancePip = CreatePip(compassOverlayRoot, color, width);
		}
		if (fireExitTargets.Count > 0 && value != ShowLinesPreset.MainEntranceOnly)
		{
			Color color2 = Plugin.ApplyBrightness(Plugin.ResolveColor(Plugin.FireExitColorPreset.Value, Plugin.FireExitCustomColor.Value, Color.red));
			float width2 = Plugin.ResolvePipWidth(Plugin.FireExitLineWidth.Value);
			fireExitPip = CreatePip(compassOverlayRoot, color2, width2);
		}
		RectTransform component = compassOverlayRoot.GetComponent<RectTransform>();
		Plugin.Logger.LogInfo((object)$"LeadMeOut: Compass overlay created. Parent={((Object)val).name} anchorPos={component.anchoredPosition} size={component.sizeDelta} siblingIndex={compassOverlayRoot.transform.GetSiblingIndex()}");
	}

	private RectTransform CreatePip(GameObject parent, Color color, float width)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_002a: 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_0054: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Pip");
		val.transform.SetParent(parent.transform, false);
		RectTransform obj = val.AddComponent<RectTransform>();
		obj.sizeDelta = new Vector2(width, 18f);
		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 = new Vector2(0f, 0f);
		((Graphic)val.AddComponent<Image>()).color = color;
		Plugin.Logger.LogDebug((object)"LeadMeOut: Pip created as Image");
		return obj;
	}

	private void UpdateCompassOverlay()
	{
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: 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_022b: 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_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: 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_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0360: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)compassOverlayRoot == (Object)null)
		{
			return;
		}
		PlayerControllerB localPlayer = GetLocalPlayer();
		if ((Object)(object)localPlayer == (Object)null)
		{
			return;
		}
		if ((Object)(object)mineshaftBottomTarget != (Object)null && (Object)(object)mineshaftTopTarget != (Object)null && TryGetPosition(mineshaftTopTarget, out var pos))
		{
			float y = ((Component)localPlayer).transform.position.y;
			float y2 = pos.y;
			mainEntranceTarget = ((y >= y2 - 8f) ? mineshaftTopTarget : mineshaftBottomTarget);
		}
		Transform val = ((Component)localPlayer).transform.Find("ScavengerModel/metarig/CameraContainer");
		float num = (((Object)(object)val != (Object)null) ? val.eulerAngles.y : ((Component)localPlayer).transform.eulerAngles.y);
		Vector3 val2 = default(Vector3);
		((Vector3)(ref val2))..ctor(Mathf.Sin(num * ((float)Math.PI / 180f)), 0f, Mathf.Cos(num * ((float)Math.PI / 180f)));
		ShowLinesPreset value = Plugin.ShowLines.Value;
		Plugin.Logger.LogDebug((object)$"LeadMeOut: UpdateCompass - forward={val2}, mainPip={(Object)(object)mainEntrancePip != (Object)null}, firePip={(Object)(object)fireExitPip != (Object)null}, mainTarget={(Object)(object)mainEntranceTarget != (Object)null}, fireCount={fireExitTargets.Count}, showLines={Plugin.ShowLines.Value}");
		if ((Object)(object)mainEntrancePip != (Object)null && TryGetPosition(mainEntranceTarget, out var pos2))
		{
			((Component)mainEntrancePip).gameObject.SetActive(value != ShowLinesPreset.FireExitsOnly);
			if (value != ShowLinesPreset.FireExitsOnly)
			{
				Color color = Plugin.ApplyBrightness(Plugin.ResolveColor(Plugin.MainEntranceColorPreset.Value, Plugin.MainEntranceCustomColor.Value, Color.green));
				float num2 = Plugin.ResolvePipWidth(Plugin.MainEntranceLineWidth.Value);
				mainEntrancePip.sizeDelta = new Vector2(num2, mainEntrancePip.sizeDelta.y);
				Vector3 val3 = pos2;
				if ((Object)(object)mainEntranceTarget == (Object)(object)mineshaftBottomTarget)
				{
					val3 = ElevatorNudge(((Component)localPlayer).transform.position, val3, 1.8f);
				}
				UpdatePipPosition(mainEntrancePip, ((Component)localPlayer).transform.position, val3, val2, color);
			}
		}
		if ((Object)(object)fireExitPip != (Object)null && fireExitTargets.Count > 0)
		{
			((Component)fireExitPip).gameObject.SetActive(value != ShowLinesPreset.MainEntranceOnly);
			if (value != ShowLinesPreset.MainEntranceOnly)
			{
				Color color2 = Plugin.ApplyBrightness(Plugin.ResolveColor(Plugin.FireExitColorPreset.Value, Plugin.FireExitCustomColor.Value, Color.red));
				float num3 = Plugin.ResolvePipWidth(Plugin.FireExitLineWidth.Value);
				fireExitPip.sizeDelta = new Vector2(num3, fireExitPip.sizeDelta.y);
				UpdatePipPosition(targetPos: ((Object)(object)mineshaftBottomTarget != (Object)null && TryGetPosition(mineshaftTopTarget, out var pos3) && ((Component)localPlayer).transform.position.y >= pos3.y - 8f && TryGetPosition(mineshaftBottomTarget, out var pos4)) ? ElevatorNudge(((Component)localPlayer).transform.position, pos4, 2.2f) : ((!TryGetPosition(fireExitTargets[0], out var pos5)) ? ((Component)localPlayer).transform.position : pos5), pip: fireExitPip, playerPos: ((Component)localPlayer).transform.position, forward: val2, color: color2);
			}
		}
	}

	private void UpdatePipPosition(RectTransform pip, Vector3 playerPos, Vector3 targetPos, Vector3 forward, Color color)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: 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_011f: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Vector3 val = targetPos - playerPos;
			val.y = 0f;
			if (((Vector3)(ref val)).magnitude < 0.01f)
			{
				return;
			}
			((Vector3)(ref val)).Normalize();
			float num = Vector3.SignedAngle(forward, val, Vector3.up);
			float num2 = 120f;
			float num3 = Mathf.Abs(num);
			if (num3 > num2 + 5f)
			{
				((Component)pip).gameObject.SetActive(false);
				return;
			}
			((Component)pip).gameObject.SetActive(true);
			float num4 = Mathf.Clamp(num, 0f - num2, num2) / num2 * 250f;
			pip.anchoredPosition = new Vector2(num4, 0f);
			float num5 = 1f;
			float num6 = num3 / num2;
			float num7 = 0.85f;
			if (num6 > num7)
			{
				num5 = Mathf.Clamp01(Mathf.InverseLerp(1f, num7, num6));
			}
			Plugin.Logger.LogDebug((object)$"LeadMeOut: PipPos angle={num:F1} xPos={num4:F1} alpha={num5:F2} active={((Component)pip).gameObject.activeSelf}");
			Image componentInChildren = ((Component)pip).GetComponentInChildren<Image>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				Color color2 = color;
				color2.a = num5;
				((Graphic)componentInChildren).color = color2;
			}
		}
		catch (Exception ex)
		{
			Plugin.Logger.LogInfo((object)("LeadMeOut: PipPos exception: " + ex.Message));
		}
	}

	private void ClearCompassOverlay()
	{
		if ((Object)(object)compassOverlayRoot != (Object)null)
		{
			Object.Destroy((Object)(object)compassOverlayRoot);
			compassOverlayRoot = null;
		}
		mainEntrancePip = null;
		fireExitPip = null;
	}

	private void CreateLineRoots()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		ClearLineRoots();
		ShowLinesPreset value = Plugin.ShowLines.Value;
		if ((Object)(object)mainEntranceTarget != (Object)null && value != ShowLinesPreset.FireExitsOnly)
		{
			mainEntranceRoot = new GameObject("LeadMeOut_MainLine");
			Object.DontDestroyOnLoad((Object)(object)mainEntranceRoot);
		}
		if (value != ShowLinesPreset.MainEntranceOnly)
		{
			for (int i = 0; i < fireExitTargets.Count; i++)
			{
				GameObject val = new GameObject($"LeadMeOut_FireLine_{i}");
				Object.DontDestroyOnLoad((Object)(object)val);
				fireExitRoots.Add(val);
				fireExitSegmentSets.Add(new List<LineRenderer>());
				fireExitDiamondSets.Add(new List<LineRenderer>());
				fireExitShapeSets.Add(new List<GameObject>());
			}
		}
		updateTimer = 999f;
	}

	private static bool TryGetPosition(Transform t, out Vector3 pos)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		pos = Vector3.zero;
		if ((Object)(object)t == (Object)null)
		{
			return false;
		}
		try
		{
			pos = t.position;
			return true;
		}
		catch (MissingReferenceException)
		{
			return false;
		}
		catch (NullReferenceException)
		{
			return false;
		}
	}

	private void UpdatePaths()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: 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_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: 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_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_030c: Unknown result type (might be due to invalid IL or missing references)
		//IL_048e: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_049c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bd: 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_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0530: Unknown result type (might be due to invalid IL or missing references)
		//IL_053d: Unknown result type (might be due to invalid IL or missing references)
		//IL_058e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0593: Unknown result type (might be due to invalid IL or missing references)
		//IL_0658: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		if (!smoothedPosInitialized)
		{
			return;
		}
		if ((Object)(object)mineshaftBottomTarget != (Object)null && (Object)(object)mineshaftTopTarget != (Object)null && TryGetPosition(mineshaftTopTarget, out var pos))
		{
			float y = smoothedPlayerPos.y;
			float y2 = pos.y;
			mainEntranceTarget = ((y >= y2 - 8f) ? mineshaftTopTarget : mineshaftBottomTarget);
		}
		if (!TryGetPosition(mainEntranceTarget, out var pos2))
		{
			if ((Object)(object)mainEntranceRoot != (Object)null)
			{
				mainEntranceRoot.SetActive(false);
			}
			mainEntranceTarget = null;
		}
		bool flag = (Object)(object)mineshaftBottomTarget != (Object)null && (Object)(object)mainEntranceTarget == (Object)(object)mineshaftBottomTarget;
		if (flag)
		{
			pos2 = ElevatorNudge(smoothedPlayerPos, pos2, 1.8f);
		}
		ShowLinesPreset value = Plugin.ShowLines.Value;
		Color color = Plugin.ResolveColor(Plugin.MainEntranceColorPreset.Value, Plugin.MainEntranceCustomColor.Value, Color.green);
		LineStyle value2 = Plugin.MainEntranceLineStyle.Value;
		float width = Plugin.ResolveWidth(Plugin.MainEntranceLineWidth.Value);
		Color val = Plugin.ResolveColor(Plugin.FireExitColorPreset.Value, Plugin.FireExitCustomColor.Value, Color.red);
		LineStyle value3 = Plugin.FireExitLineStyle.Value;
		float width2 = Plugin.ResolveWidth(Plugin.FireExitLineWidth.Value);
		float num = 0.18f;
		if ((Object)(object)mainEntranceRoot != (Object)null && (Object)(object)mainEntranceTarget != (Object)null && value != ShowLinesPreset.FireExitsOnly)
		{
			mainEntranceRoot.SetActive(true);
			if (!TryGetPosition(mainEntranceTarget, out var pos3))
			{
				pos3 = pos2;
			}
			PathResult? path = GetPath(smoothedPlayerPos, pos2, pos3);
			if (!path.HasValue && (Object)(object)mineshaftBottomTarget != (Object)null && (Object)(object)realMainEntrance != (Object)null && (Object)(object)mainEntranceTarget != (Object)(object)realMainEntrance)
			{
				Plugin.Logger.LogWarning((object)"LeadMeOut: mineshaft main path failed — falling back to the real entrance door.");
				pos2 = realMainEntrance.position;
				flag = false;
				path = GetPath(smoothedPlayerPos, pos2, realMainEntrance.position);
			}
			if (path.HasValue)
			{
				bool flag2 = LineEndsAtElevator(path.Value, flag);
				RenderPath(mainEntranceRoot, mainEntranceSegments, mainEntranceDiamonds, mainEntranceShapes, path.Value.Points, color, value2, width, 0f, 0f, pos2, path.Value.IsLockedDoor && !flag2);
				float brightness = ((path.Value.IsDeadEnd && !flag2) ? Mathf.Lerp(0.3f, 1f, Mathf.Sin(pulseTimer * 4f) * 0.5f + 0.5f) : 1f);
				mainEntranceMarker = UpdateDeadEndMarker(mainEntranceMarker, mainEntranceRoot, path.Value.IsDeadEnd || flag2, path.Value.Points, color, brightness, flag2);
			}
			else
			{
				HideSegments(mainEntranceSegments);
				HideShapes(mainEntranceShapes);
				if ((Object)(object)mainEntranceMarker != (Object)null)
				{
					mainEntranceMarker.SetActive(false);
				}
			}
		}
		else if ((Object)(object)mainEntranceRoot != (Object)null)
		{
			mainEntranceRoot.SetActive(false);
		}
		if (value != ShowLinesPreset.MainEntranceOnly)
		{
			Vector3 pos4;
			bool flag3 = (Object)(object)mineshaftBottomTarget != (Object)null && TryGetPosition(mineshaftTopTarget, out pos4) && smoothedPlayerPos.y >= pos4.y - 8f;
			Vector3 pos5 = Vector3.zero;
			if (flag3 && !TryGetPosition(mineshaftBottomTarget, out pos5))
			{
				flag3 = false;
			}
			List<Vector3> list = new List<Vector3>();
			for (int i = 0; i < fireExitTargets.Count && i < fireExitRoots.Count; i++)
			{
				if (!TryGetPosition(fireExitTargets[i], out var pos6) && !flag3)
				{
					if ((Object)(object)fireExitRoots[i] != (Object)null)
					{
						fireExitRoots[i].SetActive(false);
					}
					continue;
				}
				while (fireExitMarkers.Count <= i)
				{
					fireExitMarkers.Add(null);
				}
				fireExitRoots[i].SetActive(true);
				float lateralOffset = num * (float)(i + 1);
				Color color2 = ((i == 0) ? val : DarkenColor(val, 0.15f * (float)i));
				Vector3 val2 = (flag3 ? ElevatorNudge(smoothedPlayerPos, pos5, 2.2f) : pos6);
				Vector3 value4 = (flag3 ? pos5 : pos6);
				PathResult? path2 = GetPath(smoothedPlayerPos, val2, value4);
				if (path2.HasValue)
				{
					bool flag4 = LineEndsAtElevator(path2.Value, flag3);
					RenderPath(fireExitRoots[i], fireExitSegmentSets[i], fireExitDiamondSets[i], fireExitShapeSets[i], path2.Value.Points, color2, value3, width2, lateralOffset, 0f, val2, path2.Value.IsLockedDoor && !flag4);
					bool flag5 = path2.Value.IsDeadEnd || flag4;
					if (flag5)
					{
						Vector3 val3 = path2.Value.Points[path2.Value.Points.Count - 1];
						foreach (Vector3 item in list)
						{
							if (Vector3.Distance(item, val3) < 2f)
							{
								flag5 = false;
								break;
							}
						}
						if (flag5)
						{
							list.Add(val3);
						}
					}
					float brightness2 = ((path2.Value.IsDeadEnd && !flag4) ? Mathf.Lerp(0.3f, 1f, Mathf.Sin(pulseTimer * 4f) * 0.5f + 0.5f) : 1f);
					fireExitMarkers[i] = UpdateDeadEndMarker(fireExitMarkers[i], fireExitRoots[i], flag5, path2.Value.Points, color2, brightness2, flag4, lateralOffset);
				}
				else
				{
					HideSegments(fireExitSegmentSets[i]);
					HideShapes(fireExitShapeSets[i]);
					if (i < fireExitMarkers.Count && (Object)(object)fireExitMarkers[i] != (Object)null)
					{
						fireExitMarkers[i].SetActive(false);
					}
				}
			}
			return;
		}
		foreach (GameObject fireExitRoot in fireExitRoots)
		{
			if ((Object)(object)fireExitRoot != (Object)null)
			{
				fireExitRoot.SetActive(false);
			}
		}
	}

	private Color DarkenColor(Color c, float amount)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_00a4: 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_0031: 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_0055: 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_0068: Unknown result type (might be due to invalid IL or missing references)
		if (c.r < 0.05f && c.g < 0.05f && c.b < 0.05f)
		{
			return new Color(Mathf.Min(1f, c.r + amount), Mathf.Min(1f, c.g + amount), Mathf.Min(1f, c.b + amount), c.a);
		}
		return new Color(Mathf.Max(0f, c.r - amount), Mathf.Max(0f, c.g - amount), Mathf.Max(0f, c.b - amount), c.a);
	}

	private bool PathHitsWall(List<Vector3> corners, out Vector3 blockPoint, out int blockIndex)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0097: 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_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_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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: 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_00e0: 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_0114: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: 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_013f: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		blockPoint = Vector3.zero;
		blockIndex = -1;
		int num = LayerMask.NameToLayer("Room");
		if (num < 0)
		{
			return false;
		}
		int num2 = 1 << num;
		float[] array = new float[3] { 0.4f, 1f, 1.6f };
		RaycastHit val8 = default(RaycastHit);
		for (int i = 1; i < corners.Count; i++)
		{
			Vector3 val = corners[i - 1];
			Vector3 val2 = corners[i];
			Vector3 val3 = val2 - val;
			val3.y = 0f;
			if (((Vector3)(ref val3)).magnitude < 0.05f)
			{
				continue;
			}
			int num3 = 0;
			RaycastHit val4 = default(RaycastHit);
			float[] array2 = array;
			Vector3 val7;
			foreach (float num4 in array2)
			{
				Vector3 val5 = val + Vector3.up * num4;
				Vector3 val6 = val2 + Vector3.up * num4;
				val7 = val6 - val5;
				Vector3 normalized = ((Vector3)(ref val7)).normalized;
				float num5 = Vector3.Distance(val5, val6);
				if (Physics.Raycast(val5, normalized, ref val8, num5, num2, (QueryTriggerInteraction)1))
				{
					if (num3 == 0)
					{
						val4 = val8;
					}
					num3++;
				}
			}
			if (num3 == array.Length)
			{
				val7 = val2 - val;
				Vector3 normalized2 = ((Vector3)(ref val7)).normalized;
				blockPoint = ((RaycastHit)(ref val4)).point - normalized2 * 0.4f;
				blockPoint.y = val.y;
				blockIndex = i;
				return true;
			}
		}
		return false;
	}

	private PathResult? GetPath(Vector3 from, Vector3 to, Vector3? doorSimKey = null)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: 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_0032: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_0424: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: 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_013f: 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_00e0: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: 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_044e: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: 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_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_05be: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f1: 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_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: 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_060e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0492: Unknown result type (might be due to invalid IL or missing references)
		//IL_0499: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0529: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: 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_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0554: Unknown result type (might be due to invalid IL or missing references)
		//IL_0559: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0569: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: 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_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val = default(NavMeshHit);
		bool num = NavMesh.SamplePosition(from, ref val, 15f, -1);
		NavMeshHit val2 = default(NavMeshHit);
		bool flag = NavMesh.SamplePosition(to, ref val2, 2f, -1);
		if (!flag)
		{
			flag = NavMesh.SamplePosition(to, ref val2, 5f, -1);
		}
		if (!flag)
		{
			flag = NavMesh.SamplePosition(to, ref val2, 15f, -1);
		}
		if (!flag)
		{
			flag = NavMesh.SamplePosition(to, ref val2, 30f, -1);
		}
		if (!flag)
		{
			flag = NavMesh.SamplePosition(to, ref val2, 50f, -1);
		}
		if (!num || !flag)
		{
			return null;
		}
		List<Vector3> list = new List<Vector3>();
		list.Add(from);
		Vector3 val3 = ((NavMeshHit)(ref val)).position;
		bool flag2 = false;
		bool flag3 = false;
		bool flag4 = false;
		bool isDoorBlocked = false;
		NavMeshHit val8 = default(NavMeshHit);
		for (int i = 0; i < 3; i++)
		{
			NavMeshPath val4 = scratchPath;
			NavMesh.CalculatePath(val3, ((NavMeshHit)(ref val2)).position, -1, val4);
			Vector3[] corners;
			if ((int)val4.status == 0 && val4.corners.Length >= 2)
			{
				corners = val4.corners;
				foreach (Vector3 item in corners)
				{
					list.Add(item);
				}
				flag3 = true;
				break;
			}
			if (val4.corners.Length < 2)
			{
				if (i == 0 && FindNearestReachablePoint(((NavMeshHit)(ref val)).position, to, out var result))
				{
					NavMeshPath val5 = scratchPathDoor;
					NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, result, -1, val5);
					if ((int)val5.status == 0 && val5.corners.Length >= 2)
					{
						corners = val5.corners;
						foreach (Vector3 item2 in corners)
						{
							list.Add(item2);
						}
						flag3 = true;
						flag4 = true;
						Plugin.Logger.LogDebug((object)$"LeadMeOut: reached nearest point on player's island: {result} (door unreachable — separate NavMesh island).");
						break;
					}
				}
				flag2 = true;
				break;
			}
			if (Vector3.Distance(val4.corners[val4.corners.Length - 1], ((NavMeshHit)(ref val2)).position) <= 1.5f)
			{
				corners = val4.corners;
				foreach (Vector3 item3 in corners)
				{
					list.Add(item3);
				}
				flag3 = true;
				break;
			}
			Vector3 position = ((NavMeshHit)(ref val2)).position;
			Vector3 val6 = val4.corners[val4.corners.Length - 1];
			float num2 = Vector3.Distance(val3, position);
			float num3 = Vector3.Distance(val6, position);
			if (num3 > num2 + 3f)
			{
				flag2 = true;
				break;
			}
			corners = val4.corners;
			foreach (Vector3 item4 in corners)
			{
				list.Add(item4);
			}
			if (num3 >= num2)
			{
				flag2 = true;
				break;
			}
			Vector3 val7 = Vector3.zero;
			float num4 = num3;
			bool flag5 = false;
			for (int k = 0; k < 12; k++)
			{
				float num5 = (float)k * 30f * ((float)Math.PI / 180f);
				if (!NavMesh.SamplePosition(val6 + new Vector3(Mathf.Cos(num5), 0f, Mathf.Sin(num5)) * 2f, ref val8, 2f, -1) || Mathf.Abs(((NavMeshHit)(ref val8)).position.y - val6.y) > 1.5f)
				{
					continue;
				}
				float num6 = Vector3.Distance(((NavMeshHit)(ref val8)).position, position);
				if (!(num6 >= num4))
				{
					if (SegmentCrossesLockedDoor(val6, ((NavMeshHit)(ref val8)).position, out var hitPoint))
					{
						Plugin.Logger.LogDebug((object)$"LeadMeOut: hop rejected — would cross a locked door at {hitPoint}");
						continue;
					}
					if (!HopCrossesSeamOnly(val6, ((NavMeshHit)(ref val8)).position))
					{
						Plugin.Logger.LogDebug((object)$"LeadMeOut: hop rejected — gap to {((NavMeshHit)(ref val8)).position} is too wide to be a NavMesh seam (wall).");
						continue;
					}
					num4 = num6;
					val7 = ((NavMeshHit)(ref val8)).position;
					flag5 = true;
				}
			}
			if (!flag5)
			{
				flag2 = true;
				flag4 = true;
				break;
			}
			list.Add(val7);
			val3 = val7;
		}
		if (!flag3 && !flag4)
		{
			flag2 = true;
			flag4 = true;
		}
		if (flag4)
		{
			Vector3 position2 = ((NavMeshHit)(ref val2)).position;
			Plugin.Logger.LogDebug((object)$"LeadMeOut: PATH DEAD-END — attempting door simulation for target {position2}");
			if (FindBlockingDoorCached(from, position2, (Vector3)(((??)doorSimKey) ?? position2), out var doorPoint))
			{
				NavMeshPath val9 = scratchPathDoor;
				NavMeshHit val10 = default(NavMeshHit);
				if (NavMesh.SamplePosition(doorPoint, ref val10, 3f, -1) && NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, ((NavMeshHit)(ref val10)).position, -1, val9) && val9.corners.Length >= 2)
				{
					list = new List<Vector3>(val9.corners);
					list[0] = from;
					list.Add(doorPoint);
					flag2 = true;
					flag4 = true;
					isDoorBlocked = true;
				}
			}
		}
		if (list.Count < 2)
		{
			return null;
		}
		list[0] = from;
		if (!flag2 && PathCrossesLockedDoor(list, out var doorPoint2))
		{
			int num7 = 0;
			float num8 = float.MaxValue;
			for (int l = 0; l < list.Count; l++)
			{
				float num9 = Vector3.Distance(list[l], doorPoint2);
				if (num9 < num8)
				{
					num8 = num9;
					num7 = l;
				}
			}
			List<Vector3> list2 = new List<Vector3>();
			for (int m = 0; m <= num7; m++)
			{
				list2.Add(list[m]);
			}
			if (list2.Count > 0 && Vector3.Distance(list2[list2.Count - 1], doorPoint2) > 0.5f)
			{
				list2.Add(doorPoint2);
			}
			if (list2.Count >= 2)
			{
				list = list2;
				flag2 = true;
				flag4 = true;
				isDoorBlocked = true;
			}
		}
		Vector3[] collection = CenterCorners(list.ToArray());
		HashSet<int> pinned;
		List<Vector3> corners2 = SnapThroughDoorways(new List<Vector3>(collection), out pinned);
		List<Vector3> list3 = SmoothPath(corners2, pinned);
		for (int n = 0; n < list3.Count; n++)
		{
			list3[n] += Vector3.up * 0.1f;
		}
		float num10 = Plugin.ResolveRenderDistance(Plugin.RenderDistance.Value);
		if (num10 < float.MaxValue && !flag2)
		{
			list3 = CullByDistance(list3, from, num10);
		}
		if (list3.Count < 2)
		{
			return null;
		}
		return new PathResult
		{
			Points = list3,
			IsLockedDoor = flag2,
			IsDeadEnd = flag4,
			IsDoorBlocked = isDoorBlocked
		};
	}

	private int ComputeLockSignature()
	{
		int num = 0;
		foreach (var item in GetDoorCache())
		{
			if (!((Object)(object)item.door == (Object)null) && item.door.isLocked)
			{
				int instanceID = ((Object)item.door).GetInstanceID();
				instanceID ^= instanceID >> 16;
				instanceID *= 73244475;
				instanceID ^= instanceID >> 16;
				num ^= instanceID;
			}
		}
		return num;
	}

	private void ResetDoorGraph()
	{
		doorEdges.Clear();
		graphPoints.Clear();
		regionReps.Clear();
		graphReady = false;
		graphBuilding = false;
		graphPointIndex = 0;
		graphRepIndex = 0;
	}

	private void BeginDoorGraph()
	{
		//IL_006b: 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_0074: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00a4: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_00be: 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: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_012c: 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_0139: 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_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)
		ResetDoorGraph();
		NavMeshHit val2 = default(NavMeshHit);
		NavMeshHit val3 = default(NavMeshHit);
		foreach (var item in GetDoorCache())
		{
			if (doorEdges.Count >= 64)
			{
				break;
			}
			if (!((Object)(object)item.door == (Object)null) && !((Object)(object)item.col == (Object)null) && item.door.isLocked)
			{
				Bounds bounds = item.col.bounds;
				Vector3 center = ((Bounds)(ref bounds)).center;
				bounds = item.col.bounds;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				Vector3 val = ((extents.x < extents.z) ? Vector3.right : Vector3.forward);
				float num = Mathf.Min(extents.x, extents.z);
				if (NavMesh.SamplePosition(center + val * (num + 1.2f), ref val2, 2f, -1) && NavMesh.SamplePosition(center - val * (num + 1.2f), ref val3, 2f, -1))
				{
					DoorEdge doorEdge = new DoorEdge
					{
						door = item.door,
						center = center,
						sideA = ((NavMeshHit)(ref val2)).position,
						sideB = ((NavMeshHit)(ref val3)).position
					};
					doorEdges.Add(doorEdge);
					graphPoints.Add(new SidePoint
					{
						pos = doorEdge.sideA,
						owner = doorEdge,
						isSideA = true
					});
					graphPoints.Add(new SidePoint
					{
						pos = doorEdge.sideB,
						owner = doorEdge,
						isSideA = false
					});
				}
			}
		}
		graphBuilding = doorEdges.Count > 0;
		graphReady = doorEdges.Count == 0;
		Plugin.Logger.LogDebug((object)$"LeadMeOut: DoorGraph — build started: {doorEdges.Count} locked door(s), {graphPoints.Count} side point(s).");
	}

	private void StepDoorGraph()
	{
		//IL_00ce: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		if (!graphBuilding || graphReady)
		{
			return;
		}
		int num = 6;
		while (num > 0 && graphPointIndex < graphPoints.Count)
		{
			SidePoint sidePoint = graphPoints[graphPointIndex];
			if (sidePoint.region >= 0)
			{
				graphPointIndex++;
				graphRepIndex = 0;
			}
			else if (graphRepIndex < regionReps.Count)
			{
				bool num2 = IsPathComplete(sidePoint.pos, regionReps[graphRepIndex]);
				num--;
				if (num2)
				{
					sidePoint.region = graphRepIndex;
					graphPointIndex++;
					graphRepIndex = 0;
				}
				else
				{
					graphRepIndex++;
				}
			}
			else
			{
				sidePoint.region = regionReps.Count;
				regionReps.Add(sidePoint.pos);
				graphPointIndex++;
				graphRepIndex = 0;
			}
		}
		if (graphPointIndex < graphPoints.Count)
		{
			return;
		}
		foreach (SidePoint graphPoint in graphPoints)
		{
			if (graphPoint.isSideA)
			{
				graphPoint.owner.regionA = graphPoint.region;
			}
			else
			{
				graphPoint.owner.regionB = graphPoint.region;
			}
		}
		graphReady = true;
		graphBuilding = false;
		doorSimCache.Clear();
		doorSimMisses.Clear();
		Plugin.Logger.LogInfo((object)$"LeadMeOut: DoorGraph — built: {doorEdges.Count} locked door(s) across {regionReps.Count} region(s).");
	}

	private int RegionOf(Vector3 p)
	{
		//IL_0000: 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_0025: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val = default(NavMeshHit);
		if (!NavMesh.SamplePosition(p, ref val, 5f, -1))
		{
			return -1;
		}
		for (int i = 0; i < regionReps.Count; i++)
		{
			if (IsPathComplete(((NavMeshHit)(ref val)).position, regionReps[i]))
			{
				return i;
			}
		}
		return -1;
	}

	private bool FindBlockingDoorCached(Vector3 from, Vector3 to, Vector3 cacheKey, out Vector3 doorPoint)
	{
		//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_001f: 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_005e: 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_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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)
		doorPoint = Vector3.zero;
		if (doorSimTimer < 2f)
		{
			if (doorSimCache.TryGetValue(cacheKey, out doorPoint))
			{
				return true;
			}
			if (doorSimMisses.Contains(cacheKey))
			{
				return false;
			}
		}
		else
		{
			doorSimTimer = 0f;
			doorSimCache.Clear();
			doorSimMisses.Clear();
		}
		bool num = FindBlockingDoor(from, to, out doorPoint);
		if (num)
		{
			doorSimCache[cacheKey] = doorPoint;
			return num;
		}
		doorSimMisses.Add(cacheKey);
		return num;
	}

	private bool FindBlockingDoor(Vector3 from, Vector3 to, out Vector3 doorPoint)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_0229: 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_023e: Unknown result type (might be due to invalid IL or missing references)
		doorPoint = Vector3.zero;
		if (!graphReady)
		{
			Plugin.Logger.LogDebug((object)"LeadMeOut: DoorSim — region graph still building.");
			return false;
		}
		if (doorEdges.Count == 0)
		{
			return false;
		}
		int num = RegionOf(from);
		int num2 = RegionOf(to);
		Plugin.Logger.LogDebug((object)$"LeadMeOut: DoorSim — playerRegion={num} exitRegion={num2} (regions={regionReps.Count}, doors={doorEdges.Count})");
		if (num < 0 || num2 < 0)
		{
			Plugin.Logger.LogDebug((object)"LeadMeOut: DoorSim — player or exit sits in no door-bounded region. Blockage is structural, not a door.");
			return false;
		}
		if (num == num2)
		{
			Plugin.Logger.LogDebug((object)"LeadMeOut: DoorSim — player and exit share a region. Blockage is not a door.");
			return false;
		}
		HashSet<int> hashSet = new HashSet<int>();
		Dictionary<int, DoorEdge> dictionary = new Dictionary<int, DoorEdge>();
		Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
		Queue<int> queue = new Queue<int>();
		hashSet.Add(num);
		queue.Enqueue(num);
		bool flag = false;
		while (queue.Count > 0 && !flag)
		{
			int num3 = queue.Dequeue();
			foreach (DoorEdge doorEdge2 in doorEdges)
			{
				if (doorEdge2.regionA < 0 || doorEdge2.regionB < 0 || doorEdge2.regionA == doorEdge2.regionB)
				{
					continue;
				}
				int num4;
				if (doorEdge2.regionA == num3)
				{
					num4 = doorEdge2.regionB;
				}
				else
				{
					if (doorEdge2.regionB != num3)
					{
						continue;
					}
					num4 = doorEdge2.regionA;
				}
				if (!hashSet.Contains(num4))
				{
					hashSet.Add(num4);
					dictionary[num4] = doorEdge2;
					dictionary2[num4] = num3;
					queue.Enqueue(num4);
					if (num4 == num2)
					{
						flag = true;
						break;
					}
				}
			}
		}
		if (!flag)
		{
			Plugin.Logger.LogDebug((object)$"LeadMeOut: DoorSim — no chain of locked doors links region {num} to region {num2}.");
			return false;
		}
		int num5 = num2;
		DoorEdge doorEdge = null;
		int num6 = 0;
		while (num5 != num)
		{
			doorEdge = dictionary[num5];
			num5 = dictionary2[num5];
			num6++;
		}
		if (doorEdge == null)
		{
			return false;
		}
		doorPoint = doorEdge.center;
		Plugin.Logger.LogInfo((object)$"LeadMeOut:   >>> BLOCKING DOOR at {doorPoint} — first of {num6} locked door(s) between you and this exit.");
		return true;
	}

	private float ClosestReachableDistanceTo(Vector3 from, Vector3 to)
	{
		//IL_0000: 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_0035: 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_004a: 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_008b: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		NavMeshHit val = default(NavMeshHit);
		if (!NavMesh.SamplePosition(from, ref val, 3f, -1))
		{
			return float.MaxValue;
		}
		NavMeshHit val2 = default(NavMeshHit);
		if (!NavMesh.SamplePosition(to, ref val2, 5f, -1))
		{
			return float.MaxValue;
		}
		NavMeshPath val3 = scratchPathReach;
		NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, ((NavMeshHit)(ref val2)).position, -1, val3);
		if ((int)val3.status == 0)
		{
			return 0f;
		}
		if (val3.corners.Length == 0)
		{
			return Vector3.Distance(((NavMeshHit)(ref val)).position, ((NavMeshHit)(ref val2)).position);
		}
		return Vector3.Distance(val3.corners[val3.corners.Length - 1], ((NavMeshHit)(ref val2)).position);
	}

	private bool IsPathComplete(Vector3 a, Vector3 b)
	{
		//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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		NavMeshPath val = scratchPathReach;
		if (!NavMesh.CalculatePath(a, b, -1, val))
		{
			return false;
		}
		return (int)val.status == 0;
	}

	private bool HopCrossesSeamOnly(Vector3 a, Vector3 b)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_001a: 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_0021: 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_0032: 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)
		Vector3 val = b - a;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude < 0.001f)
		{
			return true;
		}
		Vector3 val2 = val / magnitude;
		float num = 0f;
		NavMeshHit val3 = default(NavMeshHit);
		for (float num2 = 0f; num2 <= magnitude; num2 += 0.1f)
		{
			if (NavMesh.SamplePosition(a + val2 * num2, ref val3, 0.25f, -1))
			{
				num = 0f;
				continue;
			}
			num += 0.1f;
			if (num > 0.4f)
			{
				return false;
			}
		}
		return true;
	}

	private bool SegmentCrossesLockedDoor(Vector3 a, Vector3 b, out Vector3 hitPoint)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//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_0095: 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_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_00b9: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		hitPoint = Vector3.zero;
		Vector3 val = b - a;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude < 0.001f)
		{
			return false;
		}
		Vector3 val2 = val / magnitude;
		float num = default(float);
		foreach (var item in GetDoorCache())
		{
			if (!((Object)(object)item.door == (Object)null) && !((Object)(object)item.col == (Object)null) && item.door.isLocked)
			{
				Bounds bounds = item.col.bounds;
				((Bounds)(ref bounds)).Expand(new Vector3(0.4f, 1f, 0.4f));
				if (((Bounds)(ref bounds)).Contains(a))
				{
					hitPoint = a;
					return true;
				}
				if (((Bounds)(ref bounds)).IntersectRay(new Ray(a, val2), ref num) && num <= magnitude)
				{
					hitPoint = a + val2 * num;
					return true;
				}
			}
		}
		return false;
	}

	private bool PathCrossesLockedDoor(List<Vector3> corners, out Vector3 doorPoint)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		doorPoint = Vector3.zero;
		for (int i = 1; i < corners.Count; i++)
		{
			if (SegmentCrossesLockedDoor(corners[i - 1], corners[i], out doorPoint))
			{
				Plugin.Logger.LogDebug((object)$"LeadMeOut: path runs THROUGH a locked door at {doorPoint} — truncating there.");
				return true;
			}
		}
		return false;
	}

	private float DistancePointToSegment(Vector3 p, Vector3 a, Vector3 b)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: 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_0019: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = b - a;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (magnitude < 0.001f)
		{
			return Vector3.Distance(p, a);
		}
		float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / (magnitude * magnitude));
		Vector3 val2 = a + val * num;
		return Vector3.Distance(p, val2);
	}

	private List<Vector3> CullByDistance(List<Vector3> points, Vector3 origin, float maxDist)
	{
		//IL_000d: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: 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_0064: 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)
		List<Vector3> list = new List<Vector3>();
		for (int i = 0; i < points.Count; i++)
		{
			float num = Vector3.Distance(origin, points[i]);
			if (num > maxDist)
			{
				if (i > 0)
				{
					float num2 = Vector3.Distance(origin, points[i - 1]);
					if (Vector3.Distance(points[i - 1], points[i]) > 0.001f)
					{
						float num3 = (maxDist - num2) / (num - num2);
						list.Add(Vector3.Lerp(points[i - 1], points[i], Mathf.Clamp01(num3)));
					}
				}
				break;
			}
			list.Add(points[i]);
		}
		return list;
	}

	private void RenderPath(GameObject root, List<LineRenderer> segments, List<LineRenderer> diamonds, List<GameObject> shapes, List<Vector3> points, Color color, LineStyle style, float width, float lateralOffset, float phaseOffset, Vector3 targetPos, bool isLockedDoor = false)
	{
		//IL_0035: 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_0047: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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)
		if (isLockedDoor)
		{
			float num = Mathf.Sin(pulseTimer * 4f) * 0.5f + 0.5f;
			float num2 = Mathf.Lerp(0.3f, 1f, num);
			((Color)(ref color))..ctor(color.r * num2, color.g * num2, color.b * num2, color.a);
		}
		if (lateralOffset != 0f)
		{
			points = ApplyLateralOffset(points, lateralOffset);
		}
		if (style == LineStyle.Arrow || style == LineStyle.Triangle || style == LineStyle.Diamond || style == LineStyle.Heart || style == LineStyle.Pawprint)
		{
			HideSegments(segments);
			HideSegments(diamonds);
			RenderShapes(root, shapes, points, color, style, width, targetPos);
			return;
		}
		HideShapes(shapes);
		float dashLength;
		float gapLength;
		if (style == LineStyle.Dotted)
		{
			dashLength = width;
			gapLength = width * 8f + 0.2f;
		}
		else
		{
			dashLength = 0.4f;
			gapLength = 0.35f;
		}
		List<(Vector3, Vector3)> dashes = ((style == LineStyle.Solid) ? BuildSolid(points) : BuildDashes(points, dashLength, gapLength, phaseOffset));
		UpdateLineSegments(root, segments, dashes, color, width);
		if (style == LineStyle.Dotted)
		{
			UpdateDiamonds(root, diamonds, dashes, color, width);
		}
		else
		{
			HideSegments(diamonds);
		}
	}

	private bool LineEndsAtElevator(PathResult result, bool targetIsElevator)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)mineshaftBottomTarget == (Object)null)
		{
			return false;
		}
		if (!targetIsElevator)
		{
			return false;
		}
		if (!TryGetPosition(mineshaftBottomTarget, out var pos))
		{
			return false;
		}
		if (result.IsDoorBlocked)
		{
			return false;
		}
		List<Vector3> points = result.Points;
		if (points == null || points.Count == 0)
		{
			return false;
		}
		Vector3 val = points[points.Count - 1];
		float num = val.x - pos.x;
		float num2 = val.z - pos.z;
		float num3 = Mathf.Sqrt(num * num + num2 * num2);
		if (result.IsDeadEnd)
		{
			Plugin.Logger.LogDebug((object)($"LeadMeOut: elevator check — line ends {num3:F1} away (XZ) from the shaft, " + $"dY {Mathf.Abs(val.y - pos.y):F1}, radius {10f} => " + ((num3 <= 10f) ? "ELEVATOR" : "not the elevator")));
		}
		return num3 <= 10f;
	}

	private GameObject UpdateDeadEndMarker(GameObject marker, GameObject root, bool show, List<Vector3> points, Color color, float brightness, bool elevatorEndpoint, float lateralOffset = 0f)
	{
		//IL_002e: 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)
		//IL_003f: 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_0045: 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_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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_006f: 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_0078: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_00b2: 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_00dd: Expected O, but got Unknown
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Expected O, but got Unknown
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: 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_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: 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_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: 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_02bf: 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_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: 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_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: 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_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: 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_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: 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_0262: 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_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_035a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		if (!show || points == null || points.Count < 2)
		{
			if ((Object)(object)marker != (Object)null)
			{
				marker.SetActive(false);
			}
			return marker;
		}
		Vector3 val = points[points.Count - 1];
		Vector3 val2 = points[points.Count - 2];
		Vector3 val3 = val - val2;
		Vector3 normalized = ((Vector3)(ref val3)).normalized;
		if (Mathf.Abs(lateralOffset) > 0.001f)
		{
			val3 = Vector3.Cross(Vector3.up, normalized);
			Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
			val -= normalized2 * lateralOffset;
			val2 -= normalized2 * lateralOffset;
		}
		bool flag = elevatorEndpoint;
		Vector3 doorPos = Vector3.zero;
		Vector3 doorNormal = Vector3.up;
		bool flag2 = false;
		if (!flag)
		{
			flag2 = FindLockedDoorNear(val, out doorPos, out doorNormal);
		}
		if (flag)
		{
			brightness = 1f;
		}
		if ((Object)(object)marker == (Object)null)
		{
			marker = new GameObject("DeadEndMarker");
			marker.transform.SetParent(root.transform, false);
			marker.AddComponent<MeshFilter>();
			MeshRenderer obj = marker.AddComponent<MeshRenderer>();
			((Renderer)obj).material = new Material(Shader.Find("HDRP/Unlit"));
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
		}
		marker.SetActive(true);
		MeshFilter component = marker.GetComponent<MeshFilter>();
		string text = (flag2 ? "lock" : (flag ? "elevator" : "arrow"));
		if (((Object)marker).name != "DeadEndMarker_" + text)
		{
			component.mesh = (flag2 ? BuildLockMesh() : (flag ? BuildElevatorMesh() : Build4WayArrowMesh()));
			((Object)marker).name = "DeadEndMarker_" + text;
		}
		Vector3 val6;
		if (flag2)
		{
			Vector3 val4 = -normalized;
			val4.y = 0f;
			if (((Vector3)(ref val4)).sqrMagnitude < 0.001f)
			{
				val4 = -doorNormal;
			}
			((Vector3)(ref val4)).Normalize();
			Vector3 val5 = doorNormal;
			val6 = doorPos + val4 * 0.6f;
		}
		else
		{
			Vector3 val5 = Vector3.up;
			val6 = val + Vector3.up * 0.05f;
			int num = -1;
			RaycastHit val7 = default(RaycastHit);
			if (Physics.Raycast(val2, normalized, ref val7, 1f, num, (QueryTriggerInteraction)1) && Mathf.Abs(((RaycastHit)(ref val7)).normal.y) < 0.5f)
			{
				val5 = ((RaycastHit)(ref val7)).normal;
				val6 = val - Vector3.Dot(val - ((RaycastHit)(ref val7)).point, val5) * val5 + val5 * 0.05f + Vector3.up * 0.25f;
			}
			else if (Physics.Raycast(val + Vector3.up * 0.5f, Vector3.down, ref val7, 2f, num, (QueryTriggerInteraction)1))
			{
				val5 = ((RaycastHit)(ref val7)).normal;
				val6 = new Vector3(val.x, ((RaycastHit)(ref val7)).point.y, val.z) + val5 * 0.05f;
			}
		}
		marker.transform.position = val6 + Vector3.up * 0.7f;
		PlayerControllerB localPlayer = GetLocalPlayer();
		if ((Object)(object)localPlayer != (Object)null)
		{
			Vector3 val8 = ((Component)localPlayer).transform.position - marker.transform.position;
			val8.y = 0f;
			if (((Vector3)(ref val8)).sqrMagnitude > 0.001f)
			{
				Quaternion rotation = Quaternion.LookRotation(Vector3.up, ((Vector3)(ref val8)).normalized);
				marker.transform.rotation = rotation;
			}
		}
		marker.transform.localScale = Vector3.one * 0.8f;
		MeshRenderer component2 = marker.GetComponent<MeshRenderer>();
		if ((Object)(object)component2 != (Object)null)
		{
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(color.r * brightness, color.g * brightness, color.b * brightness, 1f);
			((Renderer)component2).material.color = color2;
		}
		return marker;
	}

	private bool FindLockedDoorNear(Vector3 point, out Vector3 doorPos, out Vector3 doorNormal)
	{
		//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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//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_00c2: 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)
		doorPos = point;
		doorNormal = Vector3.up;
		DoorLock val = null;
		float num = 4f;
		foreach (var item2 in GetDoorCache())
		{
			DoorLock item = item2.door;
			if (!((Object)(object)item == (Object)null) && item.isLocked)
			{
				float num2 = Vector3.Distance(point, ((Component)item).transform.position);
				if (num2 < num)
				{
					num = num2;
					val = item;
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		doorPos = ((Component)val).transform.position;
		doorNormal = ((Component)val).transform.forward;
		doorNormal.y = 0f;
		if (((Vector3)(ref doorNormal)).sqrMagnitude < 0.001f)
		{
			doorNormal = Vector3.forward;
		}
		((Vector3)(ref doorNormal)).Normalize();
		return true;
	}

	private void RenderShapes(GameObject root, List<GameObject> shapes, List<Vector3> points, Color color, LineStyle style, float width, Vector3 targetPos)
	{
		//IL_00c6: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		float num = ((style != LineStyle.Heart && style != LineStyle.Pawprint) ? (width * 20f + 0.6f) : (width * 12f + 0.4f));
		if (num < 0.05f)
		{
			num = 0.05f;
		}
		List<(Vector3, Vector3)> shapePlacements = GetShapePlacements(points, num);
		for (int i = 0; i < shapes.Count; i++)
		{
			if (i < shapePlacements.Count)
			{
				shapes[i].SetActive(true);
				MeshFilter component = shapes[i].GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null)
				{
					component.mesh = (Mesh)(style switch
					{
						LineStyle.Pawprint => BuildPawprintMesh(), 
						LineStyle.Diamond => BuildDiamondMesh(), 
						LineStyle.Triangle => BuildTriangleMesh(), 
						LineStyle.Arrow => BuildArrowMesh(), 
						_ => BuildHeartMesh(), 
					});
				}
				ApplyShapeTransform(shapes[i], shapePlacements[i].Item1, shapePlacements[i].Item2, width);
				((Renderer)shapes[i].GetComponent<MeshRenderer>()).material.color = color;
			}
			else
			{
				shapes[i].SetActive(false);
			}
		}
		for (int j = shapes.Count; j < shapePlacements.Count; j++)
		{
			GameObject val = CreateShapeMesh(root, style, color, width);
			ApplyShapeTransform(val, shapePlacements[j].Item1, shapePlacements[j].Item2, width);
			shapes.Add(val);
		}
	}

	private List<(Vector3 pos, Vector3 dir)> GetShapePlacements(List<Vector3> points, float spacing)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0061: 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_0084: 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)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		List<(Vector3, Vector3)> list = new List<(Vector3, Vector3)>();
		int num = 200;
		float num2 = spacing * 0.5f;
		for (int i = 1; i < points.Count; i++)
		{
			if (list.Count >= num)
			{
				break;
			}
			Vector3 val = points[i - 1];
			Vector3 val2 = points[i];
			float num3 = Vector3.Distance(val, val2);
			if (num3 < 0.001f)
			{
				continue;
			}
			Vector3 val3 = val2 - val;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			float num4 = 0f;
			while (num4 < num3 && list.Count < num)
			{
				float num5 = spacing - num2;
				if (num4 + num5 <= num3)
				{
					num4 += num5;
					list.Add((val + normalized * num4, normalized));
					num2 = 0f;
				}
				else
				{
					num2 += num3 - num4;
					num4 = num3;
				}
			}
		}
		return list;
	}

	private void ApplyShapeTransform(GameObject shape, Vector3 pos, Vector3 dir, float width)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or mi