Decompiled source of AdminMenu v0.1.11

AdminMenu.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using AdminMenu.Patches;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using Steamworks;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UIElements;

[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("AdminMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.11.0")]
[assembly: AssemblyInformationalVersion("0.1.11+036203fcb07a8aee577e74077e43ac6b7336c3e9")]
[assembly: AssemblyProduct("AdminMenu")]
[assembly: AssemblyTitle("AdminMenu")]
[assembly: AssemblyVersion("0.1.11.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AdminMenu
{
	internal static class Access
	{
		private const string MemberKey = "darkharasho.adminmenu";

		private const string AdminsKey = "darkharasho.adminmenu.admins";

		private static bool _trustedClient;

		private static bool? _hostHadMod;

		private static float _nextLobbyCheck;

		private static AdminRoster _roster;

		private static string _rosterSource;

		public static bool Allowed
		{
			get
			{
				if (!NetworkServer.active && NetworkClient.active)
				{
					return _trustedClient;
				}
				return true;
			}
		}

		public static bool RoutesThroughHost
		{
			get
			{
				if (!NetworkServer.active && NetworkClient.active && _trustedClient)
				{
					return HostHasMod();
				}
				return false;
			}
		}

		public static bool CanGrant => NetworkServer.active;

		public static AdminRoster Roster
		{
			get
			{
				string text = ((Plugin.SavedAdmins != null) ? Plugin.SavedAdmins.Value : string.Empty);
				if (_roster == null || text != _rosterSource)
				{
					_roster = AdminRoster.Parse(text);
					_rosterSource = text;
				}
				return _roster;
			}
		}

		public static void Update()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0042: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_0132: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime < _nextLobbyCheck)
			{
				return;
			}
			_nextLobbyCheck = Time.unscaledTime + 2f;
			CSteamID val = LobbyId();
			if (val.m_SteamID == 0L)
			{
				_trustedClient = false;
				_hostHadMod = null;
				return;
			}
			CSteamID steamID = SteamUser.GetSteamID();
			if (string.IsNullOrEmpty(SteamMatchmaking.GetLobbyMemberData(val, steamID, "darkharasho.adminmenu")))
			{
				SteamMatchmaking.SetLobbyMemberData(val, "darkharasho.adminmenu", "0.1.11");
			}
			if (NetworkServer.active)
			{
				RefreshNames();
				string text = TrustList.Format(TrustedIds());
				if (SteamMatchmaking.GetLobbyOwner(val) == steamID && SteamMatchmaking.GetLobbyData(val, "darkharasho.adminmenu.admins") != text)
				{
					SteamMatchmaking.SetLobbyData(val, "darkharasho.adminmenu.admins", text);
				}
				return;
			}
			bool flag = HostHasMod();
			if (flag != _hostHadMod)
			{
				CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(val);
				Plugin.Log.LogInfo((object)($"Host {lobbyOwner.m_SteamID} (connected to {NetworkManager.singleton?.networkAddress}) " + (flag ? "runs the admin menu; host-side actions go through it" : "doesn't run the admin menu (no lobby flag); Bring and stats are unavailable")));
				_hostHadMod = flag;
			}
			bool flag2 = (flag ? Parse(SteamMatchmaking.GetLobbyData(val, "darkharasho.adminmenu.admins")) : TrustedIds()).Contains(steamID.m_SteamID);
			if (flag2 != _trustedClient)
			{
				Plugin.Log.LogInfo((object)(flag2 ? "Trusted admin in this lobby" : "Not a trusted admin in this lobby; the menu is host-only"));
			}
			_trustedClient = flag2;
		}

		public static bool IsTrusted(NetworkConnectionToClient sender)
		{
			if (sender == null)
			{
				return false;
			}
			if ((object)sender == NetworkServer.localConnection)
			{
				return true;
			}
			if (ulong.TryParse(sender.address, out var result))
			{
				return TrustedIds().Contains(result);
			}
			return false;
		}

		public static bool IsGranted(FirstPersonController player)
		{
			if ((Object)(object)player != (Object)null)
			{
				return Roster.Contains(player.playerID);
			}
			return false;
		}

		public static void SetGranted(FirstPersonController player, bool granted)
		{
			if (CanGrant && !((Object)(object)player == (Object)null) && player.playerID != 0L && (!granted || HasMod(player)) && (granted ? Grant(player.playerID, player.playerName) : Revoke(player.playerID)))
			{
				Plugin.Log.LogInfo((object)string.Format("{0} admin for {1} ({2})", granted ? "Granted" : "Revoked", player.playerName, player.playerID));
			}
		}

		public static bool Grant(ulong steamId, string playerName)
		{
			return Save(Roster.Set(steamId, playerName));
		}

		public static bool Revoke(ulong steamId)
		{
			return Save(Roster.Remove(steamId));
		}

		private static bool Save(bool changed)
		{
			if (!changed)
			{
				return false;
			}
			_rosterSource = _roster.Format();
			if (Plugin.SavedAdmins != null)
			{
				Plugin.SavedAdmins.Value = _rosterSource;
			}
			_nextLobbyCheck = 0f;
			return true;
		}

		private static void RefreshNames()
		{
			if (Roster.Ids.Count() == 0)
			{
				return;
			}
			foreach (FirstPersonController item in PlayerActions.Players())
			{
				if ((Object)(object)item != (Object)null && item.playerID != 0L && !string.IsNullOrEmpty(item.playerName) && Roster.Contains(item.playerID))
				{
					Save(Roster.Set(item.playerID, item.playerName));
				}
			}
		}

		public static bool HostHasMod()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			CSteamID val = LobbyId();
			if (val.m_SteamID != 0L)
			{
				return HasMod(SteamMatchmaking.GetLobbyOwner(val));
			}
			return false;
		}

		public static bool HostVersionAtLeast(string minimum)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_0011: 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_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_0020: Unknown result type (might be due to invalid IL or missing references)
			CSteamID val = LobbyId();
			if (val.m_SteamID == 0L)
			{
				return false;
			}
			CSteamID lobbyOwner = SteamMatchmaking.GetLobbyOwner(val);
			if (lobbyOwner.m_SteamID != 0L)
			{
				return ModVersion.AtLeast(SteamMatchmaking.GetLobbyMemberData(val, lobbyOwner, "darkharasho.adminmenu"), minimum);
			}
			return false;
		}

		public static bool HasMod(FirstPersonController player)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player != (Object)null)
			{
				if (!((NetworkBehaviour)player).isLocalPlayer)
				{
					return HasMod(new CSteamID(player.playerID));
				}
				return true;
			}
			return false;
		}

		private static bool HasMod(CSteamID member)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			CSteamID val = LobbyId();
			if (val.m_SteamID != 0L && member.m_SteamID != 0L)
			{
				return !string.IsNullOrEmpty(SteamMatchmaking.GetLobbyMemberData(val, member, "darkharasho.adminmenu"));
			}
			return false;
		}

		private static HashSet<ulong> TrustedIds()
		{
			return TrustList.Resolve(Plugin.TrustedAdmins.Value, "76561197987892075", Roster.Ids);
		}

		private static HashSet<ulong> Parse(string list)
		{
			return TrustList.Parse(list);
		}

		private static CSteamID LobbyId()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!SteamManager.Initialized || (Object)(object)SteamLobby.Instance == (Object)null)
				{
					return CSteamID.Nil;
				}
				return new CSteamID(SteamLobby.Instance.currentLobbyID);
			}
			catch (Exception)
			{
				return CSteamID.Nil;
			}
		}
	}
	internal static class AdminMenuController
	{
		private static AdminMenuPanel _panel;

		private static Hud _attachedHud;

		private static InputState _stateBeforeOpen;

		private static bool _owesRestore;

		public static bool IsOpen
		{
			get
			{
				if (_panel != null && _panel.IsOpen)
				{
					return _panel.Root.panel != null;
				}
				return false;
			}
		}

		public static void Toggle()
		{
			if (IsOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}

		private static void Open()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (Attach())
			{
				if ((Object)(object)InputManager.Instance != (Object)null)
				{
					_stateBeforeOpen = InputManager.Instance.CurrentInputState;
					InputManager.Instance.SetState((InputState)13, true);
				}
				_panel.Open();
				VisualElement root = _panel.Root;
				root.schedule.Execute((Action)delegate
				{
					((Focusable)root).Focus();
				}).ExecuteLater(0L);
			}
		}

		public static void Close()
		{
			if (_panel != null && _panel.IsOpen)
			{
				_panel.Close();
				if ((Object)(object)InputManager.Instance != (Object)null)
				{
					_owesRestore = !RestoreInputState(InputManager.Instance);
				}
			}
		}

		public static void Update()
		{
			//IL_0033: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			if (!_owesRestore || IsOpen)
			{
				return;
			}
			InputManager instance = InputManager.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)GameManager.Instance == (Object)null)
			{
				_owesRestore = false;
				return;
			}
			InputState currentInputState = instance.CurrentInputState;
			if ((int)currentInputState == 13)
			{
				_owesRestore = !RestoreInputState(instance);
				Plugin.Log.LogInfo((object)"Restored input left in GeneralMenu by a menu that opened over the admin menu");
			}
			else if ((int)currentInputState == 2 || (int)currentInputState == 4)
			{
				_owesRestore = false;
			}
		}

		private static bool RestoreInputState(InputManager input)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			MenuInputState? menuInputState = MenuGate.StateToRestore(((int)input.CurrentInputState == 13) ? MenuInputState.Menu : MenuInputState.Other, LocalPlayerIsDead());
			if (!menuInputState.HasValue)
			{
				return false;
			}
			input.SetState((InputState)((menuInputState == MenuInputState.Dead) ? 4 : 2), true);
			return true;
		}

		private static bool LocalPlayerIsDead()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			FirstPersonController val = PlayerActions.LocalPlayer();
			if ((Object)(object)val == (Object)null || (Object)(object)val.PlayerStats == (Object)null)
			{
				return (int)_stateBeforeOpen == 4;
			}
			return val.PlayerStats.isDead;
		}

		private static bool Attach()
		{
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			Hud instance = Hud.Instance;
			VisualElement val = (((Object)(object)instance != (Object)null && (Object)(object)instance.hudDocument != (Object)null) ? instance.hudDocument.rootVisualElement : null);
			if (val == null)
			{
				Plugin.Log.LogWarning((object)"No HUD document yet; the admin menu cannot open here.");
				return false;
			}
			if (_panel == null)
			{
				_panel = new AdminMenuPanel();
				_panel.CloseRequested += Close;
				Action refresh;
				VisualElement content = PlayersTab.Build(out refresh);
				_panel.AddTab("Players", content, refresh);
				Action refresh2;
				VisualElement content2 = ItemsTab.Build(out refresh2);
				_panel.AddTab("Items", content2, refresh2);
				Action refresh3;
				VisualElement content3 = ResourcesTab.Build(out refresh3);
				_panel.AddTab("Resources", content3, refresh3);
				Action refresh4;
				VisualElement content4 = CheatsTab.Build(out refresh4);
				_panel.AddTab("Cheats", content4, refresh4);
				Action refresh5;
				VisualElement content5 = AdminsTab.Build(out refresh5);
				_panel.AddTab("Admins", content5, refresh5);
			}
			if (_panel.Root.panel == null || (Object)(object)_attachedHud != (Object)(object)instance)
			{
				_panel.Root.RemoveFromHierarchy();
				val.Add(_panel.Root);
				_panel.Root.style.position = StyleEnum<Position>.op_Implicit((Position)1);
				_panel.Root.BringToFront();
				_attachedHud = instance;
			}
			return true;
		}
	}
	internal sealed class AdminMenuPanel
	{
		private sealed class Tab
		{
			public Button Button;

			public VisualElement Content;

			public Action OnShown;
		}

		private readonly VisualElement _overlay;

		private readonly VisualElement _rail;

		private readonly VisualElement _content;

		private readonly List<Tab> _tabs = new List<Tab>();

		private Tab _selected;

		public VisualElement Root => _overlay;

		public bool IsOpen { get; private set; }

		public event Action CloseRequested;

		public AdminMenuPanel()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0056: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0071: 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_009c: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00fb: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Expected O, but got Unknown
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Expected O, but got Unknown
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			_overlay = new VisualElement
			{
				name = "AdminMenuOverlay"
			};
			IStyle style = _overlay.style;
			style.position = StyleEnum<Position>.op_Implicit((Position)1);
			style.left = (style.right = (style.top = (style.bottom = StyleLength.op_Implicit(0f))));
			style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
			style.backgroundColor = StyleColor.op_Implicit(new Color(0f, 0f, 0f, 0.7f));
			style.color = StyleColor.op_Implicit(Theme.Text);
			style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			((Focusable)_overlay).focusable = true;
			((CallbackEventHandler)_overlay).RegisterCallback<KeyDownEvent>((EventCallback<KeyDownEvent>)delegate(KeyDownEvent evt)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				if ((int)((KeyboardEventBase<KeyDownEvent>)(object)evt).keyCode == 27 && Plugin.CloseOnEscape.Value)
				{
					((EventBase)evt).StopPropagation();
					this.CloseRequested?.Invoke();
				}
			}, (TrickleDown)1);
			VisualElement val4 = new VisualElement
			{
				name = "AdminMenuWindow"
			};
			IStyle style2 = val4.style;
			style2.width = StyleLength.op_Implicit(Length.Percent(72f));
			style2.height = StyleLength.op_Implicit(Length.Percent(78f));
			style2.maxWidth = StyleLength.op_Implicit(1200f);
			style2.backgroundColor = StyleColor.op_Implicit(Theme.Window);
			Theme.SetBorder(val4, 3f, Theme.WindowBorder, 0f);
			Theme.SetPadding(val4, 20f, 24f);
			_overlay.Add(val4);
			VisualElement val5 = Row();
			val5.style.marginBottom = StyleLength.op_Implicit(16f);
			Label val6 = new Label("ADMIN MENU");
			((VisualElement)val6).style.fontSize = StyleLength.op_Implicit(34f);
			((VisualElement)val6).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
			((VisualElement)val6).style.color = StyleColor.op_Implicit(Theme.Text);
			((VisualElement)val6).style.textShadow = StyleTextShadow.op_Implicit(new TextShadow
			{
				offset = new Vector2(2f, 2f),
				color = Color.black
			});
			((VisualElement)val6).style.flexGrow = StyleFloat.op_Implicit(1f);
			val5.Add((VisualElement)(object)val6);
			Button val7 = new Button((Action)delegate
			{
				this.CloseRequested?.Invoke();
			})
			{
				text = "Close"
			};
			((VisualElement)val7).style.marginLeft = StyleLength.op_Implicit(20f);
			((VisualElement)val7).style.minWidth = StyleLength.op_Implicit(110f);
			Theme.StyleButton(val7);
			val5.Add((VisualElement)(object)val7);
			val4.Add(val5);
			VisualElement val8 = Row();
			val8.style.flexGrow = StyleFloat.op_Implicit(1f);
			val8.style.flexShrink = StyleFloat.op_Implicit(1f);
			val8.style.alignItems = StyleEnum<Align>.op_Implicit((Align)4);
			val4.Add(val8);
			_rail = new VisualElement
			{
				name = "AdminMenuTabs"
			};
			_rail.style.width = StyleLength.op_Implicit(180f);
			_rail.style.flexShrink = StyleFloat.op_Implicit(0f);
			_rail.style.marginRight = StyleLength.op_Implicit(20f);
			_rail.style.paddingRight = StyleLength.op_Implicit(16f);
			_rail.style.borderRightWidth = StyleFloat.op_Implicit(2f);
			_rail.style.borderRightColor = StyleColor.op_Implicit(Theme.Line);
			val8.Add(_rail);
			_content = new VisualElement
			{
				name = "AdminMenuContent"
			};
			_content.style.flexGrow = StyleFloat.op_Implicit(1f);
			_content.style.flexShrink = StyleFloat.op_Implicit(1f);
			val8.Add(_content);
			Theme.StyleControls(_overlay);
		}

		public void AddTab(string title, VisualElement content, Action onShown)
		{
			//IL_0011: 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_001e: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_0085: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if (content != null)
			{
				Button val = new Button
				{
					text = title
				};
				Theme.StyleButton(val, outlined: false);
				((VisualElement)val).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
				IStyle style = ((VisualElement)val).style;
				StyleLength marginLeft = (((VisualElement)val).style.marginRight = StyleLength.op_Implicit(0f));
				style.marginLeft = marginLeft;
				((VisualElement)val).style.marginBottom = StyleLength.op_Implicit(8f);
				IStyle style2 = ((VisualElement)val).style;
				marginLeft = (((VisualElement)val).style.paddingBottom = StyleLength.op_Implicit(10f));
				style2.paddingTop = marginLeft;
				_rail.Add((VisualElement)(object)val);
				content.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
				content.style.flexGrow = StyleFloat.op_Implicit(1f);
				_content.Add(content);
				Theme.StyleControls(content);
				Tab tab = new Tab
				{
					Button = val,
					Content = content,
					OnShown = onShown
				};
				_tabs.Add(tab);
				val.clicked += delegate
				{
					Select(tab);
				};
				if (_selected == null)
				{
					Select(tab);
				}
				else
				{
					Highlight();
				}
			}
		}

		public void Open()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			_overlay.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0);
			_overlay.BringToFront();
			IsOpen = true;
			if (_selected != null)
			{
				Show(_selected);
			}
		}

		public void Close()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (IsOpen)
			{
				IsOpen = false;
				_overlay.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1);
			}
		}

		private void Select(Tab tab)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			_selected = tab;
			foreach (Tab tab2 in _tabs)
			{
				tab2.Content.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)((tab2 != tab) ? 1 : 0));
			}
			Highlight();
			Show(tab);
		}

		private void Highlight()
		{
			//IL_0031: 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)
			foreach (Tab tab in _tabs)
			{
				Theme.SetBorder((VisualElement)(object)tab.Button, 2f, (tab == _selected) ? Theme.Gold : Theme.Line, 4f);
			}
		}

		private static void Show(Tab tab)
		{
			tab.OnShown?.Invoke();
		}

		private static VisualElement Row()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			VisualElement val = new VisualElement();
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			return val;
		}
	}
	internal struct AdminEntry
	{
		public ulong Id;

		public string Name;
	}
	internal sealed class AdminRoster
	{
		private const char EntrySeparator = ',';

		private const char NameSeparator = '=';

		private static readonly char[] Separators = new char[2] { ',', ';' };

		private readonly Dictionary<ulong, string> _admins = new Dictionary<ulong, string>();

		public IEnumerable<ulong> Ids => _admins.Keys;

		public IEnumerable<AdminEntry> Entries => from admin in _admins.OrderBy<KeyValuePair<ulong, string>, string>((KeyValuePair<ulong, string> admin) => admin.Value, StringComparer.CurrentCultureIgnoreCase).ThenBy((KeyValuePair<ulong, string> admin) => admin.Key)
			select new AdminEntry
			{
				Id = admin.Key,
				Name = admin.Value
			};

		public static AdminRoster Parse(string stored)
		{
			AdminRoster adminRoster = new AdminRoster();
			if (string.IsNullOrEmpty(stored))
			{
				return adminRoster;
			}
			string[] array = stored.Split(Separators, StringSplitOptions.RemoveEmptyEntries);
			foreach (string text in array)
			{
				int num = text.IndexOf('=');
				string obj = ((num < 0) ? text : text.Substring(0, num));
				string name = ((num < 0) ? string.Empty : text.Substring(num + 1));
				if (ulong.TryParse(obj.Trim(), out var result) && result != 0L)
				{
					adminRoster._admins[result] = Clean(name);
				}
			}
			return adminRoster;
		}

		public string Format()
		{
			return string.Join(','.ToString(), from admin in _admins
				orderby admin.Key
				select (admin.Value.Length != 0) ? (admin.Key + "=" + admin.Value) : admin.Key.ToString());
		}

		public bool Contains(ulong id)
		{
			return _admins.ContainsKey(id);
		}

		public string NameOf(ulong id)
		{
			if (!_admins.TryGetValue(id, out var value))
			{
				return string.Empty;
			}
			return value;
		}

		public bool Set(ulong id, string name)
		{
			if (id == 0L)
			{
				return false;
			}
			string text = Clean(name);
			if (_admins.TryGetValue(id, out var value) && value == text)
			{
				return false;
			}
			_admins[id] = text;
			return true;
		}

		public bool Remove(ulong id)
		{
			return _admins.Remove(id);
		}

		private static string Clean(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return string.Empty;
			}
			string text = name;
			char[] array = new char[3] { ',', '=', ';' };
			foreach (char oldChar in array)
			{
				text = text.Replace(oldChar, ' ');
			}
			return text.Trim();
		}
	}
	internal static class AdminsTab
	{
		private const int TickMilliseconds = 500;

		public static VisualElement Build(out Action refresh)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			VisualElement root = new VisualElement();
			Label note = new Label();
			((VisualElement)note).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)note).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0);
			((VisualElement)note).style.marginBottom = StyleLength.op_Implicit(12f);
			root.Add((VisualElement)(object)note);
			ScrollView scrollView = new ScrollView();
			((VisualElement)scrollView).style.flexGrow = StyleFloat.op_Implicit(1f);
			root.Add((VisualElement)(object)scrollView);
			string shown = null;
			bool? shownHost = null;
			root.schedule.Execute((Action)delegate
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (AdminMenuController.IsOpen && (int)root.resolvedStyle.display == 0)
				{
					Tick();
				}
			}).Every(500L);
			refresh = delegate
			{
				Tick(forceRebuild: true);
			};
			return root;
			void Rebuild()
			{
				((VisualElement)scrollView).Clear();
				((TextElement)note).text = (Access.CanGrant ? "Everyone who can use the admin menu in your games. Elevate players from the Players tab; revoke here, whether or not they're online." : "Only the host's list decides who can use the admin menu, so there's nothing to change here. This is the list your own games would use.");
				List<AdminEntry> list = Access.Roster.Entries.ToList();
				AddSection((VisualElement)(object)scrollView, "Granted from the menu", (list.Count > 0) ? null : "Nobody yet. Use Elevate on a player's row in the Players tab.");
				foreach (AdminEntry item in list)
				{
					ulong id = item.Id;
					AddRow((VisualElement)(object)scrollView, item.Name, id, Access.CanGrant ? "Revoke" : null, delegate
					{
						Access.Revoke(id);
					});
				}
				List<ulong> list2 = (from result2 in TrustList.Parse(Plugin.TrustedAdmins.Value)
					where result2.ToString() != "76561197987892075"
					orderby result2
					select result2).ToList();
				AddSection((VisualElement)(object)scrollView, "From the config", (list2.Count > 0) ? "Edit the TrustedAdmins setting to change these. Use it for somebody who has never been in your lobby." : "The TrustedAdmins setting is empty. Use it to add somebody who has never been in your lobby.");
				foreach (ulong item2 in list2)
				{
					AddRow((VisualElement)(object)scrollView, NameFor(item2), item2, null, null);
				}
				AddSection((VisualElement)(object)scrollView, "Mod author", "Always an admin, on every install; see the README.");
				if (ulong.TryParse("76561197987892075", out var result))
				{
					AddRow((VisualElement)(object)scrollView, "darkharasho", result, null, null);
				}
			}
			void Tick(bool forceRebuild = false)
			{
				string text = Access.Roster.Format() + "\n" + Plugin.TrustedAdmins.Value;
				bool canGrant = Access.CanGrant;
				if (forceRebuild || !(text == shown) || canGrant != shownHost)
				{
					shown = text;
					shownHost = canGrant;
					Rebuild();
				}
			}
		}

		private static string NameFor(ulong steamId)
		{
			FirstPersonController val = ((IEnumerable<FirstPersonController>)PlayerActions.Players()).FirstOrDefault((Func<FirstPersonController, bool>)((FirstPersonController p) => (Object)(object)p != (Object)null && p.playerID == steamId));
			if (!((Object)(object)val != (Object)null))
			{
				return string.Empty;
			}
			return val.playerName;
		}

		private static void AddSection(VisualElement root, string title, string description)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Label val = new Label(title);
			((VisualElement)val).style.color = StyleColor.op_Implicit(Theme.Gold);
			((VisualElement)val).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
			((VisualElement)val).style.marginTop = StyleLength.op_Implicit((root.childCount > 0) ? 16f : 0f);
			root.Add((VisualElement)(object)val);
			if (description != null)
			{
				Label val2 = new Label(description);
				((VisualElement)val2).style.color = StyleColor.op_Implicit(Theme.Muted);
				((VisualElement)val2).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0);
				((VisualElement)val2).style.marginBottom = StyleLength.op_Implicit(4f);
				root.Add((VisualElement)(object)val2);
			}
		}

		private static void AddRow(VisualElement root, string name, ulong steamId, string action, Action onAction)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			VisualElement val = new VisualElement
			{
				name = "AdminRow"
			};
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.marginTop = StyleLength.op_Implicit(6f);
			val.style.paddingBottom = StyleLength.op_Implicit(6f);
			val.style.borderBottomWidth = StyleFloat.op_Implicit(1f);
			val.style.borderBottomColor = StyleColor.op_Implicit(Theme.Line);
			Label val2 = new Label(string.IsNullOrEmpty(name) ? "(unknown player)" : name);
			((VisualElement)val2).style.color = StyleColor.op_Implicit(string.IsNullOrEmpty(name) ? Theme.Muted : Theme.Text);
			((VisualElement)val2).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
			((VisualElement)val2).style.width = StyleLength.op_Implicit(200f);
			((VisualElement)val2).style.flexShrink = StyleFloat.op_Implicit(1f);
			val.Add((VisualElement)(object)val2);
			Label val3 = new Label(steamId.ToString());
			((VisualElement)val3).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)val3).style.flexGrow = StyleFloat.op_Implicit(1f);
			val.Add((VisualElement)(object)val3);
			if (action != null && onAction != null)
			{
				Button val4 = new Button(onAction)
				{
					text = action
				};
				Theme.StyleButton(val4);
				val.Add((VisualElement)(object)val4);
			}
			root.Add(val);
		}
	}
	internal static class Cheats
	{
		public const string StrengthSource = "AdminMenu.SuperPickaxe";

		public const string SpeedSource = "AdminMenu.SuperSpeedPickaxe";

		private const float StrengthMultiplier = 25f;

		public const float SpeedMultiplier = 3f;

		private static readonly StatModifier StrengthModifier = new StatModifier(24f, (StatModType)2, "AdminMenu.SuperPickaxe");

		public const float VanillaDigSize = 0.35f;

		public const float BombDigSize = 1.5f;

		public const float VanillaReach = 3f;

		public const float MaxReach = 20f;

		private const float HealIntervalSeconds = 0.25f;

		private static bool _strengthApplied;

		private static bool _speedApplied;

		private static float _nextHealTime;

		public static bool GodModeActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return Plugin.GodMode.Value;
				}
				return false;
			}
		}

		public static bool InfiniteStaminaActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return Plugin.InfiniteStamina.Value;
				}
				return false;
			}
		}

		public static bool InfiniteAmmoActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return Plugin.InfiniteAmmo.Value;
				}
				return false;
			}
		}

		private static bool SuperPickaxeActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return Plugin.SuperPickaxe.Value;
				}
				return false;
			}
		}

		public static bool SuperSpeedPickaxeActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return Plugin.SuperSpeedPickaxe.Value;
				}
				return false;
			}
		}

		public static bool QuickOfferActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return Plugin.QuickOffer.Value;
				}
				return false;
			}
		}

		public static bool BombPickaxeActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return PickaxeDigSize > 0.35f;
				}
				return false;
			}
		}

		public static float PickaxeDigSize => Plugin.PickaxeDigSize.Value;

		public static bool PickaxeReachActive
		{
			get
			{
				if (Plugin.Enabled.Value && Access.Allowed)
				{
					return PickaxeReach > 3f;
				}
				return false;
			}
		}

		public static float PickaxeReach => Plugin.PickaxeReach.Value;

		public static void Update()
		{
			FirstPersonController val = PlayerActions.LocalPlayer();
			if ((Object)(object)val == (Object)null || (Object)(object)val.PlayerStats == (Object)null)
			{
				_strengthApplied = false;
				_speedApplied = false;
				return;
			}
			PlayerStats playerStats = val.PlayerStats;
			float num = PlayerActions.MaxHealthOf(playerStats);
			if (GodModeActive && !playerStats.isDead && playerStats.GetCurrentHealth() < num && Time.unscaledTime >= _nextHealTime)
			{
				playerStats.CmdUpdateHealth(num - playerStats.GetCurrentHealth());
				_nextHealTime = Time.unscaledTime + 0.25f;
			}
			ApplyPickaxe(val);
		}

		public static void ApplyPickaxe(FirstPersonController player)
		{
			PlayerStats playerStats = player.PlayerStats;
			if (playerStats.DigStrength != null && playerStats.DiggingSpeed != null && playerStats.HeavyDigMultiplier != null)
			{
				Apply(SuperPickaxeActive, StrengthModifier, "AdminMenu.SuperPickaxe", ref _strengthApplied, $"Super pickaxe (x{25f} strength)", playerStats.DigStrength, playerStats.HeavyDigMultiplier);
				playerStats.DiggingSpeed.RemoveAllModifiersFromSource("AdminMenu.SuperSpeedPickaxe");
				bool superSpeedPickaxeActive = SuperSpeedPickaxeActive;
				if (superSpeedPickaxeActive != _speedApplied)
				{
					Plugin.Log.LogInfo((object)string.Format("Super speed pickaxe (x{0} speed) {1}", 3f, superSpeedPickaxeActive ? "on" : "off"));
					_speedApplied = superSpeedPickaxeActive;
					playerStats.OnDiggingSpeedChanged?.Invoke(playerStats.syncDiggingSpeed);
				}
			}
		}

		private static void Apply(bool wanted, StatModifier mod, string source, ref bool applied, string logName, params CharacterStat[] targets)
		{
			foreach (CharacterStat val in targets)
			{
				if (wanted)
				{
					val.AddOrReplaceModifier(mod);
				}
				else
				{
					val.RemoveAllModifiersFromSource(source);
				}
			}
			if (wanted != applied)
			{
				Plugin.Log.LogInfo((object)(logName + " " + (wanted ? "on" : "off")));
			}
			applied = wanted;
		}
	}
	internal static class CheatsTab
	{
		public static VisualElement Build(out Action refresh)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			VisualElement val = new VisualElement();
			Toggle superPickaxeToggle = BuildRow(val, "Super pickaxe", Plugin.SuperPickaxe);
			Toggle superSpeedPickaxeToggle = BuildRow(val, "Super speed pickaxe", Plugin.SuperSpeedPickaxe);
			Toggle quickOfferToggle = BuildRow(val, "Quick offer", Plugin.QuickOffer);
			Slider digSizeSlider = BuildSliderRow(val, "Pickaxe dig size", Plugin.PickaxeDigSize);
			Slider reachSlider = BuildSliderRow(val, "Pickaxe reach", Plugin.PickaxeReach);
			Toggle infiniteStaminaToggle = BuildRow(val, "Infinite stamina", Plugin.InfiniteStamina);
			Toggle infiniteAmmoToggle = BuildRow(val, "Infinite arrows & bombs", Plugin.InfiniteAmmo);
			Toggle godModeToggle = BuildRow(val, "God mode", Plugin.GodMode);
			refresh = Refresh;
			return val;
			void Refresh()
			{
				((BaseField<bool>)(object)superPickaxeToggle).value = Plugin.SuperPickaxe.Value;
				((BaseField<bool>)(object)superSpeedPickaxeToggle).value = Plugin.SuperSpeedPickaxe.Value;
				((BaseField<bool>)(object)quickOfferToggle).value = Plugin.QuickOffer.Value;
				((BaseField<float>)(object)digSizeSlider).value = Plugin.PickaxeDigSize.Value;
				((BaseField<float>)(object)reachSlider).value = Plugin.PickaxeReach.Value;
				((BaseField<bool>)(object)infiniteStaminaToggle).value = Plugin.InfiniteStamina.Value;
				((BaseField<bool>)(object)infiniteAmmoToggle).value = Plugin.InfiniteAmmo.Value;
				((BaseField<bool>)(object)godModeToggle).value = Plugin.GodMode.Value;
			}
		}

		private static Toggle BuildRow(VisualElement root, string title, ConfigEntry<bool> entry)
		{
			//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_003a: Expected O, but got Unknown
			//IL_003b: Expected O, but got Unknown
			VisualElement obj = BuildRowShell(root, title, ((ConfigEntryBase)entry).Description.Description);
			Toggle val = new Toggle();
			((BaseField<bool>)val).value = entry.Value;
			Toggle val2 = val;
			INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)val2, (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> evt)
			{
				entry.Value = evt.newValue;
			});
			obj.Add((VisualElement)(object)val2);
			return val2;
		}

		private static Slider BuildSliderRow(VisualElement root, string title, ConfigEntry<float> entry)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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_00dd: Expected O, but got Unknown
			//IL_00de: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			AcceptableValueRange<float> val = (AcceptableValueRange<float>)(object)((ConfigEntryBase)entry).Description.AcceptableValues;
			VisualElement obj = BuildRowShell(root, title, ((ConfigEntryBase)entry).Description.Description);
			Label value = new Label();
			((VisualElement)value).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)value).style.minWidth = StyleLength.op_Implicit(34f);
			((VisualElement)value).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)5);
			((VisualElement)value).style.marginRight = StyleLength.op_Implicit(6f);
			obj.Add((VisualElement)(object)value);
			Slider val2 = new Slider(val.MinValue, val.MaxValue, (SliderDirection)0, 0f);
			((BaseField<float>)val2).value = entry.Value;
			Slider val3 = val2;
			((VisualElement)val3).style.width = StyleLength.op_Implicit(120f);
			INotifyValueChangedExtensions.RegisterValueChangedCallback<float>((INotifyValueChanged<float>)(object)val3, (EventCallback<ChangeEvent<float>>)delegate(ChangeEvent<float> evt)
			{
				entry.Value = evt.newValue;
				((TextElement)value).text = evt.newValue.ToString("0.00", CultureInfo.InvariantCulture);
			});
			((TextElement)value).text = entry.Value.ToString("0.00", CultureInfo.InvariantCulture);
			obj.Add((VisualElement)(object)val3);
			return val3;
		}

		private static VisualElement BuildRowShell(VisualElement root, string title, string description)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0018: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00e4: Expected O, but got Unknown
			//IL_00ea: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement
			{
				name = "CheatRow"
			};
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.marginBottom = StyleLength.op_Implicit(10f);
			val.style.paddingBottom = StyleLength.op_Implicit(10f);
			val.style.borderBottomWidth = StyleFloat.op_Implicit(1f);
			val.style.borderBottomColor = StyleColor.op_Implicit(Theme.Line);
			VisualElement val2 = new VisualElement();
			val2.style.flexGrow = StyleFloat.op_Implicit(1f);
			val.Add(val2);
			Label val3 = new Label(title);
			((VisualElement)val3).style.color = StyleColor.op_Implicit(Theme.Text);
			((VisualElement)val3).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
			val2.Add((VisualElement)(object)val3);
			Label val4 = new Label(description);
			((VisualElement)val4).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)val4).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0);
			val2.Add((VisualElement)(object)val4);
			root.Add(val);
			return val;
		}
	}
	internal sealed class ConfigurationManagerAttributes
	{
		public string DispName;

		public int? Order;

		public bool? Browsable;
	}
	internal struct GodModeMessage : NetworkMessage
	{
		public bool Enabled;
	}
	internal static class GodModeGuard
	{
		private const float PruneIntervalSeconds = 2f;

		private static readonly ProtectedPlayers Protected;

		private static bool _handler;

		private static float _nextPrune;

		private static bool? _sentState;

		static GodModeGuard()
		{
			Protected = new ProtectedPlayers();
			Writer<GodModeMessage>.write = delegate(NetworkWriter writer, GodModeMessage message)
			{
				NetworkWriterExtensions.WriteBool(writer, message.Enabled);
			};
			Reader<GodModeMessage>.read = (NetworkReader reader) => new GodModeMessage
			{
				Enabled = NetworkReaderExtensions.ReadBool(reader)
			};
		}

		public static bool ShouldProtect(PlayerStats stats)
		{
			if ((Object)(object)stats == (Object)null || (Object)(object)stats.Player == (Object)null)
			{
				return false;
			}
			if (Cheats.GodModeActive && ((NetworkBehaviour)stats.Player).isLocalPlayer)
			{
				return true;
			}
			return IsProtectedByHost(stats);
		}

		private static bool IsProtectedByHost(PlayerStats stats)
		{
			if (!NetworkServer.active || Protected.Count == 0)
			{
				return false;
			}
			NetworkConnectionToClient connectionToClient = ((NetworkBehaviour)stats.Player).connectionToClient;
			if (connectionToClient != null)
			{
				return Protected.Contains(connectionToClient.connectionId);
			}
			return false;
		}

		public static void Update()
		{
			if (NetworkServer.active)
			{
				if (!_handler)
				{
					NetworkServer.ReplaceHandler<GodModeMessage>((Action<NetworkConnectionToClient, GodModeMessage>)OnGodModeRequest, true);
					_handler = true;
				}
				if (Protected.Count > 0 && Time.unscaledTime >= _nextPrune)
				{
					_nextPrune = Time.unscaledTime + 2f;
					Protected.PruneTo(StillTrustedConnectionIds());
				}
				_sentState = null;
				return;
			}
			if (_handler)
			{
				Protected.Clear();
				_handler = false;
			}
			if (!NetworkClient.active || !NetworkClient.isConnected)
			{
				_sentState = null;
				return;
			}
			bool godModeActive = Cheats.GodModeActive;
			if (_sentState != godModeActive)
			{
				NetworkClient.Send<GodModeMessage>(new GodModeMessage
				{
					Enabled = godModeActive
				}, 0);
				_sentState = godModeActive;
				Plugin.Log.LogInfo((object)("Asked the host to " + (godModeActive ? "hold god mode for us" : "stop holding god mode")));
			}
		}

		private static List<int> StillTrustedConnectionIds()
		{
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, NetworkConnectionToClient> connection in NetworkServer.connections)
			{
				if (connection.Value != null && Access.IsTrusted(connection.Value))
				{
					list.Add(connection.Key);
				}
			}
			return list;
		}

		private static void OnGodModeRequest(NetworkConnectionToClient sender, GodModeMessage message)
		{
			if (sender != null)
			{
				if (!Access.IsTrusted(sender))
				{
					Plugin.Log.LogWarning((object)("Ignored a god mode request from untrusted connection " + sender.address));
				}
				else if (Protected.Set(sender.connectionId, message.Enabled))
				{
					Plugin.Log.LogInfo((object)("God mode " + (message.Enabled ? "enforced" : "released") + " for connection " + sender.address));
				}
			}
		}
	}
	internal static class Hotkey
	{
		private static bool? _legacyAvailable;

		private static readonly Dictionary<KeyCode, Key> Renamed = new Dictionary<KeyCode, Key>
		{
			[(KeyCode)13] = (Key)2,
			[(KeyCode)271] = (Key)77,
			[(KeyCode)306] = (Key)55,
			[(KeyCode)305] = (Key)56,
			[(KeyCode)310] = (Key)57,
			[(KeyCode)309] = (Key)58,
			[(KeyCode)96] = (Key)4,
			[(KeyCode)270] = (Key)80,
			[(KeyCode)269] = (Key)81,
			[(KeyCode)268] = (Key)79,
			[(KeyCode)267] = (Key)78,
			[(KeyCode)266] = (Key)82
		};

		private static bool LegacyAvailable
		{
			get
			{
				if (!_legacyAvailable.HasValue)
				{
					try
					{
						Input.GetKey((KeyCode)0);
						_legacyAvailable = true;
					}
					catch (InvalidOperationException)
					{
						_legacyAvailable = false;
					}
					Plugin.Log.LogInfo((object)(_legacyAvailable.Value ? "Reading hotkeys through the legacy Input manager" : "Legacy Input manager is disabled; reading hotkeys through the Input System package"));
				}
				return _legacyAvailable.Value;
			}
		}

		public static bool WasPressed(KeyboardShortcut shortcut)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey == 0)
			{
				return false;
			}
			if (LegacyAvailable)
			{
				return ((KeyboardShortcut)(ref shortcut)).IsDown();
			}
			Keyboard current = Keyboard.current;
			if (current == null || !TryGetKey(((KeyboardShortcut)(ref shortcut)).MainKey, out var key) || !((ButtonControl)current[key]).wasPressedThisFrame)
			{
				return false;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers)
			{
				if (!TryGetKey(modifier, out var key2) || !((ButtonControl)current[key2]).isPressed)
				{
					return false;
				}
			}
			return true;
		}

		private unsafe static bool TryGetKey(KeyCode code, out Key key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			if (Renamed.TryGetValue(code, out key))
			{
				return true;
			}
			string text = ((object)(*(KeyCode*)(&code))/*cast due to .constrained prefix*/).ToString();
			if (text.StartsWith("Alpha"))
			{
				text = "Digit" + text.Substring("Alpha".Length);
			}
			else if (text.StartsWith("Keypad"))
			{
				text = "Numpad" + text.Substring("Keypad".Length);
			}
			if (Enum.TryParse<Key>(text, ignoreCase: true, out key))
			{
				return (int)key != 0;
			}
			return false;
		}
	}
	internal static class ItemCatalog
	{
		private static readonly Dictionary<string, ItemDataSO> ById = new Dictionary<string, ItemDataSO>();

		public static List<ItemEntry> All()
		{
			ById.Clear();
			ItemManager instance = ItemManager.Instance;
			ItemDatabaseSO val = (((Object)(object)instance == (Object)null) ? null : Traverse.Create((object)instance).Field<ItemDatabaseSO>("itemDataBase").Value);
			if ((Object)(object)val == (Object)null || val.items == null)
			{
				Plugin.Log.LogWarning((object)"Item database not available yet; load into the hub or a level first");
				return new List<ItemEntry>();
			}
			HashSet<string> hashSet = ResourceIds(val.items);
			List<ItemEntry> list = new List<ItemEntry>();
			foreach (ItemDataSO item in val.items.Where((ItemDataSO i) => (Object)(object)i != (Object)null && !string.IsNullOrEmpty(i.itemID) && !i.isScrapItem))
			{
				if (!ById.ContainsKey(item.itemID))
				{
					ById[item.itemID] = item;
					string localizedName = item.GetLocalizedName();
					list.Add(new ItemEntry
					{
						Id = item.itemID,
						Name = (string.IsNullOrEmpty(localizedName) ? item.itemID : localizedName),
						Rarity = ((object)Unsafe.As<Rarity, Rarity>(ref item.Rarity)/*cast due to .constrained prefix*/).ToString(),
						Stackable = item.isStackable,
						MaxStack = Mathf.Max(1, item.maxStackSize),
						IsResource = hashSet.Contains(item.itemID)
					});
				}
			}
			return list;
		}

		private static HashSet<string> ResourceIds(List<ItemDataSO> items)
		{
			HashSet<string> ids = new HashSet<string>();
			foreach (ItemDataSO item in items)
			{
				if (!((Object)(object)item == (Object)null))
				{
					if (item.isScrapItem)
					{
						Add(item);
						Add(item.itemProduced);
					}
					if (item.canBeExchanged)
					{
						AddRewards(item.level1ExchangeRewards);
						AddRewards(item.level2ExchangeRewards);
					}
				}
			}
			DigMatterProfileSO[] array = Resources.FindObjectsOfTypeAll<DigMatterProfileSO>();
			for (int i = 0; i < array.Length; i++)
			{
				if (!(Traverse.Create((object)array[i]).Field("resourceClusters").GetValue() is IEnumerable enumerable))
				{
					continue;
				}
				foreach (object item2 in enumerable)
				{
					Add(Traverse.Create(item2).Field<ItemDataSO>("resourceCluster").Value);
				}
			}
			return ids;
			void Add(ItemDataSO item)
			{
				if ((Object)(object)item != (Object)null && !string.IsNullOrEmpty(item.itemID))
				{
					ids.Add(item.itemID);
				}
			}
			void AddRewards(ExchangeResourceList list)
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				if (list?.items == null)
				{
					return;
				}
				foreach (ExchangeResource item3 in list.items)
				{
					Add(item3.item);
				}
			}
		}

		public static Sprite IconFor(string id)
		{
			if (id == null || !ById.TryGetValue(id, out var value) || (Object)(object)value == (Object)null)
			{
				return null;
			}
			return value.itemIcon;
		}

		public static void Spawn(ItemEntry item, int count, bool toInventory)
		{
			if (item == null || count < 1)
			{
				return;
			}
			int num = ((!item.Stackable) ? 1 : item.MaxStack);
			for (int num2 = count; num2 > 0; num2 -= num)
			{
				int count2 = Mathf.Min(num2, num);
				if (toInventory)
				{
					SpawnToInventory(item, count2);
				}
				else
				{
					SpawnToGround(item, count2);
				}
			}
			Plugin.Log.LogInfo((object)string.Format("Spawned {0}x {1} {2}", count, item.Id, toInventory ? "into the inventory" : "on the ground"));
		}

		public static List<ChestDataSO> Chests()
		{
			ItemManager instance = ItemManager.Instance;
			ItemDatabaseSO val = (((Object)(object)instance == (Object)null) ? null : Traverse.Create((object)instance).Field<ItemDatabaseSO>("itemDataBase").Value);
			if ((Object)(object)val == (Object)null || val.carriables == null)
			{
				return new List<ChestDataSO>();
			}
			return (from c in val.carriables.OfType<ChestDataSO>()
				where (Object)(object)c != (Object)null && !string.IsNullOrEmpty(((CarriableDataSO)c).Id)
				orderby c.Rarity
				select c).ToList();
		}

		public static string ChestLabel(ChestDataSO chest)
		{
			//IL_0019: 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_0045: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			string text = ((CarriableDataSO)chest).GetLocalizedName();
			if (string.IsNullOrEmpty(text))
			{
				text = ((CarriableDataSO)chest).Id;
			}
			string text2 = null;
			try
			{
				text2 = ItemDataSO.GetRarityLocalizedString(chest.Rarity, false);
			}
			catch (Exception)
			{
			}
			if (string.IsNullOrEmpty(text2) || text2.StartsWith("RARITY_"))
			{
				text2 = ((object)chest.Rarity/*cast due to .constrained prefix*/).ToString().Substring(0, 1) + ((object)chest.Rarity/*cast due to .constrained prefix*/).ToString().Substring(1).ToLowerInvariant();
			}
			if (text.IndexOf(text2, StringComparison.OrdinalIgnoreCase) < 0)
			{
				return text2 + " " + text;
			}
			return text;
		}

		public static Color RarityColor(Rarity rarity)
		{
			//IL_0000: 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_0018: Expected I4, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			return (Color)((rarity - 1) switch
			{
				0 => new Color(0.49f, 0.85f, 0.42f), 
				1 => new Color(0.36f, 0.85f, 0.92f), 
				2 => new Color(0.87f, 0.45f, 0.93f), 
				3 => new Color(1f, 0.65f, 0.25f), 
				_ => new Color(0.8f, 0.8f, 0.82f), 
			});
		}

		public static void SpawnChest(ChestDataSO chest)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController val = PlayerActions.LocalPlayer();
			if (!((Object)(object)chest == (Object)null) && !((Object)(object)val == (Object)null) && !((Object)(object)ItemManager.Instance == (Object)null) && PlayerActions.ActionsAllowed)
			{
				Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 2f + Vector3.up;
				ItemManager.Instance.CmdInstantiateCarriableObject(((CarriableDataSO)chest).Id, val2);
				Plugin.Log.LogInfo((object)("Spawned chest " + ((CarriableDataSO)chest).Id));
			}
		}

		private static void SpawnToInventory(ItemEntry item, int count)
		{
			FirstPersonController val = PlayerActions.LocalPlayer();
			if (item != null && !((Object)(object)val == (Object)null) && PlayerActions.ActionsAllowed)
			{
				val.CmdForcePickupItem(val, count, item.Id);
			}
		}

		private static void SpawnToGround(ItemEntry item, int count)
		{
			//IL_002d: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			FirstPersonController val = PlayerActions.LocalPlayer();
			if (item != null && !((Object)(object)val == (Object)null) && !((Object)(object)ItemManager.Instance == (Object)null) && PlayerActions.ActionsAllowed)
			{
				Vector3 val2 = ((Component)val).transform.position + ((Component)val).transform.forward * 1.5f;
				ItemManager.Instance.CmdInstantiatePickableNewItem(item.Id, count, val2);
			}
		}
	}
	internal sealed class ItemEntry
	{
		public string Id;

		public string Name;

		public string Rarity;

		public bool Stackable;

		public int MaxStack = 1;

		public bool IsResource;
	}
	internal static class ItemSearch
	{
		public static List<ItemEntry> Filter(IEnumerable<ItemEntry> items, string search)
		{
			IEnumerable<ItemEntry> source = items ?? Enumerable.Empty<ItemEntry>();
			string term = (search ?? string.Empty).Trim();
			if (term.Length == 0)
			{
				return source.OrderBy<ItemEntry, string>((ItemEntry i) => i.Name, StringComparer.OrdinalIgnoreCase).ToList();
			}
			return (from x in (from item in source
					select new
					{
						item = item,
						rank = Rank(item, term)
					} into x
					where x.rank < int.MaxValue
					orderby x.rank
					select x).ThenBy(x => x.item.Name, StringComparer.OrdinalIgnoreCase)
				select x.item).ToList();
		}

		private static int Rank(ItemEntry item, string term)
		{
			if (EqualsTerm(item.Name, term))
			{
				return 0;
			}
			if (StartsWith(item.Name, term))
			{
				return 1;
			}
			if (Contains(item.Name, term))
			{
				return 2;
			}
			if (Contains(item.Id, term))
			{
				return 3;
			}
			return int.MaxValue;
		}

		private static bool EqualsTerm(string text, string term)
		{
			if (text != null)
			{
				return string.Equals(text, term, StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		private static bool StartsWith(string text, string term)
		{
			return text?.StartsWith(term, StringComparison.OrdinalIgnoreCase) ?? false;
		}

		private static bool Contains(string text, string term)
		{
			if (text != null)
			{
				return text.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}
	}
	internal static class ItemsTab
	{
		private const int MaxResults = 200;

		private const int MaxAmount = 999;

		public static VisualElement Build(out Action refresh)
		{
			return Build(null, out refresh);
		}

		public static VisualElement Build(Func<ItemEntry, bool> include, out Action refresh)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0035: 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_005b: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00b9: Expected O, but got Unknown
			//IL_00c9: 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_00ef: Expected O, but got Unknown
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01b2: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Expected O, but got Unknown
			List<ItemEntry> all = new List<ItemEntry>();
			VisualElement val = new VisualElement();
			VisualElement val2 = new VisualElement
			{
				name = "ItemsToolbar"
			};
			val2.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val2.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val2.style.marginBottom = StyleLength.op_Implicit(12f);
			val.Add(val2);
			VisualElement val3 = new VisualElement();
			val3.style.flexGrow = StyleFloat.op_Implicit(1f);
			val3.style.marginRight = StyleLength.op_Implicit(12f);
			val2.Add(val3);
			TextField val4 = new TextField();
			((BaseField<string>)val4).value = string.Empty;
			TextField search = val4;
			((VisualElement)search).style.flexGrow = StyleFloat.op_Implicit(1f);
			val3.Add((VisualElement)(object)search);
			Label placeholder = new Label("Search by name or item ID…");
			((VisualElement)placeholder).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)placeholder).style.position = StyleEnum<Position>.op_Implicit((Position)1);
			((VisualElement)placeholder).style.left = StyleLength.op_Implicit(8f);
			((VisualElement)placeholder).style.top = StyleLength.op_Implicit(0f);
			((VisualElement)placeholder).style.bottom = StyleLength.op_Implicit(0f);
			((VisualElement)placeholder).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)3);
			((VisualElement)placeholder).pickingMode = (PickingMode)1;
			val3.Add((VisualElement)(object)placeholder);
			Toggle val5 = new Toggle("Spawn into inventory");
			((BaseField<bool>)val5).value = true;
			Toggle toInventory = val5;
			val2.Add((VisualElement)(object)toInventory);
			ScrollView scrollView = new ScrollView();
			((VisualElement)scrollView).style.flexGrow = StyleFloat.op_Implicit(1f);
			val.Add((VisualElement)(object)scrollView);
			INotifyValueChangedExtensions.RegisterValueChangedCallback<string>((INotifyValueChanged<string>)(object)search, (EventCallback<ChangeEvent<string>>)delegate(ChangeEvent<string> evt)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				((VisualElement)placeholder).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!string.IsNullOrEmpty(evt.newValue)));
				RenderResults();
			});
			refresh = Refresh;
			return val;
			void Refresh()
			{
				all.Clear();
				List<ItemEntry> list = all;
				IEnumerable<ItemEntry> collection;
				if (include != null)
				{
					collection = ItemCatalog.All().Where(include);
				}
				else
				{
					IEnumerable<ItemEntry> enumerable = ItemCatalog.All();
					collection = enumerable;
				}
				list.AddRange(collection);
				RenderResults();
			}
			void RenderResults()
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Expected O, but got Unknown
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Expected O, but got Unknown
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				((VisualElement)scrollView).Clear();
				if (!PlayerActions.ActionsAllowed)
				{
					Label val6 = new Label("Host-only actions is on and you are not the host.");
					((VisualElement)val6).style.color = StyleColor.op_Implicit(Theme.Muted);
					((VisualElement)val6).style.marginBottom = StyleLength.op_Implicit(12f);
					((VisualElement)scrollView).Add((VisualElement)(object)val6);
				}
				List<ItemEntry> list = ItemSearch.Filter(all, ((BaseField<string>)(object)search).value);
				int num = 0;
				foreach (ItemEntry item in list)
				{
					if (num >= 200)
					{
						Label val7 = new Label("… more results; refine the search");
						((VisualElement)val7).style.color = StyleColor.op_Implicit(Theme.Muted);
						((VisualElement)scrollView).Add((VisualElement)(object)val7);
						break;
					}
					VisualElement val8 = BuildRow(item, toInventory);
					Theme.StyleControls(val8);
					((VisualElement)scrollView).Add(val8);
					num++;
				}
			}
		}

		private static VisualElement BuildRow(ItemEntry item, Toggle toInventory)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Expected O, but got Unknown
			//IL_0231: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected O, but got Unknown
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			VisualElement val = new VisualElement
			{
				name = "ItemRow"
			};
			val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2);
			val.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
			val.style.marginBottom = StyleLength.op_Implicit(10f);
			val.style.paddingBottom = StyleLength.op_Implicit(10f);
			val.style.borderBottomWidth = StyleFloat.op_Implicit(1f);
			val.style.borderBottomColor = StyleColor.op_Implicit(Theme.Line);
			VisualElement val2 = new VisualElement
			{
				name = "ItemIcon"
			};
			val2.style.width = StyleLength.op_Implicit(32f);
			val2.style.height = StyleLength.op_Implicit(32f);
			val2.style.marginRight = StyleLength.op_Implicit(12f);
			val2.style.flexShrink = StyleFloat.op_Implicit(0f);
			Sprite val3 = ItemCatalog.IconFor(item.Id);
			if ((Object)(object)val3 != (Object)null)
			{
				val2.style.backgroundImage = new StyleBackground(val3);
			}
			val.Add(val2);
			Label val4 = new Label(item.Name);
			((VisualElement)val4).style.color = StyleColor.op_Implicit(Theme.Text);
			((VisualElement)val4).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
			((VisualElement)val4).style.width = StyleLength.op_Implicit(220f);
			((VisualElement)val4).style.flexGrow = StyleFloat.op_Implicit(1f);
			val.Add((VisualElement)(object)val4);
			Label val5 = new Label(item.Rarity);
			((VisualElement)val5).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)val5).style.width = StyleLength.op_Implicit(100f);
			val.Add((VisualElement)(object)val5);
			Label val6 = new Label("x");
			((VisualElement)val6).style.color = StyleColor.op_Implicit(Theme.Muted);
			((VisualElement)val6).style.marginRight = StyleLength.op_Implicit(4f);
			val.Add((VisualElement)(object)val6);
			IntegerField val7 = new IntegerField();
			((BaseField<int>)val7).value = 1;
			IntegerField amount = val7;
			((VisualElement)amount).style.width = StyleLength.op_Implicit(60f);
			((VisualElement)amount).style.marginRight = StyleLength.op_Implicit(12f);
			val.Add((VisualElement)(object)amount);
			Button val8 = new Button((Action)delegate
			{
				int num = Mathf.Clamp(((BaseField<int>)(object)amount).value, 1, 999);
				if (((BaseField<int>)(object)amount).value != num)
				{
					((BaseField<int>)(object)amount).value = num;
				}
				ItemCatalog.Spawn(item, num, ((BaseField<bool>)(object)toInventory).value);
			})
			{
				text = "Spawn"
			};
			Theme.StyleButton(val8);
			((VisualElement)val8).SetEnabled(PlayerActions.ActionsAllowed);
			val.Add((VisualElement)(object)val8);
			return val;
		}
	}
	internal enum MenuInputState
	{
		None,
		Gameplay,
		Inventory,
		Dead,
		Menu,
		Other
	}
	internal static class MenuGate
	{
		public static bool CanToggle(bool pluginEnabled, bool inGame, MenuInputState state, bool menuOpen)
		{
			if (menuOpen)
			{
				return true;
			}
			if (!pluginEnabled || !inGame)
			{
				return false;
			}
			if (state != MenuInputState.Gameplay && state != MenuInputState.Inventory)
			{
				return state == MenuInputState.Dead;
			}
			return true;
		}

		public static MenuInputState? StateToRestore(MenuInputState current, bool localPlayerDead)
		{
			if (current != MenuInputState.Menu)
			{
				return null;
			}
			return (!localPlayerDead) ? MenuInputState.Gameplay : MenuInputState.Dead;
		}
	}
	internal sealed class OfferBudget
	{
		private readonly int _capacity;

		private readonly float _window;

		private readonly Queue<KeyValuePair<float, int>> _sent = new Queue<KeyValuePair<float, int>>();

		private int _inFlight;

		public OfferBudget(int capacity, float window)
		{
			_capacity = capacity;
			_window = window;
		}

		public int Take(float now, int wanted)
		{
			while (_sent.Count > 0 && now - _sent.Peek().Key >= _window)
			{
				_inFlight -= _sent.Dequeue().Value;
			}
			int num = Math.Min(wanted, _capacity - _inFlight);
			if (num <= 0)
			{
				return 0;
			}
			_sent.Enqueue(new KeyValuePair<float, int>(now, num));
			_inFlight += num;
			return num;
		}
	}
	internal static class ModVersion
	{
		public static bool AtLeast(string version, string minimum)
		{
			if (Version.TryParse(version, out Version result) && Version.TryParse(minimum, out Version result2))
			{
				return result >= result2;
			}
			return false;
		}
	}
	internal struct BringRequestMessage : NetworkMessage
	{
		public uint NetId;
	}
	internal static class PlayerActions
	{
		private static bool _bringHandler;

		private const float CampfireSpawnRange = 40f;

		private const int SpotCloserRings = 1;

		private const int SpotsPerRing = 8;

		private const float FloorSearchDepth = 1.5f;

		private const float FitTolerance = 0.95f;

		private static int _solidMask;

		private static int _solidMaskLayer;

		public static bool ActionsAllowed
		{
			get
			{
				if (Plugin.Enabled.Value)
				{
					return Access.Allowed;
				}
				return false;
			}
		}

		public static bool CanBring
		{
			get
			{
				if (!NetworkServer.active)
				{
					return Access.RoutesThroughHost;
				}
				return true;
			}
		}

		static PlayerActions()
		{
			_solidMaskLayer = -1;
			Writer<BringRequestMessage>.write = delegate(NetworkWriter writer, BringRequestMessage message)
			{
				NetworkWriterExtensions.WriteUInt(writer, message.NetId);
			};
			Reader<BringRequestMessage>.read = (NetworkReader reader) => new BringRequestMessage
			{
				NetId = NetworkReaderExtensions.ReadUInt(reader)
			};
		}

		public static void Update()
		{
			if (NetworkServer.active && !_bringHandler)
			{
				NetworkServer.ReplaceHandler<BringRequestMessage>((Action<NetworkConnectionToClient, BringRequestMessage>)OnBringRequest, true);
				_bringHandler = true;
			}
			else if (!NetworkServer.active)
			{
				_bringHandler = false;
			}
		}

		public static List<FirstPersonController> Players()
		{
			return (from p in FirstPersonController.LocalPlayers
				where (Object)(object)p != (Object)null && (Object)(object)p.PlayerStats != (Object)null
				orderby p.playerName
				select p).ToList();
		}

		public static FirstPersonController LocalPlayer()
		{
			List<FirstPersonController> localPlayers = FirstPersonController.LocalPlayers;
			if (localPlayers == null)
			{
				return null;
			}
			for (int i = 0; i < localPlayers.Count; i++)
			{
				FirstPersonController val = localPlayers[i];
				if ((Object)(object)val != (Object)null && ((NetworkBehaviour)val).isLocalPlayer)
				{
					return val;
				}
			}
			return null;
		}

		public static void Kill(FirstPersonController player)
		{
			if (ActionsAllowed && !((Object)(object)player == (Object)null) && !((Object)(object)player.PlayerStats == (Object)null) && !player.PlayerStats.isDead)
			{
				player.PlayerStats.CmdDebugForceIsDead(player, true);
				Plugin.Log.LogInfo((object)("Killed " + player.playerName));
			}
		}

		public static void Revive(FirstPersonController player)
		{
			//IL_0032: 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_007c: 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)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			if (ActionsAllowed && !((Object)(object)player == (Object)null) && !((Object)(object)player.PlayerStats == (Object)null) && player.PlayerStats.isDead)
			{
				Vector3 val = ((Component)player).transform.position;
				FirstPersonController val2 = CarrierOf(player);
				if ((Object)(object)val2 != (Object)null)
				{
					val = ((Component)val2).transform.position + ((Component)val2).transform.forward;
					val2.CmdReleaseDeadPlayer(val2, player, val);
					val2.PlayerEquipment.CmdSetCarriedDeadPlayer((string)null, (FirstPersonController)null);
				}
				player.CmdUseReviveTool(player, val, 1f);
				Plugin.Log.LogInfo((object)("Revived " + player.playerName));
			}
		}

		private static FirstPersonController CarrierOf(FirstPersonController deadPlayer)
		{
			if ((Object)(object)deadPlayer.PlayerCarryHandler == (Object)null || !deadPlayer.PlayerCarryHandler.IsCarried)
			{
				return null;
			}
			foreach (FirstPersonController item in Players())
			{
				if ((Object)(object)item != (Object)null && (Object)(object)item.PlayerEquipment != (Object)null && (Object)(object)item.PlayerEquipment.DeadPlayerCarried == (Object)(object)deadPlayer)
				{
					return item;
				}
			}
			return null;
		}

		public static void Heal(FirstPersonController player)
		{
			if (ActionsAllowed && !((Object)(object)player == (Object)null) && !((Object)(object)player.PlayerStats == (Object)null))
			{
				PlayerStats playerStats = player.PlayerStats;
				playerStats.CmdUpdateHealth(MaxHealthOf(playerStats) - playerStats.GetCurrentHealth());
				Plugin.Log.LogInfo((object)("Healed " + player.playerName));
			}
		}

		public static void TeleportTo(FirstPersonController target)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController val = LocalPlayer();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)target == (Object)null) && !((Object)(object)target == (Object)(object)val) && MoveSelf(SpotNear(((Component)target).transform.position, -((Component)target).transform.forward, val)))
			{
				Plugin.Log.LogInfo((object)("Teleported to " + target.playerName));
			}
		}

		public static CampFire Campfire()
		{
			if (!((Object)(object)LevelManager.Instance != (Object)null))
			{
				return null;
			}
			return LevelManager.Instance.CampFire;
		}

		public static void TeleportToCampfire()
		{
			//IL_003b: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			CampFire val = Campfire();
			if (!((Object)(object)val == (Object)null))
			{
				Transform val2 = (((Object)(object)GameManager.Instance != (Object)null) ? GameManager.Instance.playerSpawn : null);
				FirstPersonController val3 = LocalPlayer();
				Vector3 val4 = (((Object)(object)val2 != (Object)null && Vector3.Distance(val2.position, ((Component)val).transform.position) <= 40f) ? val2.position : ((!((Object)(object)val3 != (Object)null)) ? (((Component)val).transform.position + Vector3.up * 1f) : SpotNear(((Component)val).transform.position, ((Component)val).transform.forward, val3)));
				if (MoveSelf(val4))
				{
					Plugin.Log.LogInfo((object)("Teleported to the campfire (" + (((Object)(object)val2 != (Object)null && val4 == val2.position) ? "player spawn" : "fire") + ")"));
				}
			}
		}

		private static bool MoveSelf(Vector3 position)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			FirstPersonController val = LocalPlayer();
			if (!Plugin.Enabled.Value || (Object)(object)val == (Object)null)
			{
				return false;
			}
			CharacterController controller = val.Controller;
			if ((Object)(object)controller != (Object)null)
			{
				((Collider)controller).enabled = false;
			}
			((Component)val).transform.position = position;
			if ((Object)(object)controller != (Object)null)
			{
				((Collider)controller).enabled = true;
			}
			if ((Object)(object)val.SmoothSyncMirror != (Object)null)
			{
				val.SmoothSyncMirror.clearBuffer();
				val.SmoothSyncMirror.teleportOwnedObjectFromOwner();
			}
			return true;
		}

		public static void Bring(FirstPersonController target)
		{
			FirstPersonController val = LocalPlayer();
			if (CanBring && ActionsAllowed && !((Object)(object)val == (Object)null) && !((Object)(object)target == (Object)null) && !((Object)(object)target == (Object)(object)val))
			{
				if (NetworkServer.active)
				{
					BringTo(target, val);
				}
				else
				{
					NetworkClient.Send<BringRequestMessage>(new BringRequestMessage
					{
						NetId = ((NetworkBehaviour)target).netId
					}, 0);
				}
				Plugin.Log.LogInfo((object)("Brought " + target.playerName));
			}
		}

		private static void OnBringRequest(NetworkConnectionToClient sender, BringRequestMessage message)
		{
			if (!Access.IsTrusted(sender))
			{
				Plugin.Log.LogWarning((object)("Ignored a bring request from untrusted connection " + sender.address));
				return;
			}
			FirstPersonController val = ((IEnumerable<FirstPersonController>)Players()).FirstOrDefault((Func<FirstPersonController, bool>)((FirstPersonController p) => ((NetworkBehaviour)p).connectionToClient == sender));
			FirstPersonController val2 = ((IEnumerable<FirstPersonController>)Players()).FirstOrDefault((Func<FirstPersonController, bool>)((FirstPersonController p) => ((NetworkBehaviour)p).netId == message.NetId));
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null) && !((Object)(object)val2 == (Object)(object)val))
			{
				BringTo(val2, val);
				Plugin.Log.LogInfo((object)(val.playerName + " brought " + val2.playerName));
			}
		}

		private static void BringTo(FirstPersonController target, FirstPersonController destination)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)target.SmoothSyncMirror == (Object)null))
			{
				Vector3 val = SpotNear(((Component)destination).transform.position, ((Component)destination).transform.forward, target);
				target.SmoothSyncMirror.teleportAnyObjectFromServer(val, ((Component)target).transform.rotation, ((Component)target).transform.localScale);
			}
		}

		private static Vector3 SpotNear(Vector3 anchor, Vector3 facing, FirstPersonController mover)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			List<SpotOffset> candidates = SpotSearch.Candidates(1.5f, 1, 8);
			Vector3 forward = Flatten(facing);
			Vector3 right = Vector3.Cross(Vector3.up, forward);
			Vector3 spot = anchor;
			SpotSearch.Pick(candidates, delegate(int i)
			{
				//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: 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)
				Vector3? val = StandablePoint(anchor + forward * candidates[i].Forward + right * candidates[i].Right, mover);
				if (!val.HasValue)
				{
					return false;
				}
				spot = val.Value;
				return true;
			});
			return spot;
		}

		private static Vector3 Flatten(Vector3 direction)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be