Decompiled source of SupermarketTogetherMovementTools v0.1.0

BepInEx\plugins\SupermarketTogetherMovementTools\SupermarketTogetherMovementTools.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mirror;
using StarterAssets;
using SupermarketTogetherFlyMod;
using SupermarketTogetherMovementSpeedMenu;
using SupermarketTogetherTeleportMenu;
using UnityEngine;

[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("SupermarketTogetherMovementTools")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SupermarketTogetherMovementTools")]
[assembly: AssemblyTitle("SupermarketTogetherMovementTools")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 SupermarketTogetherTeleportMenu
{
	[Serializable]
	internal sealed class TeleportLocationData
	{
		public string Id = "";

		public string Name = "";

		public float X;

		public float Y;

		public float Z;

		public float Yaw;

		public KeyCode ShortcutKey;

		public Vector3 Position => new Vector3(X, Y, Z);

		public TeleportLocationData()
		{
		}

		public TeleportLocationData(string id, string name, Vector3 position, float yaw, KeyCode shortcutKey = (KeyCode)0)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			Id = id;
			Name = name;
			X = position.x;
			Y = position.y;
			Z = position.z;
			Yaw = yaw;
			ShortcutKey = shortcutKey;
		}

		public TeleportLocationData WithName(string name)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return new TeleportLocationData(Id, name, Position, Yaw, ShortcutKey);
		}

		public TeleportLocationData WithShortcutKey(KeyCode shortcutKey)
		{
			//IL_000d: 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)
			return new TeleportLocationData(Id, Name, Position, Yaw, shortcutKey);
		}
	}
	[Serializable]
	internal sealed class TeleportLocationCollection
	{
		public List<TeleportLocationData> Locations = new List<TeleportLocationData>();
	}
	internal sealed class TeleportLocationStorage
	{
		private readonly string filePath;

		private readonly ManualLogSource logger;

		public TeleportLocationStorage(string configPath, ManualLogSource pluginLogger)
		{
			filePath = Path.Combine(configPath, "uta_a.supermarkettogether.teleportmenu.locations.json");
			logger = pluginLogger;
		}

		public List<TeleportLocationData> Load()
		{
			if (!File.Exists(filePath))
			{
				return new List<TeleportLocationData>();
			}
			try
			{
				string text = File.ReadAllText(filePath);
				if (string.IsNullOrWhiteSpace(text))
				{
					return new List<TeleportLocationData>();
				}
				return JsonUtility.FromJson<TeleportLocationCollection>(text)?.Locations ?? new List<TeleportLocationData>();
			}
			catch (Exception ex)
			{
				logger.LogError((object)("Failed to load teleport locations: " + ex.Message));
				return new List<TeleportLocationData>();
			}
		}

		public void Save(IReadOnlyList<TeleportLocationData> locations)
		{
			try
			{
				Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? ".");
				string contents = JsonUtility.ToJson((object)new TeleportLocationCollection
				{
					Locations = new List<TeleportLocationData>(locations)
				}, true);
				File.WriteAllText(filePath, contents);
			}
			catch (Exception ex)
			{
				logger.LogError((object)("Failed to save teleport locations: " + ex.Message));
			}
		}
	}
	internal sealed class TeleportMenu : MonoBehaviour
	{
		private enum TeleportTab
		{
			Locations,
			Players,
			LookTeleport
		}

		private enum ShortcutTargetKind
		{
			None,
			Location,
			Player,
			LookTeleport
		}

		private sealed class RowDraft
		{
			public string Name { get; set; }

			public RowDraft(string name)
			{
				Name = name;
			}
		}

		private const string WindowTitle = "Teleport Menu";

		private const string LocalPlayerObjectName = "LocalGamePlayer";

		private const float ButtonHeight = 28f;

		private const float HeaderDragHeight = 34f;

		private const float SmallButtonWidth = 64f;

		private const float MediumButtonWidth = 84f;

		private const float PlayerOffsetDistance = 1.5f;

		private const float LookTeleportMaxDistance = 1000f;

		private const float LookTeleportSurfaceOffset = 0.15f;

		private const int DefaultMaxLocations = 20;

		private static readonly KeyCode[] ShortcutKeyCandidates = Enum.GetValues(typeof(KeyCode)).Cast<KeyCode>().Where(IsAllowedShortcutKey)
			.ToArray();

		private readonly List<TeleportLocationData> locations = new List<TeleportLocationData>();

		private readonly List<PlayerShortcutData> playerShortcuts = new List<PlayerShortcutData>();

		private readonly Dictionary<string, RowDraft> drafts = new Dictionary<string, RowDraft>();

		private ManualLogSource? logger;

		private TeleportMenuSettings? settings;

		private TeleportLocationStorage? locationStorage;

		private TeleportShortcutStorage? shortcutStorage;

		private FirstPersonController? cachedFirstPersonController;

		private PlayerObjectController? cachedLocalPlayer;

		private Vector2 locationScrollPosition;

		private Vector2 playerScrollPosition;

		private TeleportTab activeTab;

		private ShortcutTargetKind listeningKind;

		private string listeningTargetId = "";

		private string listeningTargetName = "";

		private string newLocationName = "";

		private KeyCode lookTeleportKey;

		private string statusMessage = "Load into a save, then save your current position.";

		public void Initialize(ManualLogSource pluginLogger, TeleportMenuSettings menuSettings, string configPath)
		{
			//IL_0072: 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)
			logger = pluginLogger;
			settings = menuSettings;
			locationStorage = new TeleportLocationStorage(configPath, pluginLogger);
			shortcutStorage = new TeleportShortcutStorage(configPath, pluginLogger);
			locations.AddRange(NormalizeLoadedLocations(locationStorage.Load()).Take(GetMaxLocations()));
			TeleportShortcutCollection teleportShortcutCollection = shortcutStorage.Load();
			playerShortcuts.AddRange(NormalizeLoadedPlayerShortcuts(teleportShortcutCollection.PlayerShortcuts));
			lookTeleportKey = (KeyCode)(IsAllowedShortcutKey(teleportShortcutCollection.LookTeleportKey) ? ((int)teleportShortcutCollection.LookTeleportKey) : 0);
			EnforceGlobalShortcutUniqueness();
			RebuildDrafts();
		}

		internal void ShowPanel()
		{
			RefreshPlayerReferences();
			RebuildDrafts();
		}

		private void Update()
		{
			if (settings != null && (listeningKind == ShortcutTargetKind.None || !TryCaptureShortcutKey()))
			{
				HandleShortcuts();
			}
		}

		internal void DrawPanel(float availableHeight)
		{
			GUILayout.Label("Teleport Menu", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			DrawTabs();
			GUILayout.Space(8f);
			switch (activeTab)
			{
			case TeleportTab.Locations:
				DrawLocationsTab(availableHeight);
				break;
			case TeleportTab.Players:
				DrawPlayersTab(availableHeight);
				break;
			case TeleportTab.LookTeleport:
				DrawLookTeleportTab();
				break;
			}
			GUILayout.Space(8f);
			GUILayout.Label(statusMessage, Array.Empty<GUILayoutOption>());
		}

		private void DrawTabs()
		{
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawTabButton(TeleportTab.Locations, "Locations");
			DrawTabButton(TeleportTab.Players, "Players");
			DrawTabButton(TeleportTab.LookTeleport, "Look TP");
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private void DrawTabButton(TeleportTab tab, string label)
		{
			GUI.enabled = activeTab != tab;
			if (GUILayout.Button(label, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(120f),
				GUILayout.Height(32f)
			}))
			{
				activeTab = tab;
			}
			GUI.enabled = true;
		}

		private void DrawLocationsTab(float availableHeight)
		{
			DrawSaveCurrentSection();
			GUILayout.Space(10f);
			GUILayout.Label($"Saved locations: {locations.Count}/{GetMaxLocations()}", Array.Empty<GUILayoutOption>());
			DrawLocationRows(Mathf.Max(180f, availableHeight - 130f));
		}

		private void DrawPlayersTab(float availableHeight)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Players", Array.Empty<GUILayoutOption>());
			playerScrollPosition = GUILayout.BeginScrollView(playerScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(Mathf.Max(180f, availableHeight - 80f)) });
			DrawPlayerRows();
			GUILayout.EndScrollView();
		}

		private void DrawLookTeleportTab()
		{
			GUILayout.Label("Teleport to the point you are looking at.", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(GetLookTeleportShortcutLabel(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(64f),
				GUILayout.Height(28f)
			}))
			{
				BeginListening(ShortcutTargetKind.LookTeleport, "", "Look TP");
			}
			if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(64f),
				GUILayout.Height(28f)
			}))
			{
				SetLookTeleportShortcut((KeyCode)0);
			}
			if (GUILayout.Button("TP", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(64f),
				GUILayout.Height(28f)
			}))
			{
				TeleportToLookPoint();
			}
			GUILayout.EndHorizontal();
		}

		private void DrawSaveCurrentSection()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController firstPersonController = GetFirstPersonController();
			string text = (((Object)(object)firstPersonController != (Object)null) ? FormatPosition(((Component)firstPersonController).transform.position) : "(player not found)");
			GUILayout.Label("Current position: " + text, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Name", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) });
			newLocationName = GUILayout.TextField(newLocationName, 32, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) });
			if (GUILayout.Button("Save Current", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(120f),
				GUILayout.Height(28f)
			}))
			{
				SaveCurrentLocation();
			}
			GUILayout.EndHorizontal();
		}

		private void DrawLocationRows(float scrollHeight)
		{
			//IL_0002: 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_001b: 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)
			locationScrollPosition = GUILayout.BeginScrollView(locationScrollPosition, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(scrollHeight) });
			foreach (TeleportLocationData item in locations.ToList())
			{
				if (!drafts.TryGetValue(item.Id, out RowDraft value))
				{
					value = new RowDraft(item.Name);
					drafts[item.Id] = value;
				}
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				value.Name = GUILayout.TextField(value.Name, 32, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) });
				GUILayout.Label(FormatLocation(item), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) });
				GUILayout.Label(GetShortcutLabel(item.ShortcutKey), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) });
				if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(64f),
					GUILayout.Height(28f)
				}))
				{
					BeginListening(ShortcutTargetKind.Location, item.Id, item.Name);
				}
				if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(64f),
					GUILayout.Height(28f)
				}))
				{
					SetLocationShortcut(item.Id, (KeyCode)0);
				}
				if (GUILayout.Button("Save", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(64f),
					GUILayout.Height(28f)
				}))
				{
					SaveRow(item, value);
				}
				if (GUILayout.Button("TP", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(64f),
					GUILayout.Height(28f)
				}))
				{
					TeleportTo(item);
				}
				if (GUILayout.Button("Delete", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(84f),
					GUILayout.Height(28f)
				}))
				{
					DeleteLocation(item);
				}
				GUILayout.EndHorizontal();
			}
			GUILayout.EndScrollView();
		}

		private void DrawPlayerRows()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_0112: Invalid comparison between Unknown and I4
			IReadOnlyList<PlayerObjectController> players = GetPlayers();
			if (players.Count == 0)
			{
				GUILayout.Label("(no players found)", Array.Empty<GUILayoutOption>());
				return;
			}
			PlayerObjectController localPlayer = GetLocalPlayer();
			foreach (PlayerObjectController item in players)
			{
				if (!((Object)(object)item == (Object)null))
				{
					string playerId = GetPlayerId(item);
					string text = GetPlayerDisplayName(item);
					KeyCode playerShortcutKey = GetPlayerShortcutKey(playerId);
					bool flag = (Object)(object)item == (Object)(object)localPlayer;
					if (flag)
					{
						text += " (self)";
					}
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(180f) });
					GUILayout.Label(GetShortcutLabel(playerShortcutKey), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) });
					GUI.enabled = !flag;
					if (GUILayout.Button("Set", (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(64f),
						GUILayout.Height(28f)
					}))
					{
						BeginListening(ShortcutTargetKind.Player, playerId, text);
						UpsertPlayerShortcutName(playerId, GetPlayerDisplayName(item));
					}
					GUI.enabled = !flag || (int)playerShortcutKey > 0;
					if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(64f),
						GUILayout.Height(28f)
					}))
					{
						SetPlayerShortcut(playerId, GetPlayerDisplayName(item), (KeyCode)0);
					}
					GUI.enabled = !flag;
					if (GUILayout.Button("TP To", (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(84f),
						GUILayout.Height(28f)
					}))
					{
						TeleportSelfToPlayer(item);
					}
					if (GUILayout.Button("Bring", (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(84f),
						GUILayout.Height(28f)
					}))
					{
						TeleportPlayerToSelf(item);
					}
					GUI.enabled = true;
					GUILayout.EndHorizontal();
				}
			}
		}

		private void SaveCurrentLocation()
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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)
			FirstPersonController firstPersonController = GetFirstPersonController();
			if ((Object)(object)firstPersonController == (Object)null)
			{
				statusMessage = "Player controller was not found. Load into a save first.";
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogWarning((object)statusMessage);
				}
				return;
			}
			if (locations.Count >= GetMaxLocations())
			{
				statusMessage = $"Cannot save more than {GetMaxLocations()} locations.";
				return;
			}
			string name = (string.IsNullOrWhiteSpace(newLocationName) ? $"Point {locations.Count + 1}" : newLocationName.Trim());
			string id = Guid.NewGuid().ToString("N");
			Vector3 position = ((Component)firstPersonController).transform.position;
			Quaternion rotation = ((Component)firstPersonController).transform.rotation;
			TeleportLocationData teleportLocationData = new TeleportLocationData(id, name, position, ((Quaternion)(ref rotation)).eulerAngles.y, (KeyCode)0);
			locations.Add(teleportLocationData);
			drafts[teleportLocationData.Id] = new RowDraft(teleportLocationData.Name);
			SaveLocations();
			newLocationName = "";
			statusMessage = "Saved location: " + teleportLocationData.Name;
			ManualLogSource? obj2 = logger;
			if (obj2 != null)
			{
				obj2.LogInfo((object)statusMessage);
			}
		}

		private void SaveRow(TeleportLocationData location, RowDraft draft)
		{
			string text = draft.Name.Trim();
			if (string.IsNullOrWhiteSpace(text))
			{
				statusMessage = "Name cannot be empty. Example: Storage";
				return;
			}
			int num = locations.FindIndex((TeleportLocationData item) => item.Id == location.Id);
			if (num < 0)
			{
				statusMessage = "Location was not found.";
				return;
			}
			TeleportLocationData teleportLocationData = location.WithName(text);
			locations[num] = teleportLocationData;
			drafts[teleportLocationData.Id] = new RowDraft(teleportLocationData.Name);
			SaveLocations();
			statusMessage = "Saved changes: " + teleportLocationData.Name;
		}

		private void DeleteLocation(TeleportLocationData location)
		{
			locations.RemoveAll((TeleportLocationData item) => item.Id == location.Id);
			drafts.Remove(location.Id);
			SaveLocations();
			statusMessage = "Deleted location: " + location.Name;
		}

		private void TeleportTo(TeleportLocationData location)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController firstPersonController = GetFirstPersonController();
			if ((Object)(object)firstPersonController == (Object)null)
			{
				statusMessage = "Player controller was not found. Load into a save first.";
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogWarning((object)statusMessage);
				}
				return;
			}
			MoveTransform(((Component)firstPersonController).transform, location.Position, Quaternion.Euler(0f, location.Yaw, 0f));
			statusMessage = "Teleported to: " + location.Name;
			ManualLogSource? obj2 = logger;
			if (obj2 != null)
			{
				obj2.LogInfo((object)statusMessage);
			}
		}

		private void TeleportSelfToPlayer(PlayerObjectController targetPlayer)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			FirstPersonController firstPersonController = GetFirstPersonController();
			if ((Object)(object)firstPersonController == (Object)null)
			{
				statusMessage = "Player controller was not found.";
				return;
			}
			Vector3 destination = ((Component)targetPlayer).transform.position - ((Component)targetPlayer).transform.forward * 1.5f;
			MoveTransform(((Component)firstPersonController).transform, destination, ((Component)firstPersonController).transform.rotation);
			statusMessage = "Teleported to " + GetPlayerDisplayName(targetPlayer) + ".";
			ManualLogSource? obj = logger;
			if (obj != null)
			{
				obj.LogInfo((object)statusMessage);
			}
		}

		private void TeleportPlayerToSelf(PlayerObjectController targetPlayer)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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)
			PlayerObjectController localPlayer = GetLocalPlayer();
			if ((Object)(object)localPlayer == (Object)null)
			{
				statusMessage = "Local player was not found.";
				return;
			}
			Vector3 destination = ((Component)localPlayer).transform.position + ((Component)localPlayer).transform.forward * 1.5f;
			MoveTransform(((Component)targetPlayer).transform, destination, ((Component)targetPlayer).transform.rotation);
			statusMessage = "Teleported " + GetPlayerDisplayName(targetPlayer) + " to you.";
			ManualLogSource? obj = logger;
			if (obj != null)
			{
				obj.LogInfo((object)statusMessage);
			}
		}

		private void TeleportToLookPoint()
		{
			//IL_003f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_008c: 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)
			FirstPersonController firstPersonController = GetFirstPersonController();
			if ((Object)(object)firstPersonController == (Object)null)
			{
				statusMessage = "Player controller was not found. Load into a save first.";
				return;
			}
			Camera main = Camera.main;
			if ((Object)(object)main == (Object)null)
			{
				statusMessage = "Main camera was not found.";
				return;
			}
			Transform transform = ((Component)main).transform;
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(transform.position, transform.forward, ref val, 1000f, -5, (QueryTriggerInteraction)1))
			{
				statusMessage = "No surface found in view.";
				return;
			}
			Vector3 destination = ((RaycastHit)(ref val)).point + ((RaycastHit)(ref val)).normal * 0.15f;
			MoveTransform(((Component)firstPersonController).transform, destination, ((Component)firstPersonController).transform.rotation);
			statusMessage = "Teleported to look point.";
			ManualLogSource? obj = logger;
			if (obj != null)
			{
				obj.LogInfo((object)statusMessage);
			}
		}

		private void HandleShortcuts()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			foreach (TeleportLocationData location in locations)
			{
				if ((int)location.ShortcutKey != 0 && Input.GetKeyDown(location.ShortcutKey))
				{
					TeleportTo(location);
					return;
				}
			}
			foreach (PlayerShortcutData playerShortcut in playerShortcuts)
			{
				if ((int)playerShortcut.ShortcutKey != 0 && Input.GetKeyDown(playerShortcut.ShortcutKey))
				{
					PlayerObjectController val = FindPlayerById(playerShortcut.PlayerId);
					if ((Object)(object)val == (Object)null)
					{
						statusMessage = "Player is not online: " + playerShortcut.PlayerName;
					}
					else if ((Object)(object)val == (Object)(object)GetLocalPlayer())
					{
						statusMessage = "Shortcut points to yourself: " + playerShortcut.PlayerName;
					}
					else
					{
						TeleportSelfToPlayer(val);
					}
					return;
				}
			}
			if ((int)lookTeleportKey != 0 && Input.GetKeyDown(lookTeleportKey))
			{
				TeleportToLookPoint();
			}
		}

		private bool TryCaptureShortcutKey()
		{
			//IL_0013: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (settings != null && Input.GetKeyDown(settings.ToggleMenuKey.Value))
			{
				statusMessage = $"{settings.ToggleMenuKey.Value} is reserved for the menu.";
				return true;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				ClearListening();
				statusMessage = "Shortcut setup cancelled.";
				return true;
			}
			KeyCode[] shortcutKeyCandidates = ShortcutKeyCandidates;
			foreach (KeyCode val in shortcutKeyCandidates)
			{
				if (Input.GetKeyDown(val))
				{
					ApplyCapturedShortcut(val);
					ClearListening();
					return true;
				}
			}
			return false;
		}

		private void ApplyCapturedShortcut(KeyCode shortcutKey)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			switch (listeningKind)
			{
			case ShortcutTargetKind.Location:
				SetLocationShortcut(listeningTargetId, shortcutKey);
				break;
			case ShortcutTargetKind.Player:
				SetPlayerShortcut(listeningTargetId, listeningTargetName, shortcutKey);
				break;
			case ShortcutTargetKind.LookTeleport:
				SetLookTeleportShortcut(shortcutKey);
				break;
			}
		}

		private void SetLocationShortcut(string locationId, KeyCode shortcutKey)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			int num = locations.FindIndex((TeleportLocationData location) => location.Id == locationId);
			if (num < 0)
			{
				statusMessage = "Location was not found.";
				return;
			}
			if ((int)shortcutKey != 0)
			{
				ClearShortcutKeyFromOtherActions(shortcutKey, ShortcutTargetKind.Location, locationId);
			}
			TeleportLocationData teleportLocationData = locations[num];
			locations[num] = teleportLocationData.WithShortcutKey(shortcutKey);
			SaveLocations();
			SaveShortcuts();
			statusMessage = (((int)shortcutKey == 0) ? ("Cleared shortcut: " + teleportLocationData.Name) : $"Set shortcut {shortcutKey}: {teleportLocationData.Name}");
		}

		private void SetPlayerShortcut(string playerId, string playerName, KeyCode shortcutKey)
		{
			//IL_0026: 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_002a: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(playerId))
			{
				statusMessage = "Player was not found.";
				return;
			}
			if ((int)shortcutKey != 0)
			{
				ClearShortcutKeyFromOtherActions(shortcutKey, ShortcutTargetKind.Player, playerId);
			}
			int num = playerShortcuts.FindIndex((PlayerShortcutData shortcut) => shortcut.PlayerId == playerId);
			if ((int)shortcutKey == 0)
			{
				if (num >= 0)
				{
					playerShortcuts.RemoveAt(num);
				}
				SaveShortcuts();
				statusMessage = "Cleared shortcut: " + playerName;
			}
			else
			{
				if (num >= 0)
				{
					playerShortcuts[num] = new PlayerShortcutData(playerId, playerName, shortcutKey);
				}
				else
				{
					playerShortcuts.Add(new PlayerShortcutData(playerId, playerName, shortcutKey));
				}
				SaveShortcuts();
				statusMessage = $"Set shortcut {shortcutKey}: {playerName}";
			}
		}

		private void SetLookTeleportShortcut(KeyCode shortcutKey)
		{
			//IL_0000: 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_0012: 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_0004: 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 ((int)shortcutKey != 0)
			{
				ClearShortcutKeyFromOtherActions(shortcutKey, ShortcutTargetKind.LookTeleport, "");
			}
			lookTeleportKey = shortcutKey;
			SaveLocations();
			SaveShortcuts();
			statusMessage = (((int)shortcutKey == 0) ? "Cleared shortcut: Look TP" : $"Set shortcut {shortcutKey}: Look TP");
		}

		private void ClearShortcutKeyFromOtherActions(KeyCode shortcutKey, ShortcutTargetKind exceptKind, string exceptId)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < locations.Count; i++)
			{
				TeleportLocationData teleportLocationData = locations[i];
				if ((exceptKind != ShortcutTargetKind.Location || !(teleportLocationData.Id == exceptId)) && teleportLocationData.ShortcutKey == shortcutKey)
				{
					locations[i] = teleportLocationData.WithShortcutKey((KeyCode)0);
				}
			}
			for (int j = 0; j < playerShortcuts.Count; j++)
			{
				PlayerShortcutData playerShortcutData = playerShortcuts[j];
				if ((exceptKind != ShortcutTargetKind.Player || !(playerShortcutData.PlayerId == exceptId)) && playerShortcutData.ShortcutKey == shortcutKey)
				{
					playerShortcuts[j] = new PlayerShortcutData(playerShortcutData.PlayerId, playerShortcutData.PlayerName, (KeyCode)0);
				}
			}
			playerShortcuts.RemoveAll((PlayerShortcutData shortcut) => (int)shortcut.ShortcutKey == 0);
			if (exceptKind != ShortcutTargetKind.LookTeleport && lookTeleportKey == shortcutKey)
			{
				lookTeleportKey = (KeyCode)0;
			}
		}

		private void EnforceGlobalShortcutUniqueness()
		{
			//IL_001a: 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_006c: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			HashSet<KeyCode> hashSet = new HashSet<KeyCode>();
			bool flag = false;
			for (int i = 0; i < locations.Count; i++)
			{
				TeleportLocationData teleportLocationData = locations[i];
				if ((int)teleportLocationData.ShortcutKey != 0 && !hashSet.Add(teleportLocationData.ShortcutKey))
				{
					locations[i] = teleportLocationData.WithShortcutKey((KeyCode)0);
					flag = true;
				}
			}
			for (int j = 0; j < playerShortcuts.Count; j++)
			{
				PlayerShortcutData playerShortcutData = playerShortcuts[j];
				if ((int)playerShortcutData.ShortcutKey != 0 && !hashSet.Add(playerShortcutData.ShortcutKey))
				{
					playerShortcuts[j] = new PlayerShortcutData(playerShortcutData.PlayerId, playerShortcutData.PlayerName, (KeyCode)0);
					flag = true;
				}
			}
			playerShortcuts.RemoveAll((PlayerShortcutData shortcut) => (int)shortcut.ShortcutKey == 0);
			if ((int)lookTeleportKey != 0 && !hashSet.Add(lookTeleportKey))
			{
				lookTeleportKey = (KeyCode)0;
				flag = true;
			}
			if (flag)
			{
				SaveLocations();
				SaveShortcuts();
			}
		}

		private void BeginListening(ShortcutTargetKind kind, string targetId, string targetName)
		{
			listeningKind = kind;
			listeningTargetId = targetId;
			listeningTargetName = targetName;
			statusMessage = "Press a key for: " + targetName + ". Esc cancels.";
		}

		private void ClearListening()
		{
			listeningKind = ShortcutTargetKind.None;
			listeningTargetId = "";
			listeningTargetName = "";
		}

		private void UpsertPlayerShortcutName(string playerId, string playerName)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			int num = playerShortcuts.FindIndex((PlayerShortcutData shortcut) => shortcut.PlayerId == playerId);
			if (num >= 0)
			{
				PlayerShortcutData playerShortcutData = playerShortcuts[num];
				playerShortcuts[num] = new PlayerShortcutData(playerId, playerName, playerShortcutData.ShortcutKey);
				SaveShortcuts();
			}
		}

		private void SaveLocations()
		{
			locationStorage?.Save(locations);
		}

		private void SaveShortcuts()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			shortcutStorage?.Save(playerShortcuts, lookTeleportKey);
		}

		private void RebuildDrafts()
		{
			drafts.Clear();
			foreach (TeleportLocationData location in locations)
			{
				drafts[location.Id] = new RowDraft(location.Name);
			}
		}

		private static IEnumerable<TeleportLocationData> NormalizeLoadedLocations(IEnumerable<TeleportLocationData> loadedLocations)
		{
			HashSet<string> usedIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			HashSet<KeyCode> usedShortcutKeys = new HashSet<KeyCode>();
			int index = 1;
			foreach (TeleportLocationData loadedLocation in loadedLocations)
			{
				string text = ((string.IsNullOrWhiteSpace(loadedLocation.Id) || usedIds.Contains(loadedLocation.Id)) ? Guid.NewGuid().ToString("N") : loadedLocation.Id);
				usedIds.Add(text);
				string name = (string.IsNullOrWhiteSpace(loadedLocation.Name) ? $"Point {index}" : loadedLocation.Name.Trim());
				KeyCode shortcutKey = (KeyCode)((IsAllowedShortcutKey(loadedLocation.ShortcutKey) && usedShortcutKeys.Add(loadedLocation.ShortcutKey)) ? ((int)loadedLocation.ShortcutKey) : 0);
				yield return new TeleportLocationData(text, name, loadedLocation.Position, loadedLocation.Yaw, shortcutKey);
				index++;
			}
		}

		private static IEnumerable<PlayerShortcutData> NormalizeLoadedPlayerShortcuts(IEnumerable<PlayerShortcutData> loadedShortcuts)
		{
			HashSet<string> usedPlayerIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			HashSet<KeyCode> usedShortcutKeys = new HashSet<KeyCode>();
			foreach (PlayerShortcutData loadedShortcut in loadedShortcuts)
			{
				if (!string.IsNullOrWhiteSpace(loadedShortcut.PlayerId) && usedPlayerIds.Add(loadedShortcut.PlayerId) && IsAllowedShortcutKey(loadedShortcut.ShortcutKey) && usedShortcutKeys.Add(loadedShortcut.ShortcutKey))
				{
					string playerName = (string.IsNullOrWhiteSpace(loadedShortcut.PlayerName) ? loadedShortcut.PlayerId : loadedShortcut.PlayerName.Trim());
					yield return new PlayerShortcutData(loadedShortcut.PlayerId, playerName, loadedShortcut.ShortcutKey);
				}
			}
		}

		private void RefreshPlayerReferences()
		{
			if (!((Object)(object)GetFirstPersonController() == (Object)null))
			{
				cachedLocalPlayer = null;
			}
		}

		private FirstPersonController? GetFirstPersonController()
		{
			if ((Object)(object)cachedFirstPersonController != (Object)null)
			{
				return cachedFirstPersonController;
			}
			cachedFirstPersonController = FirstPersonController.Instance;
			return cachedFirstPersonController;
		}

		private PlayerObjectController? GetLocalPlayer()
		{
			if ((Object)(object)cachedLocalPlayer != (Object)null)
			{
				return cachedLocalPlayer;
			}
			GameObject val = GameObject.Find("LocalGamePlayer");
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			cachedLocalPlayer = val.GetComponent<PlayerObjectController>();
			return cachedLocalPlayer;
		}

		private static IReadOnlyList<PlayerObjectController> GetPlayers()
		{
			NetworkManager singleton = NetworkManager.singleton;
			CustomNetworkManager val = (CustomNetworkManager)(object)((singleton is CustomNetworkManager) ? singleton : null);
			if (val == null || val.GamePlayers == null)
			{
				return Array.Empty<PlayerObjectController>();
			}
			return val.GamePlayers;
		}

		private PlayerObjectController? FindPlayerById(string playerId)
		{
			return ((IEnumerable<PlayerObjectController>)GetPlayers()).FirstOrDefault((Func<PlayerObjectController, bool>)((PlayerObjectController player) => (Object)(object)player != (Object)null && GetPlayerId(player) == playerId));
		}

		private KeyCode GetPlayerShortcutKey(string playerId)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			return (KeyCode)(((??)playerShortcuts.FirstOrDefault((PlayerShortcutData shortcut) => shortcut.PlayerId == playerId)?.ShortcutKey) ?? 0);
		}

		private int GetMaxLocations()
		{
			return Mathf.Clamp(settings?.MaxLocations.Value ?? 20, 1, 20);
		}

		private static void MoveTransform(Transform target, Vector3 destination, Quaternion rotation)
		{
			//IL_002b: 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)
			CharacterController component = ((Component)target).GetComponent<CharacterController>();
			bool enabled = (Object)(object)component == (Object)null || ((Collider)component).enabled;
			if ((Object)(object)component != (Object)null)
			{
				((Collider)component).enabled = false;
			}
			target.SetPositionAndRotation(destination, rotation);
			if ((Object)(object)component != (Object)null)
			{
				((Collider)component).enabled = enabled;
			}
		}

		private static string GetPlayerId(PlayerObjectController player)
		{
			if (player.PlayerSteamID == 0)
			{
				return $"connection:{player.ConnectionID}";
			}
			return $"steam:{player.PlayerSteamID}";
		}

		private static string GetPlayerDisplayName(PlayerObjectController player)
		{
			if (!string.IsNullOrWhiteSpace(player.PlayerName))
			{
				return player.PlayerName;
			}
			return $"Player {player.ConnectionID}";
		}

		private static string FormatLocation(TeleportLocationData location)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return FormatPosition(location.Position);
		}

		private static string GetShortcutLabel(KeyCode shortcutKey)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if ((int)shortcutKey != 0)
			{
				return $"Key: {shortcutKey}";
			}
			return "Key: None";
		}

		private string GetLookTeleportShortcutLabel()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return GetShortcutLabel(lookTeleportKey);
		}

		private static string FormatPosition(Vector3 position)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			return $"X:{position.x:0.##} Y:{position.y:0.##} Z:{position.z:0.##}";
		}

		private static bool IsAllowedShortcutKey(KeyCode keyCode)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if ((int)keyCode != 0 && (int)keyCode != 27 && !IsMouseButton(keyCode) && !IsJoystickButton(keyCode))
			{
				return !IsModifierKey(keyCode);
			}
			return false;
		}

		private static bool IsMouseButton(KeyCode keyCode)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)keyCode >= 323)
			{
				return (int)keyCode <= 329;
			}
			return false;
		}

		private static bool IsJoystickButton(KeyCode keyCode)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((int)keyCode >= 330)
			{
				return (int)keyCode <= 509;
			}
			return false;
		}

		private static bool IsModifierKey(KeyCode keyCode)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if (keyCode - 303 <= 7)
			{
				return true;
			}
			return false;
		}
	}
	internal sealed class TeleportMenuSettings
	{
		public ConfigEntry<KeyCode> ToggleMenuKey { get; }

		public ConfigEntry<int> MaxLocations { get; }

		public TeleportMenuSettings(ConfigEntry<KeyCode> toggleMenuKey, ConfigEntry<int> maxLocations)
		{
			ToggleMenuKey = toggleMenuKey;
			MaxLocations = maxLocations;
		}
	}
	[Serializable]
	internal sealed class PlayerShortcutData
	{
		public string PlayerId = "";

		public string PlayerName = "";

		public KeyCode ShortcutKey;

		public PlayerShortcutData()
		{
		}

		public PlayerShortcutData(string playerId, string playerName, KeyCode shortcutKey)
		{
			//IL_002b: 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)
			PlayerId = playerId;
			PlayerName = playerName;
			ShortcutKey = shortcutKey;
		}
	}
	[Serializable]
	internal sealed class TeleportShortcutCollection
	{
		public List<PlayerShortcutData> PlayerShortcuts = new List<PlayerShortcutData>();

		public KeyCode LookTeleportKey;
	}
	internal sealed class TeleportShortcutStorage
	{
		private readonly string filePath;

		private readonly ManualLogSource logger;

		public TeleportShortcutStorage(string configPath, ManualLogSource pluginLogger)
		{
			filePath = Path.Combine(configPath, "uta_a.supermarkettogether.teleportmenu.shortcuts.json");
			logger = pluginLogger;
		}

		public TeleportShortcutCollection Load()
		{
			if (!File.Exists(filePath))
			{
				return new TeleportShortcutCollection();
			}
			try
			{
				string text = File.ReadAllText(filePath);
				if (string.IsNullOrWhiteSpace(text))
				{
					return new TeleportShortcutCollection();
				}
				return JsonUtility.FromJson<TeleportShortcutCollection>(text) ?? new TeleportShortcutCollection();
			}
			catch (Exception ex)
			{
				logger.LogError((object)("Failed to load teleport shortcuts: " + ex.Message));
				return new TeleportShortcutCollection();
			}
		}

		public void Save(IReadOnlyList<PlayerShortcutData> playerShortcuts, KeyCode lookTeleportKey)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Directory.CreateDirectory(Path.GetDirectoryName(filePath) ?? ".");
				string contents = JsonUtility.ToJson((object)new TeleportShortcutCollection
				{
					PlayerShortcuts = new List<PlayerShortcutData>(playerShortcuts),
					LookTeleportKey = lookTeleportKey
				}, true);
				File.WriteAllText(filePath, contents);
			}
			catch (Exception ex)
			{
				logger.LogError((object)("Failed to save teleport shortcuts: " + ex.Message));
			}
		}
	}
}
namespace SupermarketTogetherMovementTools
{
	internal sealed class MovementToolsMenu : MonoBehaviour
	{
		private readonly string[] tabs = new string[2] { "Movement", "Teleport" };

		private const float HeaderDragHeight = 28f;

		private const float TargetWindowWidth = 980f;

		private const float TargetWindowHeight = 760f;

		private const float ScreenMargin = 40f;

		private const float MinimumWindowWidth = 720f;

		private const float MinimumWindowHeight = 560f;

		private const float MinFlySpeed = 0.1f;

		private const float MaxFlySpeed = 100f;

		private const float FlyButtonMinWidth = 96f;

		private ManualLogSource? logger;

		private MovementToolsMenuSettings? menuSettings;

		private FlyModeSettings? flySettings;

		private MovementSpeedSettings? speedSettings;

		private TeleportMenuSettings? teleportSettings;

		private FlyModeController? flyController;

		private MovementSpeedMenu? speedMenu;

		private TeleportMenu? teleportMenu;

		private Rect windowRect = new Rect(40f, 60f, 980f, 760f);

		private bool visible;

		private int selectedTab;

		private string flySpeedInput = "10";

		private string statusMessage = "Movement tools ready.";

		public void Initialize(ManualLogSource pluginLogger, MovementToolsMenuSettings settings, FlyModeSettings fly, MovementSpeedSettings speed, TeleportMenuSettings teleport, FlyModeController flyMode, MovementSpeedMenu movementSpeed, TeleportMenu teleportPanel)
		{
			logger = pluginLogger;
			menuSettings = settings;
			flySettings = fly;
			speedSettings = speed;
			teleportSettings = teleport;
			flyController = flyMode;
			speedMenu = movementSpeed;
			teleportMenu = teleportPanel;
			SyncFlySpeedInput();
		}

		private void Update()
		{
			//IL_0014: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			if (menuSettings == null)
			{
				return;
			}
			if (Input.GetKeyDown(menuSettings.ToggleMenuKey.Value))
			{
				visible = !visible;
				if (visible)
				{
					PrepareSelectedTab();
				}
			}
			if (speedSettings != null && Input.GetKeyDown(speedSettings.ToggleKey.Value))
			{
				OpenMenu(0);
				speedMenu?.ShowPanel();
			}
			if (teleportSettings != null && Input.GetKeyDown(teleportSettings.ToggleMenuKey.Value))
			{
				OpenMenu(1);
				teleportMenu?.ShowPanel();
			}
		}

		private void OnGUI()
		{
			//IL_0017: 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_0032: Expected O, but got Unknown
			//IL_002d: 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)
			if (visible)
			{
				ResizeWindowToScreen();
				windowRect = GUI.Window(((Object)this).GetInstanceID(), windowRect, new WindowFunction(DrawWindow), "Movement Tools");
				((Rect)(ref windowRect)).x = Mathf.Clamp(((Rect)(ref windowRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref windowRect)).width));
				((Rect)(ref windowRect)).y = Mathf.Clamp(((Rect)(ref windowRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - 28f));
			}
		}

		private void DrawWindow(int windowId)
		{
			//IL_002e: 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)
			GUILayout.Label("Movement Tools", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Menu key: {menuSettings?.ToggleMenuKey.Value}", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			int num = GUILayout.Toolbar(selectedTab, tabs, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(34f) });
			if (num != selectedTab)
			{
				selectedTab = num;
				PrepareSelectedTab();
			}
			GUILayout.EndVertical();
			GUILayout.Space(10f);
			if (selectedTab == 0)
			{
				DrawMovementSection();
			}
			else
			{
				DrawTeleportSection(((Rect)(ref windowRect)).height - 190f);
			}
			GUILayout.FlexibleSpace();
			GUILayout.Label(statusMessage, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Close", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) }))
			{
				visible = false;
			}
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref windowRect)).width, 28f));
		}

		private void DrawFlySection()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.Label("Fly", Array.Empty<GUILayoutOption>());
			FlyModeController? flyModeController = flyController;
			GUILayout.Label((flyModeController != null && flyModeController.IsFlyModeEnabled) ? "Fly mode: ON" : "Fly mode: OFF", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Fly speed: {flySettings?.FlySpeed.Value:0.###}", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Shortcut: {flySettings?.ToggleKey.Value}", Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.Label("New fly speed", Array.Empty<GUILayoutOption>());
			flySpeedInput = GUILayout.TextField(flySpeedInput, 16, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Apply Speed", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.MinWidth(96f),
				GUILayout.Height(28f)
			}))
			{
				ApplyFlySpeed();
			}
			if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.MinWidth(96f),
				GUILayout.Height(28f)
			}))
			{
				SyncFlySpeedInput();
				statusMessage = "Fly speed reloaded.";
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			FlyModeController? flyModeController2 = flyController;
			if (GUILayout.Button((flyModeController2 != null && flyModeController2.IsFlyModeEnabled) ? "Turn Fly Off" : "Turn Fly On", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(32f) }))
			{
				flyController?.ToggleFlyModeFromMenu();
				FlyModeController? flyModeController3 = flyController;
				statusMessage = ((flyModeController3 != null && flyModeController3.IsFlyModeEnabled) ? "Fly mode turned on." : "Fly mode turned off.");
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogInfo((object)statusMessage);
				}
			}
			GUILayout.EndVertical();
		}

		private void DrawSpeedSection()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.Label("Speed", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Speed panel key: {speedSettings?.ToggleKey.Value}", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			speedMenu?.DrawPanel();
			GUILayout.EndVertical();
		}

		private void DrawMovementSection()
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(320f) });
			DrawFlySection();
			GUILayout.EndVertical();
			GUILayout.Space(12f);
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			DrawSpeedSection();
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private void DrawTeleportSection(float sectionHeight)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(GUIStyle.op_Implicit("box"), Array.Empty<GUILayoutOption>());
			GUILayout.Label("Teleport", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Teleport panel key: {teleportSettings?.ToggleMenuKey.Value}", Array.Empty<GUILayoutOption>());
			GUILayout.Label($"Max saved locations: {teleportSettings?.MaxLocations.Value}", Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			teleportMenu?.DrawPanel(sectionHeight);
			GUILayout.EndVertical();
		}

		private void OpenMenu(int tabIndex)
		{
			visible = true;
			selectedTab = Mathf.Clamp(tabIndex, 0, tabs.Length - 1);
			PrepareSelectedTab();
			statusMessage = "Movement tools opened.";
		}

		private void PrepareSelectedTab()
		{
			if (selectedTab == 0)
			{
				SyncFlySpeedInput();
				speedMenu?.ShowPanel();
			}
			else
			{
				teleportMenu?.ShowPanel();
			}
		}

		private void ApplyFlySpeed()
		{
			if (flySettings == null)
			{
				statusMessage = "Fly settings were not found.";
				return;
			}
			if (!float.TryParse(flySpeedInput, out var result))
			{
				statusMessage = "Fly speed must be a number. Example: 12";
				return;
			}
			result = Mathf.Clamp(result, 0.1f, 100f);
			flySettings.FlySpeed.Value = result;
			flySpeedInput = result.ToString("0.###");
			statusMessage = "Applied fly speed: " + flySpeedInput;
			ManualLogSource? obj = logger;
			if (obj != null)
			{
				obj.LogInfo((object)statusMessage);
			}
		}

		private void SyncFlySpeedInput()
		{
			flySpeedInput = flySettings?.FlySpeed.Value.ToString("0.###") ?? "10";
		}

		private void ResizeWindowToScreen()
		{
			float num = Mathf.Max(720f, (float)Screen.width - 40f);
			float num2 = Mathf.Max(560f, (float)Screen.height - 40f);
			((Rect)(ref windowRect)).width = Mathf.Min(980f, num);
			((Rect)(ref windowRect)).height = Mathf.Min(760f, num2);
		}
	}
	[BepInPlugin("uta_a.supermarkettogether.movementtools", "Supermarket Together Movement Tools", "0.1.0")]
	public sealed class MovementToolsPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "uta_a.supermarkettogether.movementtools";

		public const string PluginName = "Supermarket Together Movement Tools";

		public const string PluginVersion = "0.1.0";

		private void Awake()
		{
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			MovementToolsMenuSettings movementToolsMenuSettings = new MovementToolsMenuSettings(((BaseUnityPlugin)this).Config.Bind<KeyCode>("Menu", "ToggleMenuKey", (KeyCode)287, "Key used to show or hide the movement tools menu."));
			FlyModeSettings flyModeSettings = new FlyModeSettings(((BaseUnityPlugin)this).Config.Bind<KeyCode>("Fly", "ToggleKey", (KeyCode)103, "Key used to toggle fly mode."), ((BaseUnityPlugin)this).Config.Bind<float>("Fly", "FlySpeed", 10f, "Fly movement speed in meters per second."));
			MovementSpeedSettings movementSpeedSettings = new MovementSpeedSettings(((BaseUnityPlugin)this).Config.Bind<KeyCode>("Speed", "ToggleKey", (KeyCode)290, "Key used to open the movement tools menu for speed controls."), ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "DefaultMoveSpeed", 5f, "Move speed shown before the player controller is found."), ((BaseUnityPlugin)this).Config.Bind<float>("Speed", "DefaultSprintSpeed", 10f, "Sprint speed shown before the player controller is found."));
			TeleportMenuSettings teleportMenuSettings = new TeleportMenuSettings(((BaseUnityPlugin)this).Config.Bind<KeyCode>("Teleport", "ToggleMenuKey", (KeyCode)291, "Key used to open the movement tools menu for teleport controls."), ((BaseUnityPlugin)this).Config.Bind<int>("Teleport", "MaxLocations", 20, "Maximum number of saved teleport locations."));
			FlyModeController flyModeController = ((Component)this).gameObject.AddComponent<FlyModeController>();
			MovementSpeedMenu movementSpeedMenu = ((Component)this).gameObject.AddComponent<MovementSpeedMenu>();
			TeleportMenu teleportMenu = ((Component)this).gameObject.AddComponent<TeleportMenu>();
			flyModeController.Initialize(((BaseUnityPlugin)this).Logger, flyModeSettings);
			movementSpeedMenu.Initialize(((BaseUnityPlugin)this).Logger, movementSpeedSettings);
			teleportMenu.Initialize(((BaseUnityPlugin)this).Logger, teleportMenuSettings, Paths.ConfigPath);
			((Component)this).gameObject.AddComponent<MovementToolsMenu>().Initialize(((BaseUnityPlugin)this).Logger, movementToolsMenuSettings, flyModeSettings, movementSpeedSettings, teleportMenuSettings, flyModeController, movementSpeedMenu, teleportMenu);
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Press {2} to open the movement tools menu.", "Supermarket Together Movement Tools", "0.1.0", movementToolsMenuSettings.ToggleMenuKey.Value));
		}
	}
	internal sealed class MovementToolsMenuSettings
	{
		public ConfigEntry<KeyCode> ToggleMenuKey { get; }

		public MovementToolsMenuSettings(ConfigEntry<KeyCode> toggleMenuKey)
		{
			ToggleMenuKey = toggleMenuKey;
		}
	}
}
namespace SupermarketTogetherMovementSpeedMenu
{
	internal sealed class MovementSpeedMenu : MonoBehaviour
	{
		private const string WindowTitle = "Movement Speed";

		private const float MinSpeed = 0.1f;

		private const float MaxSpeed = 100f;

		private const float ButtonMinWidth = 96f;

		private ManualLogSource? logger;

		private MovementSpeedSettings? settings;

		private FirstPersonController? cachedFirstPersonController;

		private string moveSpeedInput = "5";

		private string sprintSpeedInput = "10";

		private string statusMessage = "Waiting for player controller...";

		public void Initialize(ManualLogSource pluginLogger, MovementSpeedSettings speedSettings)
		{
			logger = pluginLogger;
			settings = speedSettings;
			moveSpeedInput = speedSettings.DefaultMoveSpeed.Value.ToString("0.###");
			sprintSpeedInput = speedSettings.DefaultSprintSpeed.Value.ToString("0.###");
		}

		internal void ShowPanel()
		{
			SyncInputsWithCurrentSpeeds();
		}

		internal void DrawPanel()
		{
			GUILayout.Label("Movement Speed", Array.Empty<GUILayoutOption>());
			FirstPersonController firstPersonController = GetFirstPersonController();
			string text = (((Object)(object)firstPersonController != (Object)null) ? firstPersonController.MoveSpeed.ToString("0.###") : "(player controller not found)");
			string text2 = (((Object)(object)firstPersonController != (Object)null) ? firstPersonController.SprintSpeed.ToString("0.###") : "(player controller not found)");
			GUILayout.Label("Current move speed: " + text, Array.Empty<GUILayoutOption>());
			GUILayout.Label("New move speed", Array.Empty<GUILayoutOption>());
			moveSpeedInput = GUILayout.TextField(moveSpeedInput, 16, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("Current sprint speed: " + text2, Array.Empty<GUILayoutOption>());
			GUILayout.Label("New sprint speed", Array.Empty<GUILayoutOption>());
			sprintSpeedInput = GUILayout.TextField(sprintSpeedInput, 16, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Apply", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.MinWidth(96f),
				GUILayout.Height(28f)
			}))
			{
				ApplySpeeds();
			}
			if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.MinWidth(96f),
				GUILayout.Height(28f)
			}))
			{
				cachedFirstPersonController = null;
				SyncInputsWithCurrentSpeeds();
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			GUILayout.Label(statusMessage, Array.Empty<GUILayoutOption>());
		}

		private void ApplySpeeds()
		{
			FirstPersonController firstPersonController = GetFirstPersonController();
			float speed;
			float speed2;
			if ((Object)(object)firstPersonController == (Object)null)
			{
				statusMessage = "Player controller was not found. Load into the game first.";
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogWarning((object)statusMessage);
				}
			}
			else if (TryParseSpeed(moveSpeedInput, "Move speed", out speed) && TryParseSpeed(sprintSpeedInput, "Sprint speed", out speed2))
			{
				firstPersonController.MoveSpeed = speed;
				firstPersonController.SprintSpeed = speed2;
				moveSpeedInput = speed.ToString("0.###");
				sprintSpeedInput = speed2.ToString("0.###");
				statusMessage = "Applied move: " + moveSpeedInput + ", sprint: " + sprintSpeedInput;
				ManualLogSource? obj2 = logger;
				if (obj2 != null)
				{
					obj2.LogInfo((object)statusMessage);
				}
			}
		}

		private bool TryParseSpeed(string input, string label, out float speed)
		{
			if (!float.TryParse(input, out speed))
			{
				statusMessage = label + " must be a number. Example: 12";
				return false;
			}
			speed = Mathf.Clamp(speed, 0.1f, 100f);
			return true;
		}

		private void SyncInputsWithCurrentSpeeds()
		{
			FirstPersonController firstPersonController = GetFirstPersonController();
			if ((Object)(object)firstPersonController == (Object)null)
			{
				moveSpeedInput = settings?.DefaultMoveSpeed.Value.ToString("0.###") ?? "5";
				sprintSpeedInput = settings?.DefaultSprintSpeed.Value.ToString("0.###") ?? "10";
				statusMessage = "Waiting for player controller...";
			}
			else
			{
				moveSpeedInput = firstPersonController.MoveSpeed.ToString("0.###");
				sprintSpeedInput = firstPersonController.SprintSpeed.ToString("0.###");
				statusMessage = "Ready.";
			}
		}

		private FirstPersonController? GetFirstPersonController()
		{
			if ((Object)(object)cachedFirstPersonController != (Object)null)
			{
				return cachedFirstPersonController;
			}
			cachedFirstPersonController = FirstPersonController.Instance;
			return cachedFirstPersonController;
		}
	}
	internal sealed class MovementSpeedSettings
	{
		public ConfigEntry<KeyCode> ToggleKey { get; }

		public ConfigEntry<float> DefaultMoveSpeed { get; }

		public ConfigEntry<float> DefaultSprintSpeed { get; }

		public MovementSpeedSettings(ConfigEntry<KeyCode> toggleKey, ConfigEntry<float> defaultMoveSpeed, ConfigEntry<float> defaultSprintSpeed)
		{
			ToggleKey = toggleKey;
			DefaultMoveSpeed = defaultMoveSpeed;
			DefaultSprintSpeed = defaultSprintSpeed;
		}
	}
}
namespace SupermarketTogetherFlyMod
{
	internal sealed class FlyModeController : MonoBehaviour
	{
		private ManualLogSource? logger;

		private FlyModeSettings? settings;

		private FirstPersonController? firstPersonController;

		private CharacterController? characterController;

		private bool flyModeEnabled;

		private bool originalFirstPersonEnabled;

		private bool originalCharacterControllerEnabled;

		internal bool IsFlyModeEnabled => flyModeEnabled;

		public void Initialize(ManualLogSource pluginLogger, FlyModeSettings flySettings)
		{
			logger = pluginLogger;
			settings = flySettings;
		}

		internal void ToggleFlyModeFromMenu()
		{
			RefreshPlayerReferences();
			ToggleFlyMode();
		}

		private void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (settings != null)
			{
				RefreshPlayerReferences();
				if (Input.GetKeyDown(settings.ToggleKey.Value))
				{
					ToggleFlyMode();
				}
				if (flyModeEnabled && !((Object)(object)firstPersonController == (Object)null))
				{
					MovePlayer();
				}
			}
		}

		private void RefreshPlayerReferences()
		{
			if ((Object)(object)firstPersonController != (Object)null)
			{
				return;
			}
			firstPersonController = FirstPersonController.Instance;
			if (!((Object)(object)firstPersonController == (Object)null))
			{
				characterController = ((Component)firstPersonController).GetComponent<CharacterController>();
				originalFirstPersonEnabled = ((Behaviour)firstPersonController).enabled;
				originalCharacterControllerEnabled = (Object)(object)characterController == (Object)null || ((Collider)characterController).enabled;
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogInfo((object)"Found local FirstPersonController.");
				}
			}
		}

		private void ToggleFlyMode()
		{
			if ((Object)(object)firstPersonController == (Object)null)
			{
				ManualLogSource? obj = logger;
				if (obj != null)
				{
					obj.LogWarning((object)"Cannot toggle fly mode because the local player is not available yet.");
				}
				return;
			}
			flyModeEnabled = !flyModeEnabled;
			if (flyModeEnabled)
			{
				originalFirstPersonEnabled = ((Behaviour)firstPersonController).enabled;
				originalCharacterControllerEnabled = (Object)(object)characterController == (Object)null || ((Collider)characterController).enabled;
				((Behaviour)firstPersonController).enabled = false;
				if ((Object)(object)characterController != (Object)null)
				{
					((Collider)characterController).enabled = false;
				}
			}
			else
			{
				((Behaviour)firstPersonController).enabled = originalFirstPersonEnabled;
				if ((Object)(object)characterController != (Object)null)
				{
					((Collider)characterController).enabled = originalCharacterControllerEnabled;
				}
			}
			ManualLogSource? obj2 = logger;
			if (obj2 != null)
			{
				obj2.LogInfo((object)("Fly mode " + (flyModeEnabled ? "enabled" : "disabled") + "."));
			}
		}

		private void MovePlayer()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0064: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00a1: 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_00b0: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			if (settings != null && !((Object)(object)firstPersonController == (Object)null))
			{
				Transform obj = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : ((Component)firstPersonController).transform);
				Vector3 val = Vector3.ProjectOnPlane(obj.forward, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				val = Vector3.ProjectOnPlane(obj.right, Vector3.up);
				Vector3 normalized2 = ((Vector3)(ref val)).normalized;
				Vector3 val2 = Vector3.zero;
				if (Input.GetKey((KeyCode)119))
				{
					val2 += normalized;
				}
				if (Input.GetKey((KeyCode)115))
				{
					val2 -= normalized;
				}
				if (Input.GetKey((KeyCode)100))
				{
					val2 += normalized2;
				}
				if (Input.GetKey((KeyCode)97))
				{
					val2 -= normalized2;
				}
				if (Input.GetKey((KeyCode)32))
				{
					val2 += Vector3.up;
				}
				if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))
				{
					val2 -= Vector3.up;
				}
				if (!(((Vector3)(ref val2)).sqrMagnitude <= 0f))
				{
					Vector3 val3 = ((Vector3)(ref val2)).normalized * settings.FlySpeed.Value * Time.deltaTime;
					Transform transform = ((Component)firstPersonController).transform;
					transform.position += val3;
				}
			}
		}

		private void OnDestroy()
		{
			if (flyModeEnabled && (Object)(object)firstPersonController != (Object)null)
			{
				((Behaviour)firstPersonController).enabled = originalFirstPersonEnabled;
				if ((Object)(object)characterController != (Object)null)
				{
					((Collider)characterController).enabled = originalCharacterControllerEnabled;
				}
			}
		}
	}
	internal sealed class FlyModeSettings
	{
		public ConfigEntry<KeyCode> ToggleKey { get; }

		public ConfigEntry<float> FlySpeed { get; }

		public FlyModeSettings(ConfigEntry<KeyCode> toggleKey, ConfigEntry<float> flySpeed)
		{
			ToggleKey = toggleKey;
			FlySpeed = flySpeed;
		}
	}
}