Decompiled source of AdminMenu v0.1.8
AdminMenu.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 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.8.0")] [assembly: AssemblyInformationalVersion("0.1.8+2554c4faa307a48eb2bd3e0bf1831550c0de7cad")] [assembly: AssemblyProduct("AdminMenu")] [assembly: AssemblyTitle("AdminMenu")] [assembly: AssemblyVersion("0.1.8.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 readonly HashSet<ulong> _sessionGrants = new HashSet<ulong>(); private static ulong _grantsLobby; 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 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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 != _grantsLobby) { if (_sessionGrants.Count > 0) { Plugin.Log.LogInfo((object)$"Session admin grants cleared ({_sessionGrants.Count}) on leaving the lobby"); } _sessionGrants.Clear(); _grantsLobby = val.m_SteamID; } 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.8"); } if (NetworkServer.active) { 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 _sessionGrants.Contains(player.playerID); } return false; } public static void SetGranted(FirstPersonController player, bool granted) { if (CanGrant && !((Object)(object)player == (Object)null) && player.playerID != 0L && HasMod(player) && (granted ? _sessionGrants.Add(player.playerID) : _sessionGrants.Remove(player.playerID))) { Plugin.Log.LogInfo((object)string.Format("{0} session admin for {1} ({2})", granted ? "Granted" : "Revoked", player.playerName, player.playerID)); _nextLobbyCheck = 0f; } } 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 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", _sessionGrants); } 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_0133: 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); } 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 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"); 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 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 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)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_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_001e: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_00a5: 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_00bd: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0149: Expected O, but got Unknown 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(((ConfigEntryBase)entry).Description.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); Toggle val5 = new Toggle(); ((BaseField<bool>)val5).value = entry.Value; Toggle val6 = val5; INotifyValueChangedExtensions.RegisterValueChangedCallback<bool>((INotifyValueChanged<bool>)(object)val6, (EventCallback<ChangeEvent<bool>>)delegate(ChangeEvent<bool> evt) { entry.Value = evt.newValue; }); val.Add((VisualElement)(object)val6); root.Add(val); return val6; } } internal sealed class ConfigurationManagerAttributes { public string DispName; public int? Order; } 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 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 due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(direction.x, 0f, direction.z); if (!(((Vector3)(ref val)).sqrMagnitude > 0.0001f)) { return Vector3.forward; } return ((Vector3)(ref val)).normalized; } private static Vector3? StandablePoint(Vector3 candidate, FirstPersonController mover) { //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_0049: 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_0053: 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_0077: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) CharacterController controller = mover.Controller; if ((Object)(object)controller == (Object)null) { return candidate; } float radius = controller.radius; float num = Mathf.Max(controller.height, radius * 2f); int num2 = SolidMask(((Component)mover).gameObject.layer); RaycastHit val = default(RaycastHit); if (!Physics.Raycast(candidate + Vector3.up * num, Vector3.down, ref val, num + 1.5f, num2, (QueryTriggerInteraction)1)) { return null; } Vector3 val2 = ((RaycastHit)(ref val)).point + Vector3.up * (num * 0.5f + controller.skinWidth); float num3 = Mathf.Max(0f, num * 0.5f - radius); if (Physics.CheckCapsule(val2 - Vector3.up * num3, val2 + Vector3.up * num3, radius * 0.95f, num2, (QueryTriggerInteraction)1)) { return null; } return val2; } private static int SolidMask(int playerLayer) { if (_solidMaskLayer == playerLayer) { return _solidMask; } int num = 0; for (int i = 0; i < 32; i++) { if (i != playerLayer && !Physics.GetIgnoreLayerCollision(playerLayer, i)) { num |= 1 << i; } } _solidMaskLayer = playerLayer; _solidMask = num; return num; } public static float MaxHealthOf(PlayerStats stats) { return stats.NetworksyncMaxHealth; } } internal static class PlayersTab { private static readonly Color DeadColor = new Color(0.85f, 0.35f, 0.35f); private const long TickMilliseconds = 250L; 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) VisualElement root = new VisualElement(); VisualElement val = new VisualElement(); val.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)2); val.style.marginBottom = StyleLength.op_Implicit(12f); root.Add(val); Button bringAll = new Button((Action)delegate { FirstPersonController val2 = PlayerActions.LocalPlayer(); foreach (FirstPersonController item in PlayerActions.Players()) { if ((Object)(object)item != (Object)(object)val2) { PlayerActions.Bring(item); } } }) { text = "Bring everyone" }; Theme.StyleButton(bringAll); val.Add((VisualElement)(object)bringAll); Button campfire = new Button((Action)PlayerActions.TeleportToCampfire) { text = "Go to campfire" }; Theme.StyleButton(campfire); ((VisualElement)campfire).style.marginLeft = StyleLength.op_Implicit(8f); val.Add((VisualElement)(object)campfire); ScrollView scrollView = new ScrollView(); ((VisualElement)scrollView).style.flexGrow = StyleFloat.op_Implicit(1f); root.Add((VisualElement)(object)scrollView); List<FirstPersonController> shown = new List<FirstPersonController>(); List<Action> updaters = new List<Action>(); 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(250L); refresh = Refresh; return root; void Rebuild(List<FirstPersonController> players) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //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_0053: Unknown result type (might be due to invalid IL or missing references) ((VisualElement)scrollView).Clear(); shown.Clear(); updaters.Clear(); if (!PlayerActions.ActionsAllowed) { Label val2 = new Label("Only the host and trusted admins can use these."); ((VisualElement)val2).style.color = StyleColor.op_Implicit(Theme.Muted); ((VisualElement)val2).style.marginBottom = StyleLength.op_Implicit(12f); ((VisualElement)scrollView).Add((VisualElement)(object)val2); } foreach (FirstPersonController player in players) { shown.Add(player); try { ((VisualElement)scrollView).Add(BuildRow(player, out var update)); updaters.Add(update); } catch (Exception arg) { Plugin.Log.LogWarning((object)$"Failed to build player row for {player?.playerName}: {arg}"); } } } void Refresh() { Tick(forceRebuild: true); } void Tick(bool forceRebuild = false) { List<FirstPersonController> list = PlayerActions.Players(); bool flag = forceRebuild || list.Count != shown.Count; int num = 0; while (!flag && num < list.Count) { flag = (Object)(object)list[num] != (Object)(object)shown[num]; num++; } if (flag) { Rebuild(list); } ((VisualElement)bringAll).SetEnabled(PlayerActions.CanBring && PlayerActions.ActionsAllowed && list.Count > 1); bool flag2 = (Object)(object)PlayerActions.Campfire() != (Object)null; ((VisualElement)campfire).SetEnabled(Plugin.Enabled.Value && flag2 && (Object)(object)PlayerActions.LocalPlayer() != (Object)null); ((VisualElement)campfire).tooltip = (flag2 ? null : "There's no campfire here."); foreach (Action item2 in updaters) { item2(); } } } private static VisualElement BuildRow(FirstPersonController player, out Action update) { //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_001d: 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_0032: 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_0047: 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_005c: 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) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00e6: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_02c3: Expected O, but got Unknown VisualElement val = new VisualElement { name = "PlayerRow" }; 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.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)2); val2.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2); val.Add(val2); bool isSelf = (Object)(object)player == (Object)(object)PlayerActions.LocalPlayer(); Label val3 = new Label(isSelf ? (player.playerName + " (you)") : player.playerName); ((VisualElement)val3).style.color = StyleColor.op_Implicit(Theme.Text); ((VisualElement)val3).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1); ((VisualElement)val3).style.width = StyleLength.op_Implicit(200f); ((VisualElement)val3).style.flexShrink = StyleFloat.op_Implicit(1f); val2.Add((VisualElement)(object)val3); Label health = new Label(); ((VisualElement)health).style.width = StyleLength.op_Implicit(100f); ((VisualElement)health).style.flexGrow = StyleFloat.op_Implicit(1f); val2.Add((VisualElement)(object)health); Button revive = AddButton(val2, "Revive", delegate { PlayerActions.Revive(player); }); Button heal = AddButton(val2, "Heal", delegate { PlayerActions.Heal(player); }); Button kill = AddButton(val2, "Kill", delegate { PlayerActions.Kill(player); }); Button goTo = AddButton(val2, "Go to", delegate { PlayerActions.TeleportTo(player); }); Button bring = AddButton(val2, "Bring", delegate { PlayerActions.Bring(player); }); Button elevate = AddButton(val2, "Elevate", delegate { Access.SetGranted(player, !Access.IsGranted(player)); }); Action updateStats; VisualElement statsPanel = BuildStatsPanel(player, out updateStats); statsPanel.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1); val.Add(statsPanel); Button statsToggle = null; statsToggle = AddButton(val2, "Stats", delegate { //IL_000b: 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_002e: Unknown result type (might be due to invalid IL or missing references) bool flag = statsPanel.style.display == StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1); statsPanel.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!flag)); ((TextElement)statsToggle).text = (flag ? "Hide stats" : "Stats"); if (flag) { updateStats(); } }); ((VisualElement)statsToggle).style.marginRight = StyleLength.op_Implicit(0f); update = delegate { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) PlayerStats val4 = (((Object)(object)player != (Object)null) ? player.PlayerStats : null); if (!((Object)(object)val4 == (Object)null)) { if (val4.isDead) { ((TextElement)health).text = "DEAD"; ((VisualElement)health).style.color = StyleColor.op_Implicit(DeadColor); } else { ((TextElement)health).text = $"{Mathf.CeilToInt(val4.GetCurrentHealth())} / {Mathf.CeilToInt(PlayerActions.MaxHealthOf(val4))}"; ((VisualElement)health).style.color = StyleColor.op_Implicit(Theme.Muted); } bool actionsAllowed = PlayerActions.ActionsAllowed; ((VisualElement)revive).SetEnabled(actionsAllowed && val4.isDead); ((VisualElement)heal).SetEnabled(actionsAllowed); ((VisualElement)kill).SetEnabled(actionsAllowed && !val4.isDead); ((VisualElement)goTo).SetEnabled(Plugin.Enabled.Value && !isSelf); ((VisualElement)bring).SetEnabled(actionsAllowed && PlayerActions.CanBring && !isSelf); ((VisualElement)bring).tooltip = (PlayerActions.CanBring ? "" : ((!actionsAllowed) ? "Only the host and trusted admins can move other players." : "The host needs the admin menu installed for you to move other players.")); bool flag = Access.CanGrant && !isSelf; ((VisualElement)elevate).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!flag)); if (flag) { bool flag2 = Access.IsGranted(player); bool flag3 = Access.HasMod(player); ((TextElement)elevate).text = (flag2 ? "Revoke" : "Elevate"); ((VisualElement)elevate).SetEnabled(Plugin.Enabled.Value && flag3); ((VisualElement)elevate).tooltip = ((!flag3) ? "This player needs the admin menu installed before you can give them admin." : (flag2 ? "Take back admin for this player. Lasts for this session only." : "Give this player the admin menu for this session. Not saved to your config.")); } ((VisualElement)statsToggle).SetEnabled(actionsAllowed); if (statsPanel.style.display == StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0)) { updateStats(); } } }; update(); return val; } private static VisualElement BuildStatsPanel(FirstPersonController player, out Action update) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001e: 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_0033: Expected O, but got Unknown //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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing refer