Decompiled source of GuidedCompanyRadar v1.0.0

GuidedCompanyRadar.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using GuidedCompanyRadar.Patches;
using GuidedCompanyRadar.Radar;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Khameli0n")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Standalone Facility Entrance Radar (Guided Company) mod for Lethal Company: RMB scanner path trails, entrance/fire-exit beacons, and distance HUD.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GuidedCompanyRadar")]
[assembly: AssemblyTitle("GuidedCompanyRadar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GuidedCompanyRadar
{
	public static class Configuration
	{
		public static ConfigEntry<bool> EnableEntranceRadar { get; private set; }

		public static ConfigEntry<string> TrailColorHex { get; private set; }

		public static ConfigEntry<float> PulseDuration { get; private set; }

		public static ConfigEntry<float> TrailWidth { get; private set; }

		public static ConfigEntry<float> HeightOffset { get; private set; }

		public static Color TrailColor { get; private set; } = new Color(1f, 0.42f, 0f, 1f);

		public static void Init(ConfigFile cfg)
		{
			//IL_00c5: 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)
			EnableEntranceRadar = cfg.Bind<bool>("EntranceRadar", "EnableEntranceRadar", true, "Enables RMB scanner facility radar trail, camera-facing floating billboard icons, and bottom-right visor distance HUD.");
			TrailColorHex = cfg.Bind<string>("EntranceRadar", "TrailColorHex", "#FF6A00", "Hex color code for the main entrance pulse trail and beacon.");
			PulseDuration = cfg.Bind<float>("EntranceRadar", "PulseDuration", 2.5f, "Duration of the pulse animation in seconds.");
			TrailWidth = cfg.Bind<float>("EntranceRadar", "TrailWidth", 0.24f, "Width of the pulse trail in meters.");
			HeightOffset = cfg.Bind<float>("EntranceRadar", "HeightOffset", 0.25f, "Vertical offset in meters above terrain.");
			Color trailColor = default(Color);
			if (ColorUtility.TryParseHtmlString(TrailColorHex.Value, ref trailColor))
			{
				TrailColor = trailColor;
			}
			else
			{
				TrailColor = new Color(1f, 0.42f, 0f, 1f);
			}
		}
	}
	[BepInPlugin("com.khameli0n.guidedcompanyradar", "GuidedCompanyRadar", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "com.khameli0n.guidedcompanyradar";

		public const string PLUGIN_NAME = "GuidedCompanyRadar";

		public const string PLUGIN_VERSION = "1.0.0";

		public static Plugin Instance { get; private set; }

		public static ManualLogSource Log { get; private set; }

		public static Harmony HarmonyInstance { get; private set; }

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Configuration.Init(((BaseUnityPlugin)this).Config);
			HarmonyInstance = new Harmony("com.khameli0n.guidedcompanyradar");
			Type[] array = new Type[2]
			{
				typeof(HUDScanPatch),
				typeof(RoundLifecyclePatch)
			};
			foreach (Type type in array)
			{
				try
				{
					HarmonyInstance.CreateClassProcessor(type).Patch();
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"Failed to patch {type.Name}: {arg}");
				}
			}
			try
			{
				if (Configuration.EnableEntranceRadar.Value)
				{
					PulseTrailRenderer.GetOrCreate();
				}
			}
			catch (Exception arg2)
			{
				Log.LogError((object)$"[EntranceRadar] Failed to initialize PulseTrailRenderer: {arg2}");
			}
			Log.LogInfo((object)("GuidedCompanyRadar v1.0.0 loaded (EntranceRadar=" + (Configuration.EnableEntranceRadar.Value ? "ENABLED" : "DISABLED") + ")."));
		}
	}
}
namespace GuidedCompanyRadar.Radar
{
	public class DoorInfo
	{
		public EntranceTeleport Teleport;

		public Vector3 WorldPosition;

		public Vector3 NavPosition;

		public int EntranceId;

		public bool IsFireExit;

		public bool IsEntranceToBuilding;

		public string DoorName;
	}
	public static class EntranceManager
	{
		private static GameObject scanNodeObject;

		private static Sprite mainDoorSprite;

		private static Sprite fireExitSprite;

		private static bool hasLoggedNoEntrance;

		public static Vector3 MainEntrancePosition { get; private set; }

		public static Vector3 MainEntranceNavPosition { get; private set; }

		public static bool HasValidEntrance { get; private set; }

		public static ScanNodeProperties ActiveScanNode { get; private set; }

		public static EntranceTeleport BestEntrance { get; private set; }

		public static void Clear()
		{
			//IL_000c: 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)
			HasValidEntrance = false;
			hasLoggedNoEntrance = false;
			MainEntrancePosition = Vector3.zero;
			MainEntranceNavPosition = Vector3.zero;
			BestEntrance = null;
			if ((Object)(object)scanNodeObject != (Object)null)
			{
				Object.Destroy((Object)(object)scanNodeObject);
				scanNodeObject = null;
				ActiveScanNode = null;
			}
		}

		public static bool GetDoors(out DoorInfo mainDoor, out List<DoorInfo> fireExits)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			mainDoor = null;
			fireExits = new List<DoorInfo>();
			EntranceTeleport[] array = Object.FindObjectsOfType<EntranceTeleport>();
			if (array != null)
			{
				EntranceTeleport[] array2 = array;
				foreach (EntranceTeleport val in array2)
				{
					if (!((Object)(object)val == (Object)null) && val.isEntranceToBuilding)
					{
						Vector3 worldPos = (((Object)(object)val.entrancePoint != (Object)null) ? val.entrancePoint.position : ((Component)val).transform.position);
						DoorInfo doorInfo = BuildDoorInfo(val, worldPos, val.entranceId, val.entranceId != 0, ((Object)val).name);
						if (val.entranceId == 0 && mainDoor == null)
						{
							mainDoor = doorInfo;
						}
						else
						{
							fireExits.Add(doorInfo);
						}
					}
				}
			}
			if (mainDoor == null)
			{
				mainDoor = TryFindFallbackMainDoor();
			}
			if (mainDoor == null && fireExits.Count > 0)
			{
				mainDoor = fireExits[0];
				fireExits.RemoveAt(0);
			}
			if (mainDoor != null)
			{
				MainEntrancePosition = mainDoor.WorldPosition;
				MainEntranceNavPosition = mainDoor.NavPosition;
				BestEntrance = mainDoor.Teleport;
				HasValidEntrance = true;
				EnsureScanNode();
				return true;
			}
			if (!hasLoggedNoEntrance)
			{
				hasLoggedNoEntrance = true;
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[EntranceRadar] No valid entrance doors found in current area.");
				}
			}
			HasValidEntrance = false;
			return false;
		}

		public static bool RefreshEntrances()
		{
			DoorInfo mainDoor;
			List<DoorInfo> fireExits;
			return GetDoors(out mainDoor, out fireExits);
		}

		private static DoorInfo TryFindFallbackMainDoor()
		{
			//IL_000f: 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_0015: 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_0023: 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)
			if ((Object)(object)RoundManager.Instance != (Object)null)
			{
				try
				{
					Vector3 val = RoundManager.FindMainEntrancePosition(true, true);
					if (val != Vector3.zero)
					{
						return BuildDoorInfo(null, val, 0, isFireExit: false, "RoundManager_MainEntrance");
					}
				}
				catch
				{
				}
			}
			GameObject val2 = GameObject.Find("EntranceTeleportA") ?? GameObject.Find("EntranceTeleportB") ?? GameObject.Find("MainEntrance");
			if ((Object)(object)val2 != (Object)null)
			{
				return BuildDoorInfo(val2.GetComponent<EntranceTeleport>(), val2.transform.position, 0, isFireExit: false, ((Object)val2).name);
			}
			return null;
		}

		private static DoorInfo BuildDoorInfo(EntranceTeleport teleport, Vector3 worldPos, int entranceId, bool isFireExit, string doorName)
		{
			//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_0027: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			Vector3 navPosition = worldPos;
			NavMeshHit val = default(NavMeshHit);
			if (NavMesh.SamplePosition(worldPos, ref val, 15f, -1))
			{
				navPosition = ((NavMeshHit)(ref val)).position;
			}
			return new DoorInfo
			{
				Teleport = teleport,
				WorldPosition = worldPos,
				NavPosition = navPosition,
				EntranceId = entranceId,
				IsFireExit = isFireExit,
				IsEntranceToBuilding = true,
				DoorName = doorName
			};
		}

		private static void EnsureScanNode()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_004e: Expected O, but got Unknown
			//IL_0058: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)scanNodeObject != (Object)null)
			{
				scanNodeObject.transform.position = MainEntrancePosition + Vector3.up * 1.5f;
			}
			else
			{
				if (!HasValidEntrance)
				{
					return;
				}
				try
				{
					scanNodeObject = new GameObject("GuidedCompany_EntranceScanNode");
					scanNodeObject.transform.position = MainEntrancePosition + Vector3.up * 1.5f;
					int num = LayerMask.NameToLayer("ScanNode");
					if (num != -1)
					{
						scanNodeObject.layer = num;
					}
					BoxCollider obj = scanNodeObject.AddComponent<BoxCollider>();
					((Collider)obj).isTrigger = true;
					obj.size = new Vector3(8f, 8f, 8f);
					ActiveScanNode = scanNodeObject.AddComponent<ScanNodeProperties>();
					ActiveScanNode.headerText = "FACILITY MAIN ENTRANCE";
					ActiveScanNode.subText = "Entry Door";
					ActiveScanNode.nodeType = 0;
					ActiveScanNode.minRange = 0;
					ActiveScanNode.maxRange = 250;
					ActiveScanNode.requiresLineOfSight = false;
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogInfo((object)$"[EntranceRadar] Scan node created at {scanNodeObject.transform.position}");
					}
				}
				catch (Exception ex)
				{
					ManualLogSource log2 = Plugin.Log;
					if (log2 != null)
					{
						log2.LogWarning((object)("[EntranceRadar] Could not create scan node: " + ex.Message));
					}
				}
			}
		}

		public static Sprite GetEntranceIconSprite()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mainDoorSprite != (Object)null)
			{
				return mainDoorSprite;
			}
			mainDoorSprite = CreateDoorSprite(new Color(1f, 0.45f, 0.05f, 0.95f), new Color(1f, 0.65f, 0.2f, 0.35f), new Color(1f, 0.5f, 0.1f, 0.25f), drawFireExitSlash: false);
			return mainDoorSprite;
		}

		public static Sprite GetFireExitIconSprite()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fireExitSprite != (Object)null)
			{
				return fireExitSprite;
			}
			fireExitSprite = CreateDoorSprite(new Color(0.85f, 0.08f, 0.12f, 0.95f), new Color(0.65f, 0.02f, 0.05f, 0.4f), new Color(0.6f, 0.05f, 0.08f, 0.35f), drawFireExitSlash: true);
			return fireExitSprite;
		}

		private static Sprite CreateDoorSprite(Color ringColor, Color haloColor, Color fillColor, bool drawFireExitSlash)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00c5: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					val.SetPixel(j, i, val2);
				}
			}
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(31.5f, 31.5f);
			for (int k = 0; k < 64; k++)
			{
				for (int l = 0; l < 64; l++)
				{
					float num = Vector2.Distance(new Vector2((float)l, (float)k), val3);
					if (num >= 21f && num <= 26f)
					{
						float num2 = Mathf.Clamp01(Mathf.Min(num - 21f, 26f - num));
						val.SetPixel(l, k, Color.Lerp(val2, ringColor, num2));
					}
					else if (num >= 18.5f && num <= 28.5f)
					{
						val.SetPixel(l, k, haloColor);
					}
				}
			}
			for (int m = 16; m <= 45; m++)
			{
				for (int n = 23; n <= 39; n++)
				{
					bool flag = n <= 25 || n >= 37 || m >= 43 || m <= 17;
					val.SetPixel(n, m, flag ? ringColor : fillColor);
				}
			}
			if (drawFireExitSlash)
			{
				for (int num3 = 0; num3 < 16; num3++)
				{
					int num4 = 25 + num3 * 11 / 15;
					int num5 = 20 + num3 * 20 / 15;
					if (num4 >= 24 && num4 <= 38 && num5 >= 18 && num5 <= 43)
					{
						val.SetPixel(num4, num5, Color.white);
						val.SetPixel(num4 + 1, num5, Color.white);
					}
				}
			}
			else
			{
				for (int num6 = -1; num6 <= 1; num6++)
				{
					for (int num7 = -1; num7 <= 1; num7++)
					{
						val.SetPixel(28 + num7, 29 + num6, Color.white);
					}
				}
			}
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f);
		}
	}
	public class PulseTrailRenderer : MonoBehaviour
	{
		private const int MaxFireExits = 4;

		private LineRenderer mainLineRenderer;

		private Material iconMaterial;

		private Material fireExitIconMaterial;

		private GameObject mainBeacon;

		private SpriteRenderer mainBeaconSpriteRenderer;

		private Light mainLight;

		private readonly List<LineRenderer> fireExitLines = new List<LineRenderer>();

		private readonly List<GameObject> fireExitBeacons = new List<GameObject>();

		private readonly List<SpriteRenderer> fireExitRenderers = new List<SpriteRenderer>();

		private readonly List<Light> fireExitLights = new List<Light>();

		private readonly List<Vector3> mainWaypoints = new List<Vector3>(128);

		private readonly List<List<Vector3>> fireExitWaypointsList = new List<List<Vector3>>();

		private GameObject toastPanelObj;

		private CanvasGroup toastCanvasGroup;

		private TextMeshProUGUI toastHeaderText;

		private TextMeshProUGUI toastBodyText;

		private float toastTimer;

		private readonly float toastDuration = 3.2f;

		private float pulseStartTime;

		private bool isPulsing;

		private float lastTriggerTime = -1f;

		private Vector3 currentMainBasePos = Vector3.zero;

		private readonly List<Vector3> currentFireBasePositions = new List<Vector3>();

		private static readonly Color DarkRedColor = new Color(0.72f, 0.05f, 0.08f, 0.95f);

		private static readonly Color DarkRedGlow = new Color(0.95f, 0.15f, 0.18f, 1f);

		public static PulseTrailRenderer Instance { get; private set; }

		public bool IsPulsing => isPulsing;

		public static PulseTrailRenderer GetOrCreate()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Instance != (Object)null)
			{
				return Instance;
			}
			GameObject val = new GameObject("GuidedCompany_PulseTrailRenderer");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			Instance = val.AddComponent<PulseTrailRenderer>();
			return Instance;
		}

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			SetupComponents();
			ManualLogSource log = Plugin.Log;
			if (log != null)
			{
				log.LogInfo((object)"[EntranceRadar] PulseTrailRenderer (Multi-Door Navigation + Dark Red Fire Exit Branches) initialized.");
			}
		}

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

		private void SetupComponents()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.layer = LayerMask.NameToLayer("Default");
			mainLineRenderer = ((Component)this).gameObject.GetComponent<LineRenderer>() ?? ((Component)this).gameObject.AddComponent<LineRenderer>();
			ConfigureLineRenderer(mainLineRenderer, Configuration.TrailColor, isFireExit: false);
			CreateMainBeacon();
			for (int i = 0; i < 4; i++)
			{
				CreateFireExitBranch(i);
			}
		}

		private void ConfigureLineRenderer(LineRenderer lr, Color baseCol, bool isFireExit)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_0135: 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_0133: Expected O, but got Unknown
			lr.useWorldSpace = true;
			lr.numCornerVertices = 6;
			lr.numCapVertices = 6;
			lr.alignment = (LineAlignment)0;
			lr.textureMode = (LineTextureMode)0;
			((Renderer)lr).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)lr).receiveShadows = false;
			lr.widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
			{
				new Keyframe(0f, 0.08f),
				new Keyframe(0.15f, isFireExit ? 0.2f : 0.25f),
				new Keyframe(0.5f, isFireExit ? 0.24f : 0.28f),
				new Keyframe(0.85f, isFireExit ? 0.18f : 0.22f),
				new Keyframe(1f, 0.1f)
			});
			lr.widthMultiplier = ((Configuration.TrailWidth != null) ? Configuration.TrailWidth.Value : 0.24f);
			Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Unlit/Transparent");
			if ((Object)(object)val != (Object)null)
			{
				((Renderer)lr).material = new Material(val)
				{
					renderQueue = 3100
				};
			}
			lr.colorGradient = BuildGradient(baseCol, 1f, isFireExit);
			((Renderer)lr).enabled = false;
		}

		private Gradient BuildGradient(Color baseCol, float alpha, bool isFireExit)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003a: 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_0049: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			Gradient val = new Gradient();
			if (isFireExit)
			{
				val.SetKeys((GradientColorKey[])(object)new GradientColorKey[4]
				{
					new GradientColorKey(new Color(1f, 0.35f, 0.35f), 0f),
					new GradientColorKey(DarkRedGlow, 0.25f),
					new GradientColorKey(DarkRedColor, 0.65f),
					new GradientColorKey(new Color(0.55f, 0.02f, 0.05f), 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[5]
				{
					new GradientAlphaKey(0f, 0f),
					new GradientAlphaKey(0.7f * alpha, 0.2f),
					new GradientAlphaKey(0.9f * alpha, 0.5f),
					new GradientAlphaKey(0.7f * alpha, 0.8f),
					new GradientAlphaKey(0f, 1f)
				});
			}
			else
			{
				val.SetKeys((GradientColorKey[])(object)new GradientColorKey[4]
				{
					new GradientColorKey(new Color(1f, 0.85f, 0.5f), 0f),
					new GradientColorKey(baseCol, 0.35f),
					new GradientColorKey(new Color(1f, 0.35f, 0f), 0.75f),
					new GradientColorKey(baseCol, 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[5]
				{
					new GradientAlphaKey(0f, 0f),
					new GradientAlphaKey(0.55f * alpha, 0.2f),
					new GradientAlphaKey(0.75f * alpha, 0.5f),
					new GradientAlphaKey(0.55f * alpha, 0.8f),
					new GradientAlphaKey(0f, 1f)
				});
			}
			return val;
		}

		private static Material CreateBeaconMaterial()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent");
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return new Material(val)
			{
				renderQueue = 3150
			};
		}

		private void CreateMainBeacon()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0092: 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_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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)mainBeacon != (Object)null))
			{
				mainBeacon = new GameObject("GuidedCompany_MainBeacon");
				Object.DontDestroyOnLoad((Object)(object)mainBeacon);
				((Object)mainBeacon).hideFlags = (HideFlags)61;
				mainBeaconSpriteRenderer = mainBeacon.AddComponent<SpriteRenderer>();
				mainBeaconSpriteRenderer.sprite = EntranceManager.GetEntranceIconSprite();
				((Renderer)mainBeaconSpriteRenderer).sortingOrder = 3000;
				iconMaterial = CreateBeaconMaterial();
				if ((Object)(object)iconMaterial != (Object)null)
				{
					((Renderer)mainBeaconSpriteRenderer).material = iconMaterial;
				}
				Color trailColor = Configuration.TrailColor;
				mainBeaconSpriteRenderer.color = new Color(trailColor.r, trailColor.g, trailColor.b, 0.95f);
				mainBeacon.transform.localScale = Vector3.one * 1.5f;
				mainLight = mainBeacon.AddComponent<Light>();
				mainLight.type = (LightType)2;
				mainLight.range = 8f;
				mainLight.intensity = 1.8f;
				mainLight.color = new Color(1f, 0.55f, 0.1f);
				mainLight.shadows = (LightShadows)0;
				mainBeacon.SetActive(false);
			}
		}

		private void CreateFireExitBranch(int index)
		{
			//IL_0010: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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)
			GameObject val = new GameObject($"GuidedCompany_FireExitLine_{index}");
			val.transform.SetParent(((Component)this).transform, false);
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			ConfigureLineRenderer(val2, DarkRedColor, isFireExit: true);
			fireExitLines.Add(val2);
			GameObject val3 = new GameObject($"GuidedCompany_FireExitBeacon_{index}");
			Object.DontDestroyOnLoad((Object)(object)val3);
			((Object)val3).hideFlags = (HideFlags)61;
			SpriteRenderer val4 = val3.AddComponent<SpriteRenderer>();
			val4.sprite = EntranceManager.GetFireExitIconSprite();
			((Renderer)val4).sortingOrder = 3000;
			if ((Object)(object)fireExitIconMaterial == (Object)null)
			{
				fireExitIconMaterial = CreateBeaconMaterial();
			}
			if ((Object)(object)fireExitIconMaterial != (Object)null)
			{
				((Renderer)val4).material = fireExitIconMaterial;
			}
			val4.color = DarkRedColor;
			val3.transform.localScale = Vector3.one * 1.35f;
			Light val5 = val3.AddComponent<Light>();
			val5.type = (LightType)2;
			val5.range = 6.5f;
			val5.intensity = 1.6f;
			val5.color = new Color(0.85f, 0.08f, 0.12f);
			val5.shadows = (LightShadows)0;
			val3.SetActive(false);
			fireExitBeacons.Add(val3);
			fireExitRenderers.Add(val4);
			fireExitLights.Add(val5);
		}

		public void TriggerPulse()
		{
			//IL_0095: 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_009a: 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_0108: 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_0112: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: 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)
			if (!Configuration.EnableEntranceRadar.Value)
			{
				return;
			}
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val == (Object)null || val.isPlayerDead)
			{
				return;
			}
			if (val.isInsideFactory)
			{
				StopPulse();
			}
			else
			{
				if (Time.time - lastTriggerTime < 0.35f)
				{
					return;
				}
				lastTriggerTime = Time.time;
				if (!EntranceManager.GetDoors(out var mainDoor, out var fireExits))
				{
					return;
				}
				Vector3 val2 = (((Object)(object)val.thisPlayerBody != (Object)null) ? val.thisPlayerBody.position : ((Component)val).transform.position);
				mainWaypoints.Clear();
				bool flag = mainDoor != null && TryCalculateSafePath(val2, mainDoor.NavPosition, mainDoor.WorldPosition, mainWaypoints);
				fireExitWaypointsList.Clear();
				currentFireBasePositions.Clear();
				int num = 0;
				float num2 = float.MaxValue;
				for (int i = 0; i < fireExits.Count; i++)
				{
					if (num >= 4)
					{
						break;
					}
					DoorInfo doorInfo = fireExits[i];
					if (doorInfo == null)
					{
						continue;
					}
					List<Vector3> list = new List<Vector3>(64);
					if (!TryCalculateSafePath(val2, doorInfo.NavPosition, doorInfo.WorldPosition, list))
					{
						continue;
					}
					float num3 = Vector3.Distance(val2, doorInfo.WorldPosition);
					if (num3 < num2)
					{
						num2 = num3;
					}
					List<Vector3> list2 = SliceBranchPath(mainWaypoints, list);
					if (list2 != null && list2.Count >= 2)
					{
						while (num >= fireExitLines.Count)
						{
							CreateFireExitBranch(fireExitLines.Count);
						}
						LineRenderer obj = fireExitLines[num];
						obj.positionCount = list2.Count;
						obj.SetPositions(list2.ToArray());
						((Renderer)obj).enabled = true;
						GameObject obj2 = fireExitBeacons[num];
						Vector3 val3 = doorInfo.WorldPosition + Vector3.up * 1.8f;
						obj2.transform.position = val3;
						obj2.SetActive(true);
						currentFireBasePositions.Add(val3);
						fireExitWaypointsList.Add(list2);
						num++;
					}
				}
				for (int j = num; j < fireExitLines.Count; j++)
				{
					if ((Object)(object)fireExitLines[j] != (Object)null)
					{
						((Renderer)fireExitLines[j]).enabled = false;
					}
					if ((Object)(object)fireExitBeacons[j] != (Object)null)
					{
						fireExitBeacons[j].SetActive(false);
					}
				}
				if (!flag && num == 0)
				{
					StopPulse();
					return;
				}
				if (flag && mainWaypoints.Count >= 2)
				{
					mainLineRenderer.positionCount = mainWaypoints.Count;
					mainLineRenderer.SetPositions(mainWaypoints.ToArray());
					((Renderer)mainLineRenderer).enabled = true;
					currentMainBasePos = mainDoor.WorldPosition + Vector3.up * 1.8f;
					if ((Object)(object)mainBeacon != (Object)null)
					{
						mainBeacon.transform.position = currentMainBasePos;
						mainBeacon.SetActive(true);
					}
				}
				else
				{
					((Renderer)mainLineRenderer).enabled = false;
					if ((Object)(object)mainBeacon != (Object)null)
					{
						mainBeacon.SetActive(false);
					}
				}
				pulseStartTime = Time.time;
				isPulsing = true;
				float num4 = ((mainDoor != null) ? Vector3.Distance(val2, mainDoor.WorldPosition) : (-1f));
				ShowBottomRightToast(num4, (num > 0) ? num2 : (-1f), num);
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogInfo((object)$"[EntranceRadar] Safe Radar Pulse Active (Outside) | Main Door: {flag} ({num4:F0}m) | Reachable Fire Exits: {num}");
				}
			}
		}

		public void StopPulse()
		{
			isPulsing = false;
			if ((Object)(object)mainLineRenderer != (Object)null)
			{
				((Renderer)mainLineRenderer).enabled = false;
			}
			if ((Object)(object)mainBeacon != (Object)null)
			{
				mainBeacon.SetActive(false);
			}
			for (int i = 0; i < fireExitLines.Count; i++)
			{
				if ((Object)(object)fireExitLines[i] != (Object)null)
				{
					((Renderer)fireExitLines[i]).enabled = false;
				}
				if ((Object)(object)fireExitBeacons[i] != (Object)null)
				{
					fireExitBeacons[i].SetActive(false);
				}
			}
			HideBottomRightToast();
		}

		private static bool TryCalculateSafePath(Vector3 startPos, Vector3 targetNav, Vector3 finalDoor, List<Vector3> outWaypoints)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00a5: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: 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)
			outWaypoints.Clear();
			NavMeshHit val = default(NavMeshHit);
			if (!NavMesh.SamplePosition(startPos, ref val, 5f, -1))
			{
				return false;
			}
			NavMeshPath val2 = new NavMeshPath();
			if (!NavMesh.CalculatePath(((NavMeshHit)(ref val)).position, targetNav, -1, val2) || (int)val2.status != 0 || val2.corners == null || val2.corners.Length < 2)
			{
				return false;
			}
			float num = ((Configuration.HeightOffset != null) ? Configuration.HeightOffset.Value : 0.25f);
			outWaypoints.Add(startPos + Vector3.up * 0.28f);
			NavMeshHit val6 = default(NavMeshHit);
			for (int i = 0; i < val2.corners.Length - 1; i++)
			{
				Vector3 val3 = val2.corners[i];
				Vector3 val4 = val2.corners[i + 1];
				float num2 = Vector3.Distance(val3, val4);
				int num3 = Mathf.Max(1, Mathf.CeilToInt(num2 / 1.5f));
				for (int j = 1; j <= num3; j++)
				{
					Vector3 val5 = Vector3.Lerp(val3, val4, (float)j / (float)num3);
					if (NavMesh.SamplePosition(val5, ref val6, 1.2f, -1))
					{
						val5 = ((NavMeshHit)(ref val6)).position;
					}
					if (outWaypoints.Count > 0 && Mathf.Abs(val5.y - outWaypoints[outWaypoints.Count - 1].y) > 2f)
					{
						val5.y = outWaypoints[outWaypoints.Count - 1].y;
					}
					outWaypoints.Add(val5 + Vector3.up * num);
				}
			}
			outWaypoints.Add(finalDoor + Vector3.up * num);
			return outWaypoints.Count >= 2;
		}

		private static List<Vector3> SliceBranchPath(List<Vector3> mainPath, List<Vector3> fePath)
		{
			//IL_003b: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (fePath == null || fePath.Count < 2)
			{
				return null;
			}
			if (mainPath == null || mainPath.Count < 2)
			{
				return fePath;
			}
			int num = 0;
			int num2 = Mathf.Min(mainPath.Count, fePath.Count);
			for (int i = 0; i < num2; i++)
			{
				num = i;
				if (Vector3.Distance(mainPath[i], fePath[i]) > 2f)
				{
					break;
				}
			}
			int num3 = Mathf.Max(0, num - 1);
			List<Vector3> list = new List<Vector3>(fePath.Count - num3 + 1);
			if (num3 < mainPath.Count)
			{
				list.Add(mainPath[num3]);
			}
			for (int j = num3; j < fePath.Count; j++)
			{
				list.Add(fePath[j]);
			}
			if (list.Count < 2)
			{
				return fePath;
			}
			return list;
		}

		public void Tick(PlayerControllerB localPlayer)
		{
			UpdateToastTimer();
			if (isPulsing)
			{
				UpdatePulseVisuals(localPlayer);
			}
		}

		private void UpdatePulseVisuals(PlayerControllerB localPlayer)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			if (!isPulsing)
			{
				return;
			}
			if ((Object)(object)localPlayer == (Object)null || localPlayer.isPlayerDead || localPlayer.isInsideFactory)
			{
				StopPulse();
				return;
			}
			float num = ((Configuration.PulseDuration != null) ? Configuration.PulseDuration.Value : 2.5f);
			float num2 = Time.time - pulseStartTime;
			if (num2 >= num)
			{
				StopPulse();
				return;
			}
			Vector3 val = (((Object)(object)localPlayer.thisPlayerBody != (Object)null) ? localPlayer.thisPlayerBody.position : ((Component)localPlayer).transform.position);
			if ((Object)(object)mainLineRenderer != (Object)null && ((Renderer)mainLineRenderer).enabled && mainLineRenderer.positionCount > 0 && mainWaypoints.Count > 0)
			{
				mainLineRenderer.SetPosition(0, val + Vector3.up * 0.28f);
			}
			Camera cam = (((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.activeCamera != (Object)null) ? StartOfRound.Instance.activeCamera : localPlayer.gameplayCamera);
			UpdateBeaconTransform(mainBeacon, currentMainBasePos, cam, 0f);
			for (int i = 0; i < currentFireBasePositions.Count && i < fireExitBeacons.Count; i++)
			{
				UpdateBeaconTransform(fireExitBeacons[i], currentFireBasePositions[i], cam, (float)i * 0.5f);
			}
			float num3 = Mathf.Clamp01(num2 / 0.25f);
			float num4 = ((num2 < 2f) ? 1f : Mathf.Clamp01(1f - (num2 - 2f) / Mathf.Max(0.5f, num - 2f)));
			SetAlpha(num3 * num4);
		}

		private static void UpdateBeaconTransform(GameObject beacon, Vector3 basePos, Camera cam, float phaseOffset)
		{
			//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_0038: 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_0056: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)beacon == (Object)null || !beacon.activeSelf)
			{
				return;
			}
			float num = Mathf.Sin(Time.time * 2.4f + phaseOffset) * 0.07f;
			beacon.transform.position = basePos + Vector3.up * num;
			if ((Object)(object)cam != (Object)null)
			{
				Vector3 val = beacon.transform.position - ((Component)cam).transform.position;
				if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
				{
					beacon.transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up);
				}
			}
		}

		private void SetAlpha(float alpha)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			Color trailColor = Configuration.TrailColor;
			if ((Object)(object)mainLineRenderer != (Object)null && ((Renderer)mainLineRenderer).enabled)
			{
				mainLineRenderer.colorGradient = BuildGradient(trailColor, alpha, isFireExit: false);
			}
			if ((Object)(object)mainBeaconSpriteRenderer != (Object)null)
			{
				mainBeaconSpriteRenderer.color = new Color(trailColor.r, trailColor.g, trailColor.b, 0.95f * alpha);
			}
			if ((Object)(object)mainLight != (Object)null)
			{
				mainLight.intensity = 1.8f * alpha;
			}
			for (int i = 0; i < fireExitLines.Count; i++)
			{
				if ((Object)(object)fireExitLines[i] != (Object)null && ((Renderer)fireExitLines[i]).enabled)
				{
					fireExitLines[i].colorGradient = BuildGradient(DarkRedColor, alpha, isFireExit: true);
				}
				if (i < fireExitRenderers.Count && (Object)(object)fireExitRenderers[i] != (Object)null)
				{
					fireExitRenderers[i].color = new Color(DarkRedColor.r, DarkRedColor.g, DarkRedColor.b, 0.95f * alpha);
				}
				if (i < fireExitLights.Count && (Object)(object)fireExitLights[i] != (Object)null)
				{
					fireExitLights[i].intensity = 1.6f * alpha;
				}
			}
		}

		private void EnsureToastUI()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_00a3: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_01bb: 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_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)toastPanelObj != (Object)null || (Object)(object)HUDManager.Instance == (Object)null)
			{
				return;
			}
			Transform val = (((Object)(object)HUDManager.Instance.HUDContainer != (Object)null) ? HUDManager.Instance.HUDContainer.transform : null);
			if ((Object)(object)val == (Object)null)
			{
				Canvas val2 = Object.FindObjectOfType<Canvas>();
				if ((Object)(object)val2 != (Object)null)
				{
					val = ((Component)val2).transform;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			try
			{
				toastPanelObj = new GameObject("GuidedCompany_BottomRightToast");
				toastPanelObj.transform.SetParent(val, false);
				RectTransform obj = toastPanelObj.AddComponent<RectTransform>();
				obj.anchorMin = new Vector2(1f, 0f);
				obj.anchorMax = new Vector2(1f, 0f);
				obj.pivot = new Vector2(1f, 0f);
				obj.anchoredPosition = new Vector2(-14f, 14f);
				obj.sizeDelta = new Vector2(185f, 38f);
				((Graphic)toastPanelObj.AddComponent<Image>()).color = new Color(0.02f, 0.03f, 0.04f, 0.78f);
				toastCanvasGroup = toastPanelObj.AddComponent<CanvasGroup>();
				toastCanvasGroup.alpha = 0f;
				GameObject val3 = new GameObject("ToastHeader");
				val3.transform.SetParent(toastPanelObj.transform, false);
				RectTransform obj2 = val3.AddComponent<RectTransform>();
				obj2.anchorMin = new Vector2(0f, 0.5f);
				obj2.anchorMax = new Vector2(1f, 1f);
				obj2.offsetMin = new Vector2(8f, 0f);
				obj2.offsetMax = new Vector2(-8f, -2f);
				toastHeaderText = val3.AddComponent<TextMeshProUGUI>();
				((TMP_Text)toastHeaderText).text = "[!] RADAR EXITS";
				((TMP_Text)toastHeaderText).fontSize = 10f;
				((TMP_Text)toastHeaderText).fontStyle = (FontStyles)1;
				((Graphic)toastHeaderText).color = new Color(1f, 0.55f, 0.1f, 1f);
				((TMP_Text)toastHeaderText).alignment = (TextAlignmentOptions)513;
				GameObject val4 = new GameObject("ToastBody");
				val4.transform.SetParent(toastPanelObj.transform, false);
				RectTransform obj3 = val4.AddComponent<RectTransform>();
				obj3.anchorMin = new Vector2(0f, 0f);
				obj3.anchorMax = new Vector2(1f, 0.5f);
				obj3.offsetMin = new Vector2(8f, 2f);
				obj3.offsetMax = new Vector2(-8f, 0f);
				toastBodyText = val4.AddComponent<TextMeshProUGUI>();
				((TMP_Text)toastBodyText).text = "Tracking...";
				((TMP_Text)toastBodyText).fontSize = 9.5f;
				((Graphic)toastBodyText).color = new Color(0.92f, 0.92f, 0.95f, 0.95f);
				((TMP_Text)toastBodyText).alignment = (TextAlignmentOptions)513;
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[EntranceRadar] Could not create bottom-right toast UI: " + ex.Message));
				}
			}
		}

		private void ShowBottomRightToast(float mainDist, float fireDist, int fireCount)
		{
			EnsureToastUI();
			if ((Object)(object)toastCanvasGroup == (Object)null)
			{
				return;
			}
			if ((Object)(object)toastHeaderText != (Object)null)
			{
				((TMP_Text)toastHeaderText).text = "[!] FACILITY ENTRANCES";
			}
			if ((Object)(object)toastBodyText != (Object)null)
			{
				string text = string.Empty;
				if (mainDist >= 0f)
				{
					text += $"Main: {Mathf.RoundToInt(mainDist)}m";
				}
				if (fireDist >= 0f && fireCount > 0)
				{
					if (text.Length > 0)
					{
						text += " | ";
					}
					text += $"<color=#FF4444>Fire Exit: {Mathf.RoundToInt(fireDist)}m</color>";
				}
				((TMP_Text)toastBodyText).text = (string.IsNullOrEmpty(text) ? "No route found." : text);
			}
			toastTimer = toastDuration;
		}

		private void HideBottomRightToast()
		{
			toastTimer = 0f;
			if ((Object)(object)toastCanvasGroup != (Object)null)
			{
				toastCanvasGroup.alpha = 0f;
			}
		}

		private void UpdateToastTimer()
		{
			if (!((Object)(object)toastCanvasGroup == (Object)null))
			{
				if (toastTimer > 0f)
				{
					toastTimer -= Time.deltaTime;
					toastCanvasGroup.alpha = Mathf.MoveTowards(toastCanvasGroup.alpha, 1f, Time.deltaTime * 6f);
				}
				else
				{
					toastCanvasGroup.alpha = Mathf.MoveTowards(toastCanvasGroup.alpha, 0f, Time.deltaTime * 3f);
				}
			}
		}
	}
}
namespace GuidedCompanyRadar.Patches
{
	[HarmonyPatch]
	public static class HUDScanPatch
	{
		private static float lastScanTime = -1f;

		private static bool loggedHeartbeat;

		private static bool loggedScanHeartbeat;

		[HarmonyPatch(typeof(PlayerControllerB), "Update")]
		[HarmonyPostfix]
		public static void PlayerUpdate_Postfix(PlayerControllerB __instance)
		{
			try
			{
				if (!Configuration.EnableEntranceRadar.Value || (Object)(object)__instance == (Object)null || !((NetworkBehaviour)__instance).IsOwner)
				{
					return;
				}
				if (!loggedHeartbeat && __instance.isPlayerControlled)
				{
					loggedHeartbeat = true;
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogInfo((object)"[EntranceRadar] PlayerControllerB.Update hook verified active on local player!");
					}
				}
				PulseTrailRenderer.GetOrCreate()?.Tick(__instance);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = Plugin.Log;
				if (log2 != null)
				{
					log2.LogWarning((object)("[EntranceRadar] PlayerUpdate_Postfix error: " + ex.Message));
				}
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		public static void HUDUpdate_Postfix(HUDManager __instance)
		{
			try
			{
				if (!Configuration.EnableEntranceRadar.Value || (Object)(object)__instance == (Object)null)
				{
					return;
				}
				PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
				if (((Object)(object)val != (Object)null && val.isInsideFactory) || Traverse.Create((object)__instance).Field("playerPingingScan").GetValue<float>() <= 0.05f || Time.time - lastScanTime <= 0.45f)
				{
					return;
				}
				lastScanTime = Time.time;
				if (!loggedScanHeartbeat)
				{
					loggedScanHeartbeat = true;
					ManualLogSource log = Plugin.Log;
					if (log != null)
					{
						log.LogInfo((object)"[EntranceRadar] Diagnostic Heartbeat: HUDManager scan ping trigger active and verified.");
					}
				}
				PulseTrailRenderer.GetOrCreate()?.TriggerPulse();
			}
			catch
			{
			}
		}

		[HarmonyPatch(typeof(HUDManager), "NodeIsNotVisible")]
		[HarmonyPrefix]
		public static bool NodeIsNotVisible_Prefix(ScanNodeProperties node, ref bool __result)
		{
			if (!Configuration.EnableEntranceRadar.Value)
			{
				return true;
			}
			PlayerControllerB val = (((Object)(object)GameNetworkManager.Instance != (Object)null) ? GameNetworkManager.Instance.localPlayerController : null);
			if ((Object)(object)val != (Object)null && val.isInsideFactory)
			{
				return true;
			}
			if ((Object)(object)node != (Object)null && (Object)(object)node == (Object)(object)EntranceManager.ActiveScanNode && (Object)(object)PulseTrailRenderer.Instance != (Object)null && PulseTrailRenderer.Instance.IsPulsing)
			{
				__result = false;
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "AssignNewNodes")]
		[HarmonyPostfix]
		public static void AssignNewNodes_Postfix(HUDManager __instance, PlayerControllerB playerScript)
		{
			try
			{
				if (Configuration.EnableEntranceRadar.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)playerScript == (Object)null) && !playerScript.isInsideFactory && !((Object)(object)PulseTrailRenderer.Instance == (Object)null) && PulseTrailRenderer.Instance.IsPulsing && !((Object)(object)EntranceManager.ActiveScanNode == (Object)null))
				{
					List<ScanNodeProperties> value = Traverse.Create((object)__instance).Field("nodesOnScreen").GetValue<List<ScanNodeProperties>>();
					if (value != null && !value.Contains(EntranceManager.ActiveScanNode))
					{
						value.Add(EntranceManager.ActiveScanNode);
					}
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch]
	public static class RoundLifecyclePatch
	{
		[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
		[HarmonyPostfix]
		public static void ShipLeave_Postfix()
		{
			ClearRadarState();
		}

		[HarmonyPatch(typeof(StartOfRound), "StartGame")]
		[HarmonyPostfix]
		public static void StartGame_Postfix()
		{
			ClearRadarState();
		}

		[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
		[HarmonyPostfix]
		public static void OpeningDoors_Postfix()
		{
			try
			{
				if (Configuration.EnableEntranceRadar.Value)
				{
					EntranceManager.RefreshEntrances();
				}
			}
			catch
			{
			}
		}

		private static void ClearRadarState()
		{
			try
			{
				if (Configuration.EnableEntranceRadar.Value)
				{
					EntranceManager.Clear();
					PulseTrailRenderer.Instance?.StopPulse();
				}
			}
			catch
			{
			}
		}
	}
}