Decompiled source of SharedWaypoints v1.0.1

SharedWaypoints.dll

Decompiled 4 hours 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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
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("SharedWaypoints")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("SharedWaypoints")]
[assembly: AssemblyTitle("SharedWaypoints")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SharedWaypoints
{
	internal static class InputUtil
	{
		private static readonly Dictionary<KeyCode, Key> KeyMap = new Dictionary<KeyCode, Key>
		{
			{
				(KeyCode)97,
				(Key)15
			},
			{
				(KeyCode)98,
				(Key)16
			},
			{
				(KeyCode)99,
				(Key)17
			},
			{
				(KeyCode)100,
				(Key)18
			},
			{
				(KeyCode)101,
				(Key)19
			},
			{
				(KeyCode)102,
				(Key)20
			},
			{
				(KeyCode)103,
				(Key)21
			},
			{
				(KeyCode)104,
				(Key)22
			},
			{
				(KeyCode)105,
				(Key)23
			},
			{
				(KeyCode)106,
				(Key)24
			},
			{
				(KeyCode)107,
				(Key)25
			},
			{
				(KeyCode)108,
				(Key)26
			},
			{
				(KeyCode)109,
				(Key)27
			},
			{
				(KeyCode)110,
				(Key)28
			},
			{
				(KeyCode)111,
				(Key)29
			},
			{
				(KeyCode)112,
				(Key)30
			},
			{
				(KeyCode)113,
				(Key)31
			},
			{
				(KeyCode)114,
				(Key)32
			},
			{
				(KeyCode)115,
				(Key)33
			},
			{
				(KeyCode)116,
				(Key)34
			},
			{
				(KeyCode)117,
				(Key)35
			},
			{
				(KeyCode)118,
				(Key)36
			},
			{
				(KeyCode)119,
				(Key)37
			},
			{
				(KeyCode)120,
				(Key)38
			},
			{
				(KeyCode)121,
				(Key)39
			},
			{
				(KeyCode)122,
				(Key)40
			},
			{
				(KeyCode)48,
				(Key)50
			},
			{
				(KeyCode)49,
				(Key)41
			},
			{
				(KeyCode)50,
				(Key)42
			},
			{
				(KeyCode)51,
				(Key)43
			},
			{
				(KeyCode)52,
				(Key)44
			},
			{
				(KeyCode)53,
				(Key)45
			},
			{
				(KeyCode)54,
				(Key)46
			},
			{
				(KeyCode)55,
				(Key)47
			},
			{
				(KeyCode)56,
				(Key)48
			},
			{
				(KeyCode)57,
				(Key)49
			},
			{
				(KeyCode)32,
				(Key)1
			},
			{
				(KeyCode)304,
				(Key)51
			},
			{
				(KeyCode)303,
				(Key)52
			},
			{
				(KeyCode)306,
				(Key)55
			},
			{
				(KeyCode)305,
				(Key)56
			},
			{
				(KeyCode)308,
				(Key)53
			},
			{
				(KeyCode)307,
				(Key)54
			},
			{
				(KeyCode)9,
				(Key)3
			},
			{
				(KeyCode)301,
				(Key)72
			},
			{
				(KeyCode)8,
				(Key)65
			},
			{
				(KeyCode)13,
				(Key)2
			},
			{
				(KeyCode)27,
				(Key)60
			},
			{
				(KeyCode)273,
				(Key)63
			},
			{
				(KeyCode)274,
				(Key)64
			},
			{
				(KeyCode)276,
				(Key)61
			},
			{
				(KeyCode)275,
				(Key)62
			},
			{
				(KeyCode)277,
				(Key)70
			},
			{
				(KeyCode)127,
				(Key)71
			},
			{
				(KeyCode)278,
				(Key)68
			},
			{
				(KeyCode)279,
				(Key)69
			},
			{
				(KeyCode)280,
				(Key)67
			},
			{
				(KeyCode)281,
				(Key)66
			},
			{
				(KeyCode)282,
				(Key)94
			},
			{
				(KeyCode)283,
				(Key)95
			},
			{
				(KeyCode)284,
				(Key)96
			},
			{
				(KeyCode)285,
				(Key)97
			},
			{
				(KeyCode)286,
				(Key)98
			},
			{
				(KeyCode)287,
				(Key)99
			},
			{
				(KeyCode)288,
				(Key)100
			},
			{
				(KeyCode)289,
				(Key)101
			},
			{
				(KeyCode)290,
				(Key)102
			},
			{
				(KeyCode)291,
				(Key)103
			},
			{
				(KeyCode)292,
				(Key)104
			},
			{
				(KeyCode)293,
				(Key)105
			}
		};

		private static readonly Dictionary<KeyCode, bool> WasDown = new Dictionary<KeyCode, bool>();

		private static readonly Dictionary<KeyCode, int> EdgeFrame = new Dictionary<KeyCode, int>();

		private static readonly Dictionary<KeyCode, bool> EdgeResult = new Dictionary<KeyCode, bool>();

		public static bool WasPressedThisFrame(KeyCode keyCode)
		{
			//IL_000b: 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_00b5: 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_001e: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00eb: 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_006d: 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)
			int frameCount = Time.frameCount;
			bool value2;
			if (EdgeFrame.TryGetValue(keyCode, out var value) && value == frameCount)
			{
				return EdgeResult.TryGetValue(keyCode, out value2) && value2;
			}
			EdgeFrame[keyCode] = frameCount;
			try
			{
				Keyboard current = Keyboard.current;
				if (current != null && KeyMap.TryGetValue(keyCode, out var value3))
				{
					KeyControl val = current[value3];
					if (val != null && ((ButtonControl)val).wasPressedThisFrame)
					{
						EdgeResult[keyCode] = true;
						WasDown[keyCode] = true;
						return true;
					}
				}
			}
			catch
			{
			}
			try
			{
				if (Input.GetKeyDown(keyCode))
				{
					EdgeResult[keyCode] = true;
					WasDown[keyCode] = true;
					return true;
				}
			}
			catch
			{
			}
			bool flag = IsDown(keyCode);
			bool value4;
			bool flag2 = WasDown.TryGetValue(keyCode, out value4) && value4;
			bool flag3 = flag && !flag2;
			EdgeResult[keyCode] = flag3;
			WasDown[keyCode] = flag;
			return flag3;
		}

		public static bool IsDown(KeyCode keyCode)
		{
			//IL_000e: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Keyboard current = Keyboard.current;
				if (current != null && KeyMap.TryGetValue(keyCode, out var value))
				{
					KeyControl val = current[value];
					if (val != null && ((ButtonControl)val).isPressed)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			try
			{
				if (Input.GetKey(keyCode))
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}

		public unsafe static string TipLabel(KeyCode keyCode)
		{
			//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_0005: Invalid comparison between Unknown and I4
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000c: 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_0030: Expected I4, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_0066: 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)
			KeyCode val = keyCode;
			if ((int)val != 13)
			{
				if ((int)val != 27)
				{
					switch (val - 303)
					{
					case 0:
					case 1:
						return "Shift";
					case 2:
					case 3:
						return "Ctrl";
					case 4:
					case 5:
						return "Alt";
					default:
						if ((int)keyCode >= 48 && (int)keyCode <= 57)
						{
							return ((char)(48 + (keyCode - 48))).ToString();
						}
						return ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString();
					}
				}
				return "Esc";
			}
			return "Enter";
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "Start")]
	internal static class StartOfRoundStartPatch
	{
		private static void Postfix(StartOfRound __instance)
		{
			WaypointHud.EnsureExists();
			if ((Object)(object)__instance != (Object)null && __instance.inShipPhase)
			{
				WaypointRegistry.ClearAll();
			}
			Plugin.Log.LogInfo((object)"SharedWaypoints HUD ensured after StartOfRound.Start.");
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Start")]
	internal static class HudManagerStartPatch
	{
		private static void Postfix()
		{
			WaypointHud.EnsureExists();
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
	internal static class ShipLeavePatch
	{
		private static void Prefix()
		{
			WaypointRegistry.ClearAll();
			Plugin.Log.LogInfo((object)"Cleared waypoints on ShipLeave.");
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "Disconnect")]
	internal static class DisconnectPatch
	{
		private static void Prefix()
		{
			WaypointRegistry.ClearAll();
			Plugin.Log.LogInfo((object)"Cleared waypoints on disconnect.");
		}
	}
	[BepInPlugin("com.benhough.lethal.SharedWaypoints", "SharedWaypoints", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModGuid = "com.benhough.lethal.SharedWaypoints";

		public const string ModName = "SharedWaypoints";

		public const string ModVersion = "1.0.1";

		internal static Plugin Instance { get; private set; }

		internal static ManualLogSource Log { get; private set; }

		internal static ConfigEntry<bool> Enabled { get; private set; }

		internal static ConfigEntry<KeyCode> DropKey { get; private set; }

		internal static ConfigEntry<KeyCode> ClearKey { get; private set; }

		internal static ConfigEntry<float> MaxDistance { get; private set; }

		internal static ConfigEntry<bool> ShowOwnWaypoint { get; private set; }

		internal static ConfigEntry<float> HudScale { get; private set; }

		private void Awake()
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable shared waypoints.");
			DropKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DropKey", (KeyCode)289, "Place or replace your waypoint at your current position.");
			ClearKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ClearKey", (KeyCode)288, "Remove your waypoint for everyone.");
			MaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxDistance", 500f, "Hide waypoint markers beyond this distance (meters).");
			ShowOwnWaypoint = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowOwnWaypoint", true, "Show your own waypoint on the HUD.");
			HudScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HudScale", 1f, "Scale of the fixed waypoint HUD panel.");
			try
			{
				new Harmony("com.benhough.lethal.SharedWaypoints").PatchAll(typeof(Plugin).Assembly);
				WaypointHud.EnsureExists();
				Log.LogInfo((object)string.Format("{0} v{1} loaded. Drop={2} Clear={3}.", "SharedWaypoints", "1.0.1", DropKey.Value, ClearKey.Value));
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to start: {arg}");
			}
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.benhough.lethal.SharedWaypoints";

		public const string PLUGIN_NAME = "SharedWaypoints";

		public const string PLUGIN_VERSION = "1.0.1";
	}
	internal sealed class WaypointHud : MonoBehaviour
	{
		private static WaypointHud? _instance;

		private Canvas? _canvas;

		private RectTransform? _panelRt;

		private Image? _backdrop;

		private TextMeshProUGUI? _label;

		private Text? _fallback;

		private bool _fontAssigned;

		private TMP_FontAsset? _tmpFont;

		private bool _wasInShipPhase;

		private float _nextRefresh;

		private string _cachedText = "";

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

		internal static void EnsureExists()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if (!((Object)(object)_instance != (Object)null))
			{
				GameObject val = new GameObject("SharedWaypointsHUD");
				Object.DontDestroyOnLoad((Object)val);
				_instance = val.AddComponent<WaypointHud>();
			}
		}

		private void Awake()
		{
			_instance = this;
			BuildUi();
		}

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

		private void BuildUi()
		{
			//IL_02aa: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00ba: 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_00ee: 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_0122: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_canvas != (Object)null)
			{
				return;
			}
			_canvas = ((Component)this).gameObject.AddComponent<Canvas>();
			_canvas.renderMode = (RenderMode)0;
			_canvas.sortingOrder = 5000;
			CanvasScaler obj = ((Component)this).gameObject.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)1;
			obj.referenceResolution = new Vector2(1920f, 1080f);
			((Component)this).gameObject.AddComponent<GraphicRaycaster>();
			GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(((Component)this).transform, false);
			_panelRt = val.GetComponent<RectTransform>();
			_panelRt.anchorMin = new Vector2(1f, 1f);
			_panelRt.anchorMax = new Vector2(1f, 1f);
			_panelRt.pivot = new Vector2(1f, 1f);
			_panelRt.sizeDelta = new Vector2(340f, 160f);
			_panelRt.anchoredPosition = new Vector2(-24f, -96f);
			_backdrop = val.AddComponent<Image>();
			((Graphic)_backdrop).color = PanelBg;
			((Graphic)_backdrop).raycastTarget = false;
			GameObject val2 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
			val2.transform.SetParent(val.transform, false);
			RectTransform component = val2.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(12f, 8f);
			component.offsetMax = new Vector2(-12f, -8f);
			try
			{
				_label = val2.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_label).alignment = (TextAlignmentOptions)257;
				((TMP_Text)_label).fontStyle = (FontStyles)0;
				((TMP_Text)_label).enableWordWrapping = true;
				((Graphic)_label).raycastTarget = false;
				((TMP_Text)_label).overflowMode = (TextOverflowModes)0;
				((TMP_Text)_label).fontSize = 20f;
				((TMP_Text)_label).lineSpacing = 2f;
				((Graphic)_label).color = Color.white;
				((TMP_Text)_label).text = "";
			}
			catch
			{
				_fallback = val2.AddComponent<Text>();
				_fallback.alignment = (TextAnchor)0;
				((Graphic)_fallback).raycastTarget = false;
				_fallback.fontSize = 16;
				_fallback.horizontalOverflow = (HorizontalWrapMode)0;
				_fallback.verticalOverflow = (VerticalWrapMode)1;
				((Graphic)_fallback).color = Color.white;
				Font builtinResource = Resources.GetBuiltinResource<Font>("Arial.ttf");
				if (builtinResource != null)
				{
					_fallback.font = builtinResource;
				}
				_fallback.text = "";
			}
			SetPanelVisible(visible: false);
			Plugin.Log.LogInfo((object)"SharedWaypoints fixed HUD panel built (top-right).");
		}

		private void Update()
		{
			WaypointNet.EnsureRegistered();
			HandleInput();
			MaybeClearOnShipPhase();
		}

		private void LateUpdate()
		{
			if ((Object)(object)_canvas == (Object)null)
			{
				BuildUi();
			}
			TryAssignFont();
			if (!(Time.unscaledTime < _nextRefresh))
			{
				_nextRefresh = Time.unscaledTime + 0.1f;
				RefreshPanel();
			}
		}

		private void MaybeClearOnShipPhase()
		{
			StartOfRound instance = StartOfRound.Instance;
			bool flag = (Object)(object)instance != (Object)null && instance.inShipPhase;
			if (flag && !_wasInShipPhase)
			{
				WaypointRegistry.ClearAll();
				Plugin.Log.LogInfo((object)"Cleared waypoints entering ship phase.");
			}
			_wasInShipPhase = flag;
		}

		private void HandleInput()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.Enabled == null || !Plugin.Enabled.Value)
			{
				return;
			}
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if (!((Object)(object)val == (Object)null) && !val.isPlayerDead && !val.isTypingChat && !val.inTerminalMenu)
			{
				if (InputUtil.WasPressedThisFrame(Plugin.DropKey.Value))
				{
					DropWaypoint(val);
				}
				if (InputUtil.WasPressedThisFrame(Plugin.ClearKey.Value))
				{
					ClearWaypoint(val);
				}
			}
		}

		private static void DropWaypoint(PlayerControllerB player)
		{
			//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_00c1: Unknown result type (might be due to invalid IL or missing references)
			WaypointState waypointState = new WaypointState
			{
				OwnerPlayerClientId = player.playerClientId,
				OwnerName = (string.IsNullOrEmpty(player.playerUsername) ? "Player" : player.playerUsername),
				Position = ((Component)player).transform.position,
				IsInside = player.isInsideFactory,
				ColorIndex = WaypointState.ColorIndexFor(player.playerClientId)
			};
			WaypointRegistry.Set(waypointState);
			WaypointNet.BroadcastSet(waypointState);
			string text = (waypointState.IsInside ? "inside" : "outside");
			Feedback("Waypoint dropped (" + text + ")", "Shared Waypoint", "Dropped " + text + " at your position.");
			Plugin.Log.LogInfo((object)$"Dropped waypoint inside={waypointState.IsInside} pos={waypointState.Position} owner={waypointState.OwnerPlayerClientId}.");
		}

		private static void ClearWaypoint(PlayerControllerB player)
		{
			ulong playerClientId = player.playerClientId;
			if (!WaypointRegistry.TryGet(playerClientId, out WaypointState _))
			{
				Feedback("No waypoint to clear", "Shared Waypoint", "You have no active waypoint.");
				return;
			}
			WaypointRegistry.Clear(playerClientId);
			WaypointNet.BroadcastClear(playerClientId);
			Feedback("Waypoint cleared", "Shared Waypoint", "Your waypoint was removed.");
			Plugin.Log.LogInfo((object)$"Cleared own waypoint owner={playerClientId}.");
		}

		private static void Feedback(string tip, string title, string body)
		{
			try
			{
				HUDManager instance = HUDManager.Instance;
				if (!((Object)(object)instance == (Object)null))
				{
					instance.ChangeControlTip(3, tip, false);
					instance.DisplayTip(title, body, false, false, "LC_Tip1");
				}
			}
			catch
			{
			}
		}

		private void TryAssignFont()
		{
			if (_fontAssigned)
			{
				return;
			}
			try
			{
				TMP_FontAsset val = null;
				HUDManager instance = HUDManager.Instance;
				if ((Object)(object)instance != (Object)null)
				{
					if ((Object)(object)instance.clockNumber != (Object)null && (Object)(object)((TMP_Text)instance.clockNumber).font != (Object)null)
					{
						val = ((TMP_Text)instance.clockNumber).font;
					}
					if ((Object)(object)val == (Object)null && instance.controlTipLines != null)
					{
						TextMeshProUGUI[] controlTipLines = instance.controlTipLines;
						foreach (TextMeshProUGUI val2 in controlTipLines)
						{
							if ((Object)(object)val2 != (Object)null && (Object)(object)((TMP_Text)val2).font != (Object)null)
							{
								val = ((TMP_Text)val2).font;
								break;
							}
						}
					}
					if ((Object)(object)val == (Object)null && (Object)(object)instance.weightCounter != (Object)null)
					{
						val = ((TMP_Text)instance.weightCounter).font;
					}
				}
				if ((Object)(object)val == (Object)null && (Object)(object)TMP_Settings.defaultFontAsset != (Object)null)
				{
					val = TMP_Settings.defaultFontAsset;
				}
				if ((Object)(object)val != (Object)null)
				{
					_tmpFont = val;
					_fontAssigned = true;
					if ((Object)(object)_label != (Object)null)
					{
						((TMP_Text)_label).font = val;
					}
					Plugin.Log.LogInfo((object)("SharedWaypoints TMP font assigned: " + ((Object)val).name));
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Font assign failed: " + ex.Message));
			}
		}

		private void RefreshPanel()
		{
			//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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_024d: 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_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_canvas == (Object)null || (Object)(object)_panelRt == (Object)null)
			{
				return;
			}
			if (Plugin.Enabled == null || !Plugin.Enabled.Value)
			{
				SetPanelVisible(visible: false);
				return;
			}
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)val == (Object)null || val.isPlayerDead)
			{
				SetPanelVisible(visible: false);
				return;
			}
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null || instance.inShipPhase)
			{
				SetPanelVisible(visible: false);
				return;
			}
			bool isInsideFactory = val.isInsideFactory;
			Vector3 position = ((Component)val).transform.position;
			ulong playerClientId = val.playerClientId;
			float num = Plugin.MaxDistance?.Value ?? 500f;
			bool flag = Plugin.ShowOwnWaypoint == null || Plugin.ShowOwnWaypoint.Value;
			float num2 = Mathf.Clamp(Plugin.HudScale?.Value ?? 1f, 0.6f, 2f);
			((Transform)_panelRt).localScale = Vector3.one * num2;
			List<(string, Color)> list = new List<(string, Color)>();
			foreach (WaypointState item3 in WaypointRegistry.Snapshot())
			{
				if (item3.IsInside == isInsideFactory && (flag || item3.OwnerPlayerClientId != playerClientId))
				{
					float num3 = Vector3.Distance(position, item3.Position);
					if (!(num3 > num))
					{
						string text = BearingArrow(val, item3.Position);
						string text2 = Shorten(item3.OwnerName, 14);
						string text3 = (item3.IsInside ? "IN" : "OUT");
						string text4 = ((item3.OwnerPlayerClientId == playerClientId) ? "*" : " ");
						list.Add(($"{text4}{text} {text2}  {num3:0}m  [{text3}]", item3.Color));
					}
				}
			}
			if (list.Count == 0)
			{
				SetPanelVisible(visible: false);
				return;
			}
			StringBuilder stringBuilder = new StringBuilder(128);
			stringBuilder.Append("<color=#FFAA55>WAYPOINTS</color>\n");
			foreach (var item4 in list)
			{
				string item = item4.Item1;
				string value = ColorUtility.ToHtmlStringRGB(item4.Item2);
				stringBuilder.Append("<color=#").Append(value).Append('>')
					.Append(item)
					.Append("</color>\n");
			}
			string text5 = stringBuilder.ToString().TrimEnd();
			if (text5 != _cachedText)
			{
				_cachedText = text5;
				if ((Object)(object)_label != (Object)null)
				{
					((TMP_Text)_label).text = text5;
					((Graphic)_label).color = Color.white;
				}
				else if ((Object)(object)_fallback != (Object)null)
				{
					StringBuilder stringBuilder2 = new StringBuilder();
					stringBuilder2.AppendLine("WAYPOINTS");
					foreach (var item5 in list)
					{
						string item2 = item5.Item1;
						stringBuilder2.AppendLine(item2);
					}
					_fallback.text = stringBuilder2.ToString().TrimEnd();
				}
			}
			float num4 = Mathf.Clamp(36f + (float)list.Count * 26f, 60f, 280f);
			_panelRt.sizeDelta = new Vector2(340f, num4);
			SetPanelVisible(visible: true);
		}

		private void SetPanelVisible(bool visible)
		{
			if ((Object)(object)_panelRt != (Object)null && ((Component)_panelRt).gameObject.activeSelf != visible)
			{
				((Component)_panelRt).gameObject.SetActive(visible);
			}
			if (!visible)
			{
				_cachedText = "";
			}
		}

		private static string Shorten(string name, int max)
		{
			if (string.IsNullOrEmpty(name))
			{
				return "?";
			}
			if (name.Length > max)
			{
				return name.Substring(0, max - 1) + "…";
			}
			return name;
		}

		private static string BearingArrow(PlayerControllerB player, Vector3 target)
		{
			//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target - ((Component)player).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				return "●";
			}
			Vector3 forward = ((Component)player).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			float num = Vector3.SignedAngle(forward, ((Vector3)(ref val)).normalized, Vector3.up);
			float num2 = Mathf.Abs(num);
			if (num2 < 22.5f)
			{
				return "↑";
			}
			if (num2 > 157.5f)
			{
				return "↓";
			}
			if (num > 0f)
			{
				if (num < 67.5f)
				{
					return "↗";
				}
				if (num < 112.5f)
				{
					return "→";
				}
				return "↘";
			}
			if (num > -67.5f)
			{
				return "↖";
			}
			if (num > -112.5f)
			{
				return "←";
			}
			return "↙";
		}
	}
	internal static class WaypointNet
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static HandleNamedMessageDelegate <0>__OnMessage;

			public static Action<ulong> <1>__OnClientConnected;
		}

		public const string MessageName = "MrGlim.SharedWaypoints";

		private static bool _registered;

		private static bool _clientConnectedHooked;

		private static bool _requestedSync;

		public static void EnsureRegistered()
		{
			//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_004f: Expected O, but got Unknown
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null)
			{
				_registered = false;
				_clientConnectedHooked = false;
				_requestedSync = false;
				return;
			}
			if (!_registered)
			{
				CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager;
				object obj = <>O.<0>__OnMessage;
				if (obj == null)
				{
					HandleNamedMessageDelegate val = OnMessage;
					<>O.<0>__OnMessage = val;
					obj = (object)val;
				}
				customMessagingManager.RegisterNamedMessageHandler("MrGlim.SharedWaypoints", (HandleNamedMessageDelegate)obj);
				_registered = true;
				Plugin.Log.LogInfo((object)"SharedWaypoints net handler registered.");
			}
			if (singleton.IsServer && !_clientConnectedHooked)
			{
				singleton.OnClientConnectedCallback += OnClientConnected;
				_clientConnectedHooked = true;
			}
			if (!singleton.IsServer && singleton.IsConnectedClient && !_requestedSync)
			{
				_requestedSync = true;
				RequestSync();
			}
		}

		public unsafe static void BroadcastSet(WaypointState state)
		{
			//IL_0016: 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_0045: 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)
			EnsureRegistered();
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null)
			{
				return;
			}
			FastBufferWriter val = WriteSet(state);
			try
			{
				if (singleton.IsServer)
				{
					singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val, (NetworkDelivery)2);
				}
				else
				{
					singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", 0uL, val, (NetworkDelivery)2);
				}
			}
			finally
			{
				((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
			}
		}

		public static void BroadcastClear(ulong ownerPlayerClientId)
		{
			//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_003a: 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_006f: 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)
			EnsureRegistered();
			NetworkManager singleton = NetworkManager.Singleton;
			if (!((Object)(object)singleton == (Object)null))
			{
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(16, (Allocator)2, -1);
				byte b = 0;
				((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref ownerPlayerClientId, default(ForPrimitives));
				if (singleton.IsServer)
				{
					singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val, (NetworkDelivery)2);
				}
				else
				{
					singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", 0uL, val, (NetworkDelivery)2);
				}
				((FastBufferWriter)(ref val)).Dispose();
			}
		}

		private static void RequestSync()
		{
			//IL_002a: 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_0040: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if (!((Object)(object)singleton == (Object)null) && !singleton.IsServer)
			{
				FastBufferWriter val = default(FastBufferWriter);
				((FastBufferWriter)(ref val))..ctor(8, (Allocator)2, -1);
				byte b = 2;
				((FastBufferWriter)(ref val)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
				ulong num = 0uL;
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref num, default(ForPrimitives));
				singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", 0uL, val, (NetworkDelivery)2);
				((FastBufferWriter)(ref val)).Dispose();
				Plugin.Log.LogInfo((object)"Requested waypoint sync from server.");
			}
		}

		private static void OnClientConnected(ulong clientId)
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if (!((Object)(object)singleton == (Object)null) && singleton.IsServer && clientId != singleton.LocalClientId)
			{
				SendAllToClient(clientId);
			}
		}

		private unsafe static void SendAllToClient(ulong clientId)
		{
			//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_003d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null || !singleton.IsServer)
			{
				return;
			}
			foreach (WaypointState item in WaypointRegistry.Snapshot())
			{
				FastBufferWriter val = WriteSet(item);
				try
				{
					singleton.CustomMessagingManager.SendNamedMessage("MrGlim.SharedWaypoints", clientId, val, (NetworkDelivery)2);
				}
				finally
				{
					((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
				}
			}
			Plugin.Log.LogInfo((object)$"Resynced {WaypointRegistry.All.Count} waypoint(s) to client {clientId}.");
		}

		private static FastBufferWriter WriteSet(WaypointState state)
		{
			//IL_002f: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			int byteCount = Encoding.UTF8.GetByteCount(state.OwnerName ?? "");
			FastBufferWriter result = default(FastBufferWriter);
			((FastBufferWriter)(ref result))..ctor(48 + byteCount, (Allocator)2, -1);
			byte b = 1;
			((FastBufferWriter)(ref result)).WriteValueSafe<byte>(ref b, default(ForPrimitives));
			((FastBufferWriter)(ref result)).WriteValueSafe<ulong>(ref state.OwnerPlayerClientId, default(ForPrimitives));
			((FastBufferWriter)(ref result)).WriteValueSafe(state.OwnerName ?? "", false);
			((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref state.Position.x, default(ForPrimitives));
			((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref state.Position.y, default(ForPrimitives));
			((FastBufferWriter)(ref result)).WriteValueSafe<float>(ref state.Position.z, default(ForPrimitives));
			((FastBufferWriter)(ref result)).WriteValueSafe<bool>(ref state.IsInside, default(ForPrimitives));
			((FastBufferWriter)(ref result)).WriteValueSafe<int>(ref state.ColorIndex, default(ForPrimitives));
			return result;
		}

		private unsafe static void OnMessage(ulong sender, FastBufferReader reader)
		{
			//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 missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			byte b = default(byte);
			((FastBufferReader)(ref reader)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
			NetworkManager singleton = NetworkManager.Singleton;
			if (b == 2)
			{
				if ((Object)(object)singleton != (Object)null && singleton.IsServer)
				{
					SendAllToClient(sender);
				}
				return;
			}
			ulong num = default(ulong);
			((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref num, default(ForPrimitives));
			switch (b)
			{
			case 0:
				WaypointRegistry.Clear(num);
				Plugin.Log.LogInfo((object)$"Waypoint cleared for owner={num}.");
				if ((Object)(object)singleton != (Object)null && singleton.IsServer)
				{
					FastBufferWriter val2 = default(FastBufferWriter);
					((FastBufferWriter)(ref val2))..ctor(16, (Allocator)2, -1);
					byte b2 = 0;
					((FastBufferWriter)(ref val2)).WriteValueSafe<byte>(ref b2, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<ulong>(ref num, default(ForPrimitives));
					singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val2, (NetworkDelivery)2);
					((FastBufferWriter)(ref val2)).Dispose();
				}
				break;
			case 1:
			{
				string text = default(string);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
				float num2 = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num2, default(ForPrimitives));
				float num3 = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num3, default(ForPrimitives));
				float num4 = default(float);
				((FastBufferReader)(ref reader)).ReadValueSafe<float>(ref num4, default(ForPrimitives));
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				int colorIndex = default(int);
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref colorIndex, default(ForPrimitives));
				WaypointState state = new WaypointState
				{
					OwnerPlayerClientId = num,
					OwnerName = (text ?? ""),
					Position = new Vector3(num2, num3, num4),
					IsInside = flag,
					ColorIndex = colorIndex
				};
				WaypointRegistry.Set(state);
				Plugin.Log.LogInfo((object)$"Waypoint set owner={num} name='{text}' inside={flag} pos=({num2:0.0},{num3:0.0},{num4:0.0}).");
				if ((Object)(object)singleton != (Object)null && singleton.IsServer && sender != 0L)
				{
					FastBufferWriter val = WriteSet(state);
					try
					{
						singleton.CustomMessagingManager.SendNamedMessageToAll("MrGlim.SharedWaypoints", val, (NetworkDelivery)2);
						break;
					}
					finally
					{
						((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
					}
				}
				break;
			}
			}
		}
	}
	internal static class WaypointRegistry
	{
		private static readonly Dictionary<ulong, WaypointState> ByOwner = new Dictionary<ulong, WaypointState>();

		public static IReadOnlyDictionary<ulong, WaypointState> All => ByOwner;

		public static void Set(WaypointState state)
		{
			ByOwner[state.OwnerPlayerClientId] = state;
		}

		public static void Clear(ulong ownerPlayerClientId)
		{
			ByOwner.Remove(ownerPlayerClientId);
		}

		public static bool TryGet(ulong ownerPlayerClientId, out WaypointState state)
		{
			return ByOwner.TryGetValue(ownerPlayerClientId, out state);
		}

		public static void ClearAll()
		{
			ByOwner.Clear();
		}

		public static IEnumerable<WaypointState> Snapshot()
		{
			return ByOwner.Values;
		}
	}
	internal sealed class WaypointState
	{
		public ulong OwnerPlayerClientId;

		public string OwnerName = "";

		public Vector3 Position;

		public bool IsInside;

		public int ColorIndex;

		public Color Color => WaypointPalette.Get(ColorIndex);

		public static int ColorIndexFor(ulong clientId)
		{
			return (int)(clientId % (ulong)WaypointPalette.Count);
		}
	}
	internal static class WaypointPalette
	{
		private static readonly Color[] Colors = (Color[])(object)new Color[8]
		{
			new Color(0.95f, 0.45f, 0.2f, 1f),
			new Color(0.3f, 0.85f, 0.95f, 1f),
			new Color(0.55f, 0.95f, 0.35f, 1f),
			new Color(0.95f, 0.35f, 0.75f, 1f),
			new Color(0.95f, 0.9f, 0.25f, 1f),
			new Color(0.55f, 0.55f, 1f, 1f),
			new Color(1f, 0.55f, 0.35f, 1f),
			new Color(0.4f, 0.95f, 0.7f, 1f)
		};

		public static int Count => Colors.Length;

		public static Color Get(int index)
		{
			//IL_0008: 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)
			if (Colors.Length == 0)
			{
				return Color.white;
			}
			int num = index % Colors.Length;
			if (num < 0)
			{
				num += Colors.Length;
			}
			return Colors[num];
		}
	}
}