Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RunicSentinelServer v1.3.1
plugins/RunicSentinelServer/RunicSentinelServer.dll
Decompiled 2 weeks 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.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Runic.Localization; using RunicSafety.Api; using RunicSentinel.Admission; using RunicSentinel.Api; using RunicSentinel.Contracts; using RunicSentinel.Core; using RunicSentinel.Devcommands; using RunicSentinel.Devcommands.EWP; using RunicSentinel.Devcommands.Service; using RunicSentinel.PlayerActions; using RunicSentinel.Runtime; using Splatform; using Steamworks; using UnityEngine; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Runic Sentinel Server")] [assembly: AssemblyDescription("Dedicated and listen-host Sentinel authority without client reporting or administrator GUI code")] [assembly: AssemblyCompany("Chazman")] [assembly: AssemblyProduct("Runic Sentinel Server")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0")] [assembly: InternalsVisibleTo("RunicSentinelServer.Tests")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Runic.Localization { internal sealed class LanguageCatalog { private readonly Dictionary<string, string> _english; private Dictionary<string, string> _selected = new Dictionary<string, string>(); private readonly Func<string, string> _read; private string _language; internal LanguageCatalog(string english, Func<string, string> read) { _english = Parse(english); _read = read; } internal static Dictionary<string, string> Parse(string json) { if (string.IsNullOrWhiteSpace(json)) { return new Dictionary<string, string>(); } if (json.Length > 2097152) { throw new InvalidDataException("Language file exceeds 2 MiB."); } DataContractJsonSerializer dataContractJsonSerializer = new DataContractJsonSerializer(typeof(Dictionary<string, string>), new DataContractJsonSerializerSettings { UseSimpleDictionaryFormat = true }); using MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(json.TrimStart('\ufeff'))); return ((Dictionary<string, string>)dataContractJsonSerializer.ReadObject(stream)) ?? new Dictionary<string, string>(); } internal void Select(string language) { language = (string.IsNullOrWhiteSpace(language) ? "English" : language); if (string.Equals(language, _language, StringComparison.Ordinal)) { return; } _language = language; _selected = new Dictionary<string, string>(); if (language.IndexOfAny(new char[4] { '/', '\\', ':', '\0' }) >= 0 || language == "." || language == "..") { return; } try { _selected = Parse(_read(language)); } catch (Exception) { } } internal string Get(string key) { _english.TryGetValue(key, out var value); if (_selected.TryGetValue(key, out var value2) && !string.IsNullOrWhiteSpace(value2) && (value == null || SameFields(value, value2))) { return value2; } return value ?? key; } internal string English(string key) { if (!_english.TryGetValue(key, out var value)) { return key; } return value; } internal string TranslateEnglish(string text) { foreach (KeyValuePair<string, string> item in _english) { if (item.Value == text) { return Get(item.Key); } } return text; } internal string Format(string key, params object[] args) { _english.TryGetValue(key, out var value); string text = Get(key); if (value != null && !SameFields(value, text)) { text = value; } try { return string.Format(CultureInfo.CurrentCulture, text, args); } catch (FormatException) { try { return string.Format(CultureInfo.CurrentCulture, value ?? key, args); } catch (FormatException) { return value ?? key; } } } private static bool SameFields(string a, string b) { try { return Fields(a).SetEquals(Fields(b)); } catch (FormatException) { return false; } } private static HashSet<int> Fields(string text) { HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < text.Length; i++) { if (text[i] == '}') { if (i + 1 >= text.Length || text[i + 1] != '}') { throw new FormatException(); } i++; } else { if (text[i] != '{') { continue; } if (i + 1 < text.Length && text[i + 1] == '{') { i++; continue; } int num = ++i; for (; i < text.Length && char.IsDigit(text[i]); i++) { } if (num == i || !int.TryParse(text.Substring(num, i - num), out var result)) { throw new FormatException(); } hashSet.Add(result); for (; i < text.Length && text[i] != '}'; i++) { if (text[i] == '{') { throw new FormatException(); } } if (i == text.Length) { throw new FormatException(); } } } return hashSet; } } internal static class RunicText { private static readonly Assembly Owner = typeof(RunicText).Assembly; private static readonly string Module = Owner.GetName().Name; private static readonly LanguageCatalog Catalog = Create(); private static LanguageCatalog Create() { using Stream stream = Owner.GetManifestResourceStream("Runic.Localization.English.json"); using StreamReader streamReader = ((stream == null) ? null : new StreamReader(stream)); return new LanguageCatalog(streamReader?.ReadToEnd() ?? "{}", ReadLanguage); } private static string ReadLanguage(string language) { string path = Path.Combine(Path.Combine(Path.GetDirectoryName(Owner.Location), "Translations", Module), language + ".json"); if (!File.Exists(path)) { return null; } return File.ReadAllText(path); } private static void SelectLanguage() { string language = "English"; try { Localization instance = Localization.instance; language = ((instance != null) ? instance.GetSelectedLanguage() : null) ?? "English"; } catch { } Catalog.Select(language); } internal static string Get(string key) { SelectLanguage(); return Catalog.Get(key); } internal static string English(string key) { return Catalog.English(key); } internal static string TranslateEnglish(string text) { SelectLanguage(); return Catalog.TranslateEnglish(text); } internal static string Format(string key, params object[] args) { SelectLanguage(); return Catalog.Format(key, args); } } } namespace RunicSentinel { [BepInPlugin("chazman.RunicSentinelServer", "Runic Sentinel Server", "1.3.0")] [BepInIncompatibility("server_devcommands")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInIncompatibility("chazman.RunicSentinel")] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "chazman.RunicSentinelServer"; public const string Name = "Runic Sentinel Server"; public const string Version = "1.3.0"; public const string ModuleId = "runic.sentinel.server"; private static Plugin _instance; private SentinelRuntime _runtime; private SentinelEnforcementRuntime _enforcement; private SentinelOperatorCommands _operatorCommands; private SentinelManagedPolicyService _managedPolicy; private SentinelAdminControl _adminControl; private SentinelFlightRecorder _flightRecorder; private Harmony _failClosedHarmony; private Harmony _roleHarmony; private Harmony _authorityHarmony; private ZNet _authorityNetwork; private ZNet _destroyedAuthorityNetwork; private int _refreshRequested; private bool _authorityStarted; private bool _activationFailed; private bool _configuredRoleKnown; private bool _serverRoleConfigured; private bool _unavailableGateLogged; private bool _clientNoticeLogged; private void Awake() { SentinelConfig.Bind(((BaseUnityPlugin)this).Config); ConfigEntry<bool> enabled = SentinelConfig.Enabled; if (enabled != null && !enabled.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Sentinel Server is disabled; no worker or network handlers were created."); return; } _instance = this; try { InstallPermanentFailClosedGate(); } catch (Exception ex) { _activationFailed = true; Shutdown(); ((BaseUnityPlugin)this).Logger.LogError((object)("Runic Sentinel Server could not install its Required-mode safety gate and is inactive: " + ex)); return; } try { InstallRoleObservers(); TryActivateAuthority(ZNet.instance); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Sentinel Server v1.3.0 installed. Authority services remain inert until Valheim selects a dedicated server or listen host role."); } catch (Exception ex2) { _activationFailed = true; ShutdownAuthority(); try { Harmony roleHarmony = _roleHarmony; if (roleHarmony != null) { roleHarmony.UnpatchSelf(); } } catch { } _roleHarmony = null; ((BaseUnityPlugin)this).Logger.LogError((object)("Runic Sentinel Server role bootstrap failed. Required mode remains fail closed through the permanent world-load and connection gates: " + ex2)); } } private void InstallPermanentFailClosedGate() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown MethodInfo methodInfo = RequireInstanceVoid("RPC_ServerHandshake", typeof(ZRpc), typeof(string)); MethodInfo methodInfo2 = RequireInstanceVoid("ServerLoadWorld"); _failClosedHarmony = new Harmony("chazman.RunicSentinelServer.fail-closed"); try { _failClosedHarmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(SentinelServerRoleBootstrap), "BeforeUnavailableServerHandshake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _failClosedHarmony.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(SentinelServerRoleBootstrap), "BeforeUnavailableWorldLoad", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch { try { _failClosedHarmony.UnpatchSelf(); } catch { } _failClosedHarmony = null; throw; } } private void InstallRoleObservers() { //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), "SetServer", new Type[6] { typeof(bool), typeof(bool), typeof(bool), typeof(string), typeof(string), typeof(World) }, (Type[])null); if (methodInfo == null || !methodInfo.IsStatic || methodInfo.ReturnType != typeof(void)) { throw new MissingMethodException(typeof(ZNet).FullName, "SetServer"); } MethodInfo methodInfo2 = RequireInstanceVoid("Awake"); MethodInfo methodInfo3 = RequireInstanceVoid("OnNewConnection", typeof(ZNetPeer)); MethodInfo methodInfo4 = RequireInstanceVoid("OnDestroy"); _roleHarmony = new Harmony("chazman.RunicSentinelServer.authority-role"); _roleHarmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(SentinelServerRoleBootstrap), "AfterSetServer", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _roleHarmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(SentinelServerRoleBootstrap), "AfterZNetAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _roleHarmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(SentinelServerRoleBootstrap), "AfterNewConnection", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _roleHarmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(SentinelServerRoleBootstrap), "AfterZNetDestroy", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static MethodInfo RequireInstanceVoid(string name, params Type[] parameters) { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(ZNet), name, parameters ?? Type.EmptyTypes, (Type[])null); if (methodInfo == null || methodInfo.IsStatic || methodInfo.ReturnType != typeof(void)) { throw new MissingMethodException(typeof(ZNet).FullName, name); } return methodInfo; } internal static void ObserveConfiguredRole(bool server) { Plugin instance = _instance; if (!((Object)(object)instance == (Object)null)) { instance._configuredRoleKnown = true; instance._serverRoleConfigured = server; instance._destroyedAuthorityNetwork = null; if (server) { instance.TryActivateAuthority(null); return; } instance.ShutdownAuthority(); instance.LogClientInertOnce(); } } internal static void ObserveNetwork(ZNet network) { _instance?.TryActivateAuthority(network); } internal static void ObserveConnection(ZNet network, ZNetPeer peer) { Plugin instance = _instance; if (!((Object)(object)instance == (Object)null)) { instance.TryActivateAuthority(network); if (instance._authorityStarted && (Object)(object)network != (Object)null && network.IsServer()) { instance._authorityNetwork = network; SentinelNetworkCompatibility.ObserveConnection(network, peer); } else { instance.BlockUnavailableConnection(network, peer, null); } } } internal static void ObserveNetworkDestroyed(ZNet network) { Plugin instance = _instance; if ((Object)(object)instance != (Object)null && instance._authorityStarted && network == instance._authorityNetwork) { instance._destroyedAuthorityNetwork = network; instance.ShutdownAuthority(); } } internal static bool AllowUnavailableServerHandshake(ZNet network, ZRpc rpc) { Plugin instance = _instance; if (!((Object)(object)instance == (Object)null)) { return !instance.BlockUnavailableConnection(network, null, rpc); } return true; } internal static void GuardUnavailableWorldLoad(ZNet network) { Plugin instance = _instance; if ((Object)(object)instance == (Object)null || !instance.ShouldBlockUnavailable(network)) { return; } instance.LogUnavailableGateOnce(); throw new InvalidOperationException("Runic Sentinel Server Required authority is unavailable; world load was blocked."); } private void TryActivateAuthority(ZNet network) { //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Expected O, but got Unknown if (_authorityStarted) { if ((Object)(object)network != (Object)null && network.IsServer()) { _authorityNetwork = network; _destroyedAuthorityNetwork = null; } } else { if (_activationFailed || network == _destroyedAuthorityNetwork) { return; } bool flag = _configuredRoleKnown && _serverRoleConfigured; if ((Object)(object)network != (Object)null) { try { flag |= network.IsServer(); } catch { } } if (flag) { try { _runtime = new SentinelRuntime(); _flightRecorder = new SentinelFlightRecorder(_runtime.Evidence, ((BaseUnityPlugin)this).Logger, Paths.ConfigPath); _runtime.AttachNetwork(SentinelConfig.RemoteAdmissionMode); _enforcement = new SentinelEnforcementRuntime(_runtime); SentinelIntegrationApi.Attach(_enforcement); SentinelTransitionBackup.Attach(_runtime, ((BaseUnityPlugin)this).Logger, Paths.ConfigPath); _managedPolicy = new SentinelManagedPolicyService(_runtime, ((BaseUnityPlugin)this).Logger, Paths.ConfigPath, (string reason) => SentinelTransitionBackup.CreateVerifiedBackupNow(reason)); _operatorCommands = new SentinelOperatorCommands(_runtime, ((BaseUnityPlugin)this).Logger, Paths.ConfigPath, _managedPolicy); _adminControl = new SentinelAdminControl(_runtime, _managedPolicy, _operatorCommands); _authorityHarmony = new Harmony("chazman.RunicSentinelServer.authority"); Engine.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger); _authorityHarmony.PatchAll(typeof(Plugin).Assembly); SentinelConfig.Changed += Refresh; _runtime.Start(Paths.ConfigPath); _authorityNetwork = (((Object)(object)network != (Object)null && network.IsServer()) ? network : null); _authorityStarted = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Sentinel Server authority services started. Required admission now gates the exact direct connection and the dedicated console/admin backend is available."); return; } catch (Exception ex) { _activationFailed = true; ShutdownAuthority(); ((BaseUnityPlugin)this).Logger.LogError((object)("Runic Sentinel Server authority startup failed closed: " + ex)); return; } } if ((Object)(object)network != (Object)null || _configuredRoleKnown) { LogClientInertOnce(); } } } internal static bool UnavailableAuthorityFailsClosed(SentinelRemoteAdmissionMode mode, bool authoritative, bool authorityStarted) { if (authoritative && !authorityStarted) { return mode == SentinelRemoteAdmissionMode.Required; } return false; } private bool ShouldBlockUnavailable(ZNet network) { bool authoritative = false; try { authoritative = (Object)(object)network != (Object)null && network.IsServer(); } catch { } return UnavailableAuthorityFailsClosed(SentinelConfig.RemoteAdmissionMode, authoritative, _authorityStarted); } private bool BlockUnavailableConnection(ZNet network, ZNetPeer peer, ZRpc rpc) { if (!ShouldBlockUnavailable(network)) { return false; } LogUnavailableGateOnce(); try { ZNetPeer val = peer; if (val == null && rpc != null) { foreach (ZNetPeer peer2 in network.GetPeers()) { if (peer2 != null && peer2.m_rpc == rpc) { val = peer2; break; } } } if (val != null) { network.Disconnect(val); } } catch { } return true; } private void LogUnavailableGateOnce() { if (!_unavailableGateLogged) { _unavailableGateLogged = true; ((BaseUnityPlugin)this).Logger.LogError((object)"Runic Sentinel Server Required authority is unavailable. World loading and native client admission remain blocked until the server is restarted successfully."); } } private void LogClientInertOnce() { if (!_clientNoticeLogged) { _clientNoticeLogged = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Sentinel Server detected a non-authoritative client and remains fully inert. Install Runic Sentinel Client in player-only profiles."); } } private void Refresh() { Interlocked.Exchange(ref _refreshRequested, 1); } private void Update() { ZNet instance = ZNet.instance; if (_authorityStarted && (Object)(object)instance != (Object)null && !instance.IsServer()) { ShutdownAuthority(); LogClientInertOnce(); return; } if (_authorityStarted && (Object)(object)instance != (Object)null && instance.IsServer()) { _authorityNetwork = instance; _destroyedAuthorityNetwork = null; } if (!_authorityStarted) { if ((Object)(object)instance != (Object)null) { TryActivateAuthority(instance); } return; } try { _runtime?.TickNetwork(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel server admission tick stopped safely: " + ex.Message)); } try { _runtime?.TickIntegrity(); } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel server integrity check failed closed: " + ex2.Message)); } try { _adminControl?.Tick(); if (_adminControl != null) { Engine.Tick(); } } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel server administrator transport stopped safely: " + ex3.Message)); } try { _operatorCommands?.TickDedicatedConsole(); } catch (Exception ex4) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel server console input stopped safely: " + ex4.Message)); } if (Interlocked.Exchange(ref _refreshRequested, 0) == 0 || _runtime == null) { return; } try { _runtime.Start(Paths.ConfigPath); } catch (Exception ex5) { ((BaseUnityPlugin)this).Logger.LogError((object)("Sentinel server policy refresh failed closed: " + ex5.Message)); } } private void OnDestroy() { Shutdown(); } private void Shutdown() { if (_instance == this) { _instance = null; } ShutdownAuthority(); try { Harmony roleHarmony = _roleHarmony; if (roleHarmony != null) { roleHarmony.UnpatchSelf(); } } catch { } _roleHarmony = null; try { Harmony failClosedHarmony = _failClosedHarmony; if (failClosedHarmony != null) { failClosedHarmony.UnpatchSelf(); } } catch { } _failClosedHarmony = null; } private void ShutdownAuthority() { try { Engine.Stop(); } catch { } SentinelConfig.Changed -= Refresh; Interlocked.Exchange(ref _refreshRequested, 0); _authorityStarted = false; _authorityNetwork = null; try { Harmony authorityHarmony = _authorityHarmony; if (authorityHarmony != null) { authorityHarmony.UnpatchSelf(); } } catch { } _authorityHarmony = null; SentinelSteamSessions.Reset(); try { _adminControl?.Dispose(); } catch { } _adminControl = null; SentinelTransitionBackup.Detach(); try { _operatorCommands?.Dispose(); } catch { } _operatorCommands = null; _managedPolicy = null; try { _flightRecorder?.Dispose(); } catch { } _flightRecorder = null; SentinelIntegrationApi.Detach(_enforcement); try { _enforcement?.Dispose(); } catch { } _enforcement = null; try { _runtime?.Dispose(); } catch { } _runtime = null; } } internal static class SentinelServerRoleBootstrap { internal static void AfterSetServer([HarmonyArgument(0)] bool server) { Plugin.ObserveConfiguredRole(server); } internal static void AfterZNetAwake(ZNet __instance) { Plugin.ObserveNetwork(__instance); } internal static void AfterNewConnection(ZNet __instance, [HarmonyArgument(0)] ZNetPeer peer) { Plugin.ObserveConnection(__instance, peer); } internal static void AfterZNetDestroy(ZNet __instance) { Plugin.ObserveNetworkDestroyed(__instance); } [HarmonyPriority(800)] internal static bool BeforeUnavailableServerHandshake(ZNet __instance, [HarmonyArgument(0)] ZRpc rpc) { return Plugin.AllowUnavailableServerHandshake(__instance, rpc); } [HarmonyPriority(800)] internal static void BeforeUnavailableWorldLoad(ZNet __instance) { Plugin.GuardUnavailableWorldLoad(__instance); } } internal static class SentinelConfig { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> UseServerAdminList; internal static ConfigEntry<string> PolicyFile; internal static ConfigEntry<string> SignatureFile; internal static ConfigEntry<string> PublicKeyFile; internal static ConfigEntry<string> TrustedPublicKeySha256; internal static ConfigEntry<string> RemoteAdmissionPolicy; internal static ConfigEntry<int> IntegrityCheckSeconds; internal static ConfigEntry<bool> BackupBeforeTransitions; internal static ConfigEntry<int> VeryHighDisconnectCount; internal static ConfigEntry<int> HighDisconnectCount; internal static ConfigEntry<int> EnforcementWindowSeconds; internal static SentinelRemoteAdmissionMode RemoteAdmissionMode { get { if (!string.Equals(RemoteAdmissionPolicy?.Value?.Trim(), "Disabled", StringComparison.OrdinalIgnoreCase)) { if (!string.Equals(RemoteAdmissionPolicy?.Value?.Trim(), "Required", StringComparison.OrdinalIgnoreCase)) { return SentinelRemoteAdmissionMode.Optional; } return SentinelRemoteAdmissionMode.Required; } return SentinelRemoteAdmissionMode.Disabled; } } internal static event Action Changed; internal static void Bind(ConfigFile config) { //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Expected O, but got Unknown Enabled = config.Bind<bool>("General", "Enabled", true, RunicText.Get("text_04f9fe75aee9")); UseServerAdminList = config.Bind<bool>("Administrator Access", "UseServerAdminList", true, RunicText.Get("text_99bb2f56596f")); PolicyFile = config.Bind<string>("Policy", "ManifestFile", "RunicSentinel.policy", RunicText.Get("text_b7eed9044c43")); SignatureFile = config.Bind<string>("Policy", "SignatureFile", "RunicSentinel.policy.sig", RunicText.Get("text_2e110bbd5688")); PublicKeyFile = config.Bind<string>("Policy", "PublicKeyFile", "RunicSentinel.policy.pub", RunicText.Get("text_54e85eb611ce")); TrustedPublicKeySha256 = config.Bind<string>("Policy", "TrustedPublicKeySha256", string.Empty, RunicText.Get("text_0ed34bbd06da")); RemoteAdmissionPolicy = config.Bind<string>("Remote Admission", "Policy", "Optional", RunicText.Get("text_b602d235fa8e") + RunicText.Get("text_d66b3605dcac") + RunicText.Get("text_b101247a5c6d") + RunicText.Get("text_3e51c1dea7db") + RunicText.Get("text_183c9913fd6f")); IntegrityCheckSeconds = config.Bind<int>("Runtime Integrity", "CheckIntervalSeconds", 15, RunicText.Get("text_8907827da911") + RunicText.Get("text_46c4c63703c2")); BackupBeforeTransitions = config.Bind<bool>("Transition Safety", "BackupWorldBeforeProfileChange", true, RunicText.Get("text_f0e8f6c49a3c") + RunicText.Get("text_b87330de459d")); VeryHighDisconnectCount = config.Bind<int>("Automatic Enforcement", "VeryHighFindingsBeforeDisconnect", 2, new ConfigDescription(RunicText.Get("text_308e67125b7e"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); HighDisconnectCount = config.Bind<int>("Automatic Enforcement", "HighFindingsBeforeDisconnect", 3, new ConfigDescription(RunicText.Get("text_a4d9b1405b2f"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 20), Array.Empty<object>())); EnforcementWindowSeconds = config.Bind<int>("Automatic Enforcement", "FindingWindowSeconds", 60, new ConfigDescription(RunicText.Get("text_dff407e006ab"), (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 600), Array.Empty<object>())); PolicyFile.SettingChanged += Notify; SignatureFile.SettingChanged += Notify; PublicKeyFile.SettingChanged += Notify; TrustedPublicKeySha256.SettingChanged += Notify; } private static void Notify(object sender, EventArgs args) { SentinelConfig.Changed?.Invoke(); } } } namespace RunicSentinel.Devcommands { public class AddStatusCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<int, List<string>> <>9__0_0; public static ConsoleEvent <>9__0_1; internal List<string> <.ctor>b__0_0(int index) { return index switch { 0 => ParameterInfo.StatusEffects, 1 => ParameterInfo.Create("Effect duration in seconds."), 2 => ParameterInfo.Create("Effect intensity."), _ => ParameterInfo.None, }; } internal void <.ctor>b__0_1(ConsoleEventArgs args) { Helper.ArgsCheck(args, 2, "Missing status name"); float result = 0f; float result2 = 0f; if (args.Length > 4) { throw new InvalidOperationException("Usage: addstatus name [duration seconds] [intensity]"); } if (args.Length > 2 && (!float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result) || float.IsNaN(result) || float.IsInfinity(result) || result < 0f)) { throw new InvalidOperationException("Duration must be finite, nonnegative seconds. 3600 = one hour; 6000 = 100 minutes. Zero means no expiry."); } if (args.Length > 3 && (!float.TryParse(args[3], NumberStyles.Float, CultureInfo.InvariantCulture, out result2) || float.IsNaN(result2) || float.IsInfinity(result2) || result2 < 0f)) { throw new InvalidOperationException("Intensity must be a finite, nonnegative number."); } Player player = Helper.GetPlayer(); int stableHashCode = StringExtensionMethods.GetStableHashCode(args[1]); ((Character)player).GetSEMan().AddStatusEffect(stableHashCode, true, 0, 0f, (short)(-1)); StatusEffect statusEffect = ((Character)player).GetSEMan().GetStatusEffect(stableHashCode); if ((Object)(object)statusEffect == (Object)null) { throw new InvalidOperationException("Unknown or unavailable status effect: " + args[1]); } if (args.Length > 2) { statusEffect.m_ttl = result; } if (args.Length <= 3) { return; } SE_Shield val = (SE_Shield)(object)((statusEffect is SE_Shield) ? statusEffect : null); if (val != null) { val.m_absorbDamage = result2; } SE_Burning val2 = (SE_Burning)(object)((statusEffect is SE_Burning) ? statusEffect : null); if (val2 != null) { if (args[1] == "Burning") { val2.m_fireDamageLeft = 0f; val2.AddFireDamage(result2); } else { val2.m_spiritDamageLeft = 0f; val2.AddSpiritDamage(result2); } } SE_Poison val3 = (SE_Poison)(object)((statusEffect is SE_Poison) ? statusEffect : null); if (val3 != null) { val3.m_damageLeft = result2; val3.m_damagePerHit = result2 / Math.Max(0.001f, statusEffect.m_ttl) * val3.m_damageInterval; } } } public AddStatusCommand() { //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_0058: Expected O, but got Unknown AutoComplete.Register("addstatus", (int index) => index switch { 0 => ParameterInfo.StatusEffects, 1 => ParameterInfo.Create("Effect duration in seconds."), 2 => ParameterInfo.Create("Effect intensity."), _ => ParameterInfo.None, }); object obj = <>c.<>9__0_1; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { Helper.ArgsCheck(args, 2, "Missing status name"); float result = 0f; float result2 = 0f; if (args.Length > 4) { throw new InvalidOperationException("Usage: addstatus name [duration seconds] [intensity]"); } if (args.Length > 2 && (!float.TryParse(args[2], NumberStyles.Float, CultureInfo.InvariantCulture, out result) || float.IsNaN(result) || float.IsInfinity(result) || result < 0f)) { throw new InvalidOperationException("Duration must be finite, nonnegative seconds. 3600 = one hour; 6000 = 100 minutes. Zero means no expiry."); } if (args.Length > 3 && (!float.TryParse(args[3], NumberStyles.Float, CultureInfo.InvariantCulture, out result2) || float.IsNaN(result2) || float.IsInfinity(result2) || result2 < 0f)) { throw new InvalidOperationException("Intensity must be a finite, nonnegative number."); } Player player = Helper.GetPlayer(); int stableHashCode = StringExtensionMethods.GetStableHashCode(args[1]); ((Character)player).GetSEMan().AddStatusEffect(stableHashCode, true, 0, 0f, (short)(-1)); StatusEffect statusEffect = ((Character)player).GetSEMan().GetStatusEffect(stableHashCode); if ((Object)(object)statusEffect == (Object)null) { throw new InvalidOperationException("Unknown or unavailable status effect: " + args[1]); } if (args.Length > 2) { statusEffect.m_ttl = result; } if (args.Length > 3) { SE_Shield val2 = (SE_Shield)(object)((statusEffect is SE_Shield) ? statusEffect : null); if (val2 != null) { val2.m_absorbDamage = result2; } SE_Burning val3 = (SE_Burning)(object)((statusEffect is SE_Burning) ? statusEffect : null); if (val3 != null) { if (args[1] == "Burning") { val3.m_fireDamageLeft = 0f; val3.AddFireDamage(result2); } else { val3.m_spiritDamageLeft = 0f; val3.AddSpiritDamage(result2); } } SE_Poison val4 = (SE_Poison)(object)((statusEffect is SE_Poison) ? statusEffect : null); if (val4 != null) { val4.m_damageLeft = result2; val4.m_damagePerHit = result2 / Math.Max(0.001f, statusEffect.m_ttl) * val4.m_damageInterval; } } }; <>c.<>9__0_1 = val; obj = (object)val; } Helper.Command("addstatus", "[name] [duration] [intensity] - Adds a status effect.", (ConsoleEvent)obj); } } public class AliasCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<string, string> <>9__0_2; public static ConsoleEvent <>9__0_0; public static Func<int, int, List<string>> <>9__0_1; internal void <.ctor>b__0_0(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString(string.Join("\n", AliasManager.AliasKeys.Select((string key) => key + " -> " + AliasManager.GetAliasValue(key)))); } else if (args.Length < 3) { AliasManager.RemoveAlias(args[1]); if (Terminal.commands.ContainsKey(args[1])) { Terminal.commands.Remove(args[1]); } args.Context.updateCommandList(); } else { string value = string.Join(" ", args.Args.Skip(2)); AliasManager.AddAlias(args[1], value); args.Context.updateCommandList(); } } internal string <.ctor>b__0_2(string key) { return key + " -> " + AliasManager.GetAliasValue(key); } internal List<string> <.ctor>b__0_1(int index, int subIndex) { if (index == 0) { return ParameterInfo.Create("Name of the alias."); } return ParameterInfo.None; } } public AliasCommand() { //IL_0039: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (args.Length < 2) { args.Context.AddString(string.Join("\n", AliasManager.AliasKeys.Select((string key) => key + " -> " + AliasManager.GetAliasValue(key)))); } else if (args.Length < 3) { AliasManager.RemoveAlias(args[1]); if (Terminal.commands.ContainsKey(args[1])) { Terminal.commands.Remove(args[1]); } args.Context.updateCommandList(); } else { string value = string.Join(" ", args.Args.Skip(2)); AliasManager.AddAlias(args[1], value); args.Context.updateCommandList(); } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("alias", "[name] [command] - Sets a command alias.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.Register("alias", (int index, int subIndex) => (index == 0) ? ParameterInfo.Create("Name of the alias.") : ParameterInfo.None); AutoComplete.Offsets["alias"] = 1; } } [HarmonyPatch] public class BindCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static ConsoleOptionsFetcher <>9__0_1; public static Func<int, int, List<string>> <>9__0_2; public static Func<int, List<string>> <>9__0_7; public static ConsoleEvent <>9__0_3; public static Func<int, List<string>> <>9__0_4; public static ConsoleEvent <>9__0_5; public static ConsoleEvent <>9__0_6; internal void <.ctor>b__0_0(ConsoleEventArgs args) { if (args.Length >= 2) { BindManager.AddBind(args[1], string.Join(" ", args.Args.Skip(2))); } } internal List<string> <.ctor>b__0_1() { return ParameterInfo.KeyCodes; } internal List<string> <.ctor>b__0_2(int index, int subIndex) { if (index == 0 && subIndex == 0) { return ParameterInfo.KeyCodes; } if (index == 0 && subIndex == 1) { return ParameterInfo.KeyCodesWithNegative; } return ParameterInfo.None; } internal List<string> <.ctor>b__0_7(int index) { return ParameterInfo.KeyCodesWithNegative; } internal void <.ctor>b__0_3(ConsoleEventArgs args) { if (args.Length >= 2) { BindManager.RemoveBind(args[1]); } } internal List<string> <.ctor>b__0_4(int index) { if (index == 0) { return ParameterInfo.KeyCodes; } return ParameterInfo.None; } internal void <.ctor>b__0_5(ConsoleEventArgs args) { BindManager.PrintBinds(args.Context); } internal void <.ctor>b__0_6(ConsoleEventArgs args) { BindManager.ClearBinds(); } } public BindCommand() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0057: 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_0054: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_019d: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { BindManager.AddBind(args[1], string.Join(" ", args.Args.Skip(2))); } }; <>c.<>9__0_0 = val; obj = (object)val; } object obj2 = <>c.<>9__0_1; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => ParameterInfo.KeyCodes; <>c.<>9__0_1 = val2; obj2 = (object)val2; } new ConsoleCommand("bind", "[keycode,modifier1,modifier2,...] [command] [parameters] - Binds a key (with modifier keys) to a command.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false); AutoComplete.Register("bind", delegate(int index, int subIndex) { if (index == 0 && subIndex == 0) { return ParameterInfo.KeyCodes; } return (index == 0 && subIndex == 1) ? ParameterInfo.KeyCodesWithNegative : ParameterInfo.None; }, new Dictionary<string, Func<int, List<string>>> { { "keys", (int index) => ParameterInfo.KeyCodesWithNegative } }); AutoComplete.Offsets["bind"] = 1; object obj3 = <>c.<>9__0_3; if (obj3 == null) { ConsoleEvent val3 = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { BindManager.RemoveBind(args[1]); } }; <>c.<>9__0_3 = val3; obj3 = (object)val3; } new ConsoleCommand("unbind", "[keycode] - Clears binds from a key.", (ConsoleEvent)obj3, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.Register("unbind", (int index) => (index == 0) ? ParameterInfo.KeyCodes : ParameterInfo.None); object obj4 = <>c.<>9__0_5; if (obj4 == null) { ConsoleEvent val4 = delegate(ConsoleEventArgs args) { BindManager.PrintBinds(args.Context); }; <>c.<>9__0_5 = val4; obj4 = (object)val4; } new ConsoleCommand("printbinds", "Prints all key binds.", (ConsoleEvent)obj4, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.RegisterEmpty("printbinds"); object obj5 = <>c.<>9__0_6; if (obj5 == null) { ConsoleEvent val5 = delegate { BindManager.ClearBinds(); }; <>c.<>9__0_6 = val5; obj5 = (object)val5; } new ConsoleCommand("resetbinds", "Removes all custom key binds.", (ConsoleEvent)obj5, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.RegisterEmpty("resetbinds"); } public static void SetMode(string mode) { BindManager.SetMode(mode); } } public class BroadcastCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__2_0; public static Func<int, List<string>> <>9__2_1; public static Func<int, List<string>> <>9__2_4; public static Func<int, List<string>> <>9__2_5; public static Func<int, List<string>> <>9__2_6; public static Func<int, List<string>> <>9__2_7; public static ConsoleEvent <>9__2_2; public static Func<int, List<string>> <>9__2_3; public static Func<int, List<string>> <>9__2_8; public static Func<int, List<string>> <>9__2_9; public static Func<int, List<string>> <>9__2_10; public static Func<int, List<string>> <>9__2_11; internal void <.ctor>b__2_0(ConsoleEventArgs args) { //IL_002f: 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) Helper.ArgsCheck(args, 2, "Missing the center/side parameter."); Helper.ArgsCheck(args, 3, "Missing the message"); MessageType val = (MessageType)((args[2] == "side") ? 1 : 2); string text = string.Join(" ", args.Args.Skip(2)); MessageHud.instance.MessageAll(val, text); } internal List<string> <.ctor>b__2_1(int index) { if (index == 0) { return Types; } return Modifiers; } internal List<string> <.ctor>b__2_4(int index) { return ParameterInfo.Create("Bolds the text."); } internal List<string> <.ctor>b__2_5(int index) { return ParameterInfo.Create("Italics the text."); } internal List<string> <.ctor>b__2_6(int index) { return ParameterInfo.Colors; } internal List<string> <.ctor>b__2_7(int index) { return ParameterInfo.Create("Size in pixels."); } internal void <.ctor>b__2_2(ConsoleEventArgs args) { //IL_0072: 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_00b8: Expected I4, but got Unknown Helper.ArgsCheck(args, 2, "Missing the player parameter."); Helper.ArgsCheck(args, 3, "Missing the center/side parameter."); Helper.ArgsCheck(args, 4, "Missing the message"); List<PlayerInfo> list = PlayerInfo.FindPlayers(Parse.Split(args[1])); if (list.Count == 0) { throw new Exception("Player " + args[1] + " not found."); } MessageType val = (MessageType)((args[3] == "side") ? 1 : 2); string text = string.Join(" ", args.Args.Skip(3)); foreach (PlayerInfo item in list) { ZRoutedRpc.instance.InvokeRoutedRPC(item.PeerId, "ShowMessage", new object[2] { (int)val, text }); } } internal List<string> <.ctor>b__2_3(int index) { return index switch { 0 => ParameterInfo.PlayerNames, 1 => Types, _ => Modifiers, }; } internal List<string> <.ctor>b__2_8(int index) { return ParameterInfo.Create("Bolds the text."); } internal List<string> <.ctor>b__2_9(int index) { return ParameterInfo.Create("Italics the text."); } internal List<string> <.ctor>b__2_10(int index) { return ParameterInfo.Colors; } internal List<string> <.ctor>b__2_11(int index) { return ParameterInfo.Create("Size in pixels."); } } private static readonly List<string> Types = new List<string>(2) { "center", "side" }; private static readonly List<string> Modifiers = new List<string>(4) { "<b", "<color", "<i", "<size" }; public BroadcastCommand() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown object obj = <>c.<>9__2_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_002f: 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) Helper.ArgsCheck(args, 2, "Missing the center/side parameter."); Helper.ArgsCheck(args, 3, "Missing the message"); MessageType val3 = (MessageType)((args[2] == "side") ? 1 : 2); string text = string.Join(" ", args.Args.Skip(2)); MessageHud.instance.MessageAll(val3, text); }; <>c.<>9__2_0 = val; obj = (object)val; } Helper.Command("broadcast", "[center/side] [message] - Broadcasts a message.", (ConsoleEvent)obj); AutoComplete.Register("broadcast", (int index) => (index == 0) ? Types : Modifiers, new Dictionary<string, Func<int, List<string>>> { { "<b", (int index) => ParameterInfo.Create("Bolds the text.") }, { "<i", (int index) => ParameterInfo.Create("Italics the text.") }, { "<color", (int index) => ParameterInfo.Colors }, { "<size", (int index) => ParameterInfo.Create("Size in pixels.") } }); object obj2 = <>c.<>9__2_2; if (obj2 == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { //IL_0072: 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_00b8: Expected I4, but got Unknown Helper.ArgsCheck(args, 2, "Missing the player parameter."); Helper.ArgsCheck(args, 3, "Missing the center/side parameter."); Helper.ArgsCheck(args, 4, "Missing the message"); List<PlayerInfo> list = PlayerInfo.FindPlayers(Parse.Split(args[1])); if (list.Count == 0) { throw new Exception("Player " + args[1] + " not found."); } MessageType val3 = (MessageType)((args[3] == "side") ? 1 : 2); string text = string.Join(" ", args.Args.Skip(3)); foreach (PlayerInfo item in list) { ZRoutedRpc.instance.InvokeRoutedRPC(item.PeerId, "ShowMessage", new object[2] { (int)val3, text }); } }; <>c.<>9__2_2 = val2; obj2 = (object)val2; } Helper.Command("message", "[player] [center/side] [message] - Sends a message to a player.", (ConsoleEvent)obj2); AutoComplete.Register("message", (int index) => index switch { 0 => ParameterInfo.PlayerNames, 1 => Types, _ => Modifiers, }, new Dictionary<string, Func<int, List<string>>> { { "<b", (int index) => ParameterInfo.Create("Bolds the text.") }, { "<i", (int index) => ParameterInfo.Create("Italics the text.") }, { "<color", (int index) => ParameterInfo.Colors }, { "<size", (int index) => ParameterInfo.Create("Size in pixels.") } }); } } public class CalmCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<int, List<string>> <>9__0_0; public static ConsoleEvent <>9__0_1; internal List<string> <.ctor>b__0_0(int index) { if (index == 0) { return ParameterInfo.Create("Radius", "a positive integer"); } return ParameterInfo.None; } internal void <.ctor>b__0_1(ConsoleEventArgs args) { //IL_000a: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003d: 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_008c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)Helper.GetPlayer()).transform.position; float num = args.TryParameterFloat(1, 20f); int num2 = 0; foreach (BaseAI instance in BaseAI.Instances) { BaseAI val = instance; if (Vector3.Distance(position, ((Component)val).transform.position) <= num && (val.IsAlerted() || val.IsAggravated() || val.HaveTarget())) { val.m_nview.ClaimOwnership(); val.SetAggravated(false, (AggravatedReason)1); val.SetAlerted(false); val.SetTargetInfo(ZDOID.None); MonsterAI val2 = (MonsterAI)(object)((val is MonsterAI) ? val : null); if (val2 != null) { val2.m_targetCreature = null; val2.m_targetStatic = null; } AnimalAI val3 = (AnimalAI)(object)((val is AnimalAI) ? val : null); if (val3 != null) { val3.m_target = null; } num2++; } } Helper.AddMessage(args.Context, $"Calmed {num2} creatures."); } } public CalmCommand() { //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_0058: Expected O, but got Unknown AutoComplete.Register("calm", (int index) => (index == 0) ? ParameterInfo.Create("Radius", "a positive integer") : ParameterInfo.None); object obj = <>c.<>9__0_1; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_000a: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_003d: 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_008c: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)Helper.GetPlayer()).transform.position; float num = args.TryParameterFloat(1, 20f); int num2 = 0; foreach (BaseAI instance in BaseAI.Instances) { BaseAI val2 = instance; if (Vector3.Distance(position, ((Component)val2).transform.position) <= num && (val2.IsAlerted() || val2.IsAggravated() || val2.HaveTarget())) { val2.m_nview.ClaimOwnership(); val2.SetAggravated(false, (AggravatedReason)1); val2.SetAlerted(false); val2.SetTargetInfo(ZDOID.None); MonsterAI val3 = (MonsterAI)(object)((val2 is MonsterAI) ? val2 : null); if (val3 != null) { val3.m_targetCreature = null; val3.m_targetStatic = null; } AnimalAI val4 = (AnimalAI)(object)((val2 is AnimalAI) ? val2 : null); if (val4 != null) { val4.m_target = null; } num2++; } } Helper.AddMessage(args.Context, $"Calmed {num2} creatures."); }; <>c.<>9__0_1 = val; obj = (object)val; } Helper.Command("calm", "[radius=20] - Calms creatures within given meters.", (ConsoleEvent)obj); } } public class ConfigCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<int, List<string>> <>9__0_0; public static ConsoleEvent <>9__1_0; public static ConsoleOptionsFetcher <>9__1_1; internal List<string> <RegisterAutoComplete>b__0_0(int index) { if (index == 0) { return Settings.Options; } return ParameterInfo.Create("Value"); } internal void <.ctor>b__1_0(ConsoleEventArgs args) { if (args.Length >= 2) { if (args.Length == 2) { Settings.UpdateValue(args.Context, args[1], ""); } else { Settings.UpdateValue(args.Context, args[1], string.Join(" ", args.Args.Skip(2))); } } } internal List<string> <.ctor>b__1_1() { return Settings.Options; } } private void RegisterAutoComplete(string command) { AutoComplete.Register(command, (int index) => (index == 0) ? Settings.Options : ParameterInfo.Create("Value")); } public ConfigCommand() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0057: 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_0054: Expected O, but got Unknown object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (args.Length >= 2) { if (args.Length == 2) { Settings.UpdateValue(args.Context, args[1], ""); } else { Settings.UpdateValue(args.Context, args[1], string.Join(" ", args.Args.Skip(2))); } } }; <>c.<>9__1_0 = val; obj = (object)val; } object obj2 = <>c.<>9__1_1; if (obj2 == null) { ConsoleOptionsFetcher val2 = () => Settings.Options; <>c.<>9__1_1 = val2; obj2 = (object)val2; } new ConsoleCommand("dev_config", "[key] [value] - Toggles or sets config value.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false); RegisterAutoComplete("dev_config"); } } public static class DefaultAutoComplete { public static void Register() { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown AutoComplete.RegisterEmpty("aggravate"); AutoComplete.RegisterEmpty("challenge"); AutoComplete.RegisterEmpty("cheers"); AutoComplete.RegisterEmpty("clear"); AutoComplete.Register("fov ", (int index) => (index == 0) ? ParameterInfo.Create("Amount", "a positive number") : ParameterInfo.None); AutoComplete.RegisterEmpty("hidebetatext"); AutoComplete.Register("help ", (int index) => index switch { 0 => ParameterInfo.Create("Page", "number"), 1 => ParameterInfo.Create("Page size", "a positive integer (default is 5)"), _ => ParameterInfo.None, }); AutoComplete.RegisterEmpty("info"); AutoComplete.Register("lodbias", (int index) => (index == 0) ? ParameterInfo.Create("Amount", "a positive number") : ParameterInfo.None); AutoComplete.RegisterEmpty("nonono"); AutoComplete.RegisterEmpty("opterrain"); AutoComplete.RegisterEmpty("point"); AutoComplete.RegisterEmpty("ping"); ConsoleOptionsFetcher originalFetcher = Terminal.commands["raiseskill"].m_tabOptionsFetcher; Terminal.commands["raiseskill"].m_tabOptionsFetcher = new ConsoleOptionsFetcher(newFetcher); AutoComplete.Register("raiseskill", delegate(int index) { ConsoleOptionsFetcher tabOptionsFetcher = Terminal.commands["raiseskill"].m_tabOptionsFetcher; return index switch { 0 => tabOptionsFetcher.Invoke(), 1 => ParameterInfo.Create("Amount of skill levels gained or lost (if negative)."), _ => ParameterInfo.None, }; }); AutoComplete.RegisterEmpty("resetsharedmap"); AutoComplete.RegisterEmpty("resetspawn"); AutoComplete.RegisterEmpty("respawn"); AutoComplete.Register("s", (int index) => ParameterInfo.Create("Message")); AutoComplete.Register("say", (int index) => ParameterInfo.Create("Message")); AutoComplete.RegisterEmpty("restartparty"); AutoComplete.RegisterEmpty("sit"); AutoComplete.RegisterEmpty("thumbsup"); AutoComplete.RegisterEmpty("tutorialreset"); AutoComplete.RegisterEmpty("tutorialtoggle"); AutoComplete.RegisterEmpty("wave"); AutoComplete.Register("W", (int index) => (index == 0) ? ParameterInfo.PlayerNames : ParameterInfo.Create("Message")); AutoComplete.RegisterAdmin("ban"); AutoComplete.RegisterEmpty("banned"); AutoComplete.RegisterAdmin("kick"); AutoComplete.RegisterEmpty("save"); AutoComplete.RegisterAdmin("unban"); AutoComplete.Register("beard", (int index) => (index == 0) ? ParameterInfo.Beards : ParameterInfo.None); AutoComplete.RegisterEmpty("clearstatus"); AutoComplete.RegisterEmpty("dpsdebug"); AutoComplete.RegisterEmpty("exploremap"); AutoComplete.Register("ffsmooth", (int index) => (index == 0) ? ParameterInfo.Create("0 = normal, 1 = add smooth movement") : ParameterInfo.None); AutoComplete.RegisterEmpty("fly"); AutoComplete.RegisterEmpty("freefly"); AutoComplete.Register("forcedelete", (int index) => index switch { 0 => ParameterInfo.Create("Radius", "in meters (from 0.0 to 50.0, default is 5.0)."), 1 => ParameterInfo.ObjectIds, _ => ParameterInfo.None, }); AutoComplete.RegisterEmpty("gc"); AutoComplete.RegisterEmpty("ghost"); AutoComplete.RegisterEmpty("god"); AutoComplete.Register("hair", (int index) => (index == 0) ? ParameterInfo.Hairs : ParameterInfo.None); AutoComplete.RegisterEmpty("heal"); AutoComplete.Register("itemset", (int index) => index switch { 0 => Terminal.commands["itemset"].m_tabOptionsFetcher.Invoke(), 1 => new List<string>(2) { "keep", "clear" }, _ => ParameterInfo.None, }); AutoComplete.RegisterEmpty("killenemycreatures"); AutoComplete.RegisterEmpty("killtame"); AutoComplete.RegisterEmpty("listkeys"); if (Terminal.commands.TryGetValue("listkeys", out var value)) { value.RemoteCommand = false; } AutoComplete.Register("location", (int index) => index switch { 0 => ParameterInfo.LocationIds, 1 => new List<string>(1) { "SAVE" }, _ => ParameterInfo.None, }); AutoComplete.Register("maxfps", (int index) => (index == 0) ? ParameterInfo.Create("Amount", "a positive integer") : ParameterInfo.None); AutoComplete.Register("model", (int index) => (index == 0) ? ParameterInfo.Create("<color=yellow>0</color> = male, <color=yellow>1</color> = female") : ParameterInfo.None); AutoComplete.RegisterEmpty("nocost"); AutoComplete.RegisterEmpty("noportals"); AutoComplete.Register("players", (int index) => (index == 0) ? ParameterInfo.Create("Amount", "a positive integer (0 disables the override)") : ParameterInfo.None); AutoComplete.RegisterEmpty("printcreatures"); AutoComplete.RegisterEmpty("printseeds"); AutoComplete.RegisterEmpty("printlocations"); AutoComplete.RegisterEmpty("puke"); AutoComplete.RegisterEmpty("removebirds"); AutoComplete.RegisterEmpty("removedrops"); AutoComplete.RegisterEmpty("removefish"); AutoComplete.Register("recall ", (int index) => (index == 0) ? ParameterInfo.PlayerNames : ParameterInfo.None); AutoComplete.RegisterEmpty("resetcharacter"); AutoComplete.RegisterEmpty("resetenv"); AutoComplete.RegisterEmpty("resetwind"); AutoComplete.Register("removekey", (int index) => (index == 0) ? ParameterInfo.GlobalKeys : ParameterInfo.None); AutoComplete.Register("setkey", (int index) => (index == 0) ? ParameterInfo.GlobalKeys : ParameterInfo.None); AutoComplete.RegisterDefault("setpower"); AutoComplete.Register("spawn", (int index) => index switch { 0 => ParameterInfo.ObjectIds, 1 => ParameterInfo.Create("Amount", "a positive integer (default 1)"), 2 => ParameterInfo.Create("Level", "a positive integer (default 1)"), 3 => ParameterInfo.Create("Radius in metres", "default 0.5; p/e/i may also follow the numeric arguments"), 4 => new List<string> { "p", "e", "i" }, 5 => ParameterInfo.Create("Optional Component.field::value overrides"), _ => ParameterInfo.None, }); AutoComplete.RegisterEmpty("tame"); AutoComplete.Register("test", (int index) => (index == 0) ? new List<string>(1) { "oldcomfort" } : ParameterInfo.None); AutoComplete.RegisterDefault("resetskill"); AutoComplete.RegisterEmpty("time"); AutoComplete.Register("timescale", (int index) => index switch { 0 => ParameterInfo.Create("Multiplier", "sets how fast the time goes (from 0.0 to 3.0). Value 0 can be used to pause the game."), 1 => ParameterInfo.Create("Transition duration", "causes the change to be applied gradually over time (seconds). Default value 0 applies the change instantly."), _ => ParameterInfo.None, }); AutoComplete.Register("tod", (int index) => (index == 0) ? ParameterInfo.Create("Time", "overrides the time of the day (from 0.0 to 1.0, with 0.5 being the mid day). Value -1 removes the override.") : ParameterInfo.None); List<string> newFetcher() { //IL_0012: 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) List<string> list = originalFetcher.Invoke(); if (!list.Contains(((object)(SkillType)999/*cast due to .constrained prefix*/).ToString())) { list.Add(((object)(SkillType)999/*cast due to .constrained prefix*/).ToString()); } return list; } } } public class DevcommandsCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__5_0; internal void <.ctor>b__5_0(ConsoleEventArgs args) { if (Terminal.m_cheat) { Set(args.Context, value: false); return; } if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { Set(args.Context, value: true); return; } args.Context.AddString("Authenticating for devcommands..."); Admin.ManualCheck(); } } public static void Set(Terminal terminal, bool value) { terminal.AddString("Devcommands: " + value); Set(value); } public static void EnableAutoFeatures() { if (!Terminal.m_cheat) { return; } Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).m_nview.IsValid()) { if (Settings.AutoGodMode && Settings.IsEnabled(PermissionHash.God, localValue: true)) { localPlayer.SetGodMode(true); } if (Settings.AutoGhostMode && Settings.IsEnabled(PermissionHash.Ghost, localValue: true)) { localPlayer.SetGhostMode(true); } if (Settings.AutoFly && Settings.IsEnabled(PermissionHash.Fly, localValue: true)) { localPlayer.m_debugFly = true; ((Character)localPlayer).m_nview.GetZDO().Set(ZDOVars.s_debugFly, true); } if (Settings.AutoNoCost && Settings.IsEnabled(PermissionHash.NoCost, localValue: true)) { localPlayer.m_noPlacementCost = true; } if (Settings.AutoDebugMode) { Player.m_debugMode = true; } } if (Object.op_Implicit((Object)(object)EnvMan.instance)) { if (Settings.AutoTod != "" && PermissionApi.IsCommandAllowed("tod")) { EnvMan.instance.m_debugTimeOfDay = true; EnvMan.instance.m_debugTime = Mathf.Clamp01(Parse.Float(Settings.AutoTod)); } if (Settings.AutoEnv != "" && PermissionApi.IsCommandAllowed("env")) { EnvMan.instance.m_debugEnv = Settings.AutoEnv; } } } public static void DisableAutoFeatures() { if (Terminal.m_cheat) { return; } Player localPlayer = Player.m_localPlayer; if (Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).m_nview.IsValid()) { if (Settings.AutoDebugMode) { Player.m_debugMode = false; } if (Settings.AutoGodMode) { localPlayer.SetGodMode(false); } if (Settings.AutoGhostMode) { localPlayer.SetGhostMode(false); } if (Settings.AutoFly) { localPlayer.m_debugFly = false; ((Character)localPlayer).m_nview.GetZDO().Set(ZDOVars.s_debugFly, false); } if (Settings.AutoNoCost) { localPlayer.m_noPlacementCost = false; } } if (Object.op_Implicit((Object)(object)EnvMan.instance)) { if (Settings.AutoTod != "") { EnvMan.instance.m_debugTimeOfDay = false; } if (Settings.AutoEnv != "") { EnvMan.instance.m_debugEnv = ""; } } } public static void SetCheats(bool value) { if (Terminal.m_cheat != value) { Gogan.LogEvent("Cheat", "CheatsEnabled", value.ToString(), 0L); } Terminal.m_cheat = value; } public static void Set(bool value) { SetCheats(value); Console instance = Console.instance; if (instance != null) { ((Terminal)instance).updateCommandList(); } Chat instance2 = Chat.instance; if (instance2 != null) { ((Terminal)instance2).updateCommandList(); } DisableAutoFeatures(); EnableAutoFeatures(); if (value && Settings.AutoExecDevOn != "") { Console instance3 = Console.instance; if (instance3 != null) { ((Terminal)instance3).TryRunCommand(Settings.AutoExecDevOn, false, false); } } if (!value && Settings.AutoExecDevOff != "") { Console instance4 = Console.instance; if (instance4 != null) { ((Terminal)instance4).TryRunCommand(Settings.AutoExecDevOff, false, false); } } } public DevcommandsCommand() { //IL_0039: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown object obj = <>c.<>9__5_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (Terminal.m_cheat) { Set(args.Context, value: false); } else if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer()) { Set(args.Context, value: true); } else { args.Context.AddString("Authenticating for devcommands..."); Admin.ManualCheck(); } }; <>c.<>9__5_0 = val; obj = (object)val; } new ConsoleCommand("devcommands", "Toggles cheats", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.RegisterEmpty("devcommands"); } } [HarmonyPatch(typeof(Terminal), "IsCheatsEnabled")] public class IsCheatsEnabledWithoutServerCheck { private static bool Postfix(bool result) { if (!result && (!SentinelBridge.Authorized || !Terminal.m_cheat)) { ZNet instance = ZNet.instance; if (instance == null) { return false; } return instance.IsDedicated(); } return true; } } [HarmonyPatch(typeof(ConsoleCommand), "IsValid")] public class IsValidWithoutServerCheck { private static bool Postfix(bool result) { if (!result && (!SentinelBridge.Authorized || !Terminal.m_cheat)) { ZNet instance = ZNet.instance; if (instance == null) { return false; } return instance.IsDedicated(); } return true; } } [HarmonyPatch(typeof(Terminal), "Awake")] public class AutoCompleteSecrets { private static void Postfix(Terminal __instance) { __instance.m_autoCompleteSecrets = true; } } public class DmgCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<PlayerInfo, string> <>9__0_2; public static ConsoleEvent <>9__0_0; public static Func<int, List<string>> <>9__0_1; internal void <.ctor>b__0_0(ConsoleEventArgs args) { //IL_00c9: 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_0091: 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_009b: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing target."); Helper.ArgsCheck(args, 3, "Missing amount."); string text = args.Args[1]; float num = Parse.Float(args.Args[2]); float num2 = Math.Abs(num); string arg = ((num >= 0f) ? " damage" : " healing"); List<PlayerInfo> list = PlayerInfo.FindPlayers(new string[1] { text }); foreach (PlayerInfo item in list) { if (num >= 0f) { HitData val = new HitData { m_damage = { m_damage = num }, m_hitType = (HitType)14 }; ZRoutedRpc.instance.InvokeRoutedRPC(0L, item.ZDOID, "RPC_Damage", new object[1] { val }); } else { ZRoutedRpc.instance.InvokeRoutedRPC(0L, item.ZDOID, "RPC_Heal", new object[2] { num2, true }); } } string text2 = string.Format("{0}{1} applied to: {2}", num2, arg, string.Join(", ", list.Select((PlayerInfo p) => p.Name))); args.Context.AddString(text2); } internal string <.ctor>b__0_2(PlayerInfo p) { return p.Name; } internal List<string> <.ctor>b__0_1(int index) { switch (index) { case 0: { string item = "others"; string item2 = "all"; List<string> playerNames = ParameterInfo.PlayerNames; List<string> list = new List<string>(2 + playerNames.Count); list.Add(item); list.Add(item2); list.AddRange(playerNames); return list; } case 1: return ParameterInfo.Create("Value", "Positive = damage / Negative = healing"); default: return ParameterInfo.None; } } } public DmgCommand() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_00c9: 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_0091: 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_009b: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing target."); Helper.ArgsCheck(args, 3, "Missing amount."); string text = args.Args[1]; float num = Parse.Float(args.Args[2]); float num2 = Math.Abs(num); string arg = ((num >= 0f) ? " damage" : " healing"); List<PlayerInfo> list = PlayerInfo.FindPlayers(new string[1] { text }); foreach (PlayerInfo item3 in list) { if (num >= 0f) { HitData val2 = new HitData { m_damage = { m_damage = num }, m_hitType = (HitType)14 }; ZRoutedRpc.instance.InvokeRoutedRPC(0L, item3.ZDOID, "RPC_Damage", new object[1] { val2 }); } else { ZRoutedRpc.instance.InvokeRoutedRPC(0L, item3.ZDOID, "RPC_Heal", new object[2] { num2, true }); } } string text2 = string.Format("{0}{1} applied to: {2}", num2, arg, string.Join(", ", list.Select((PlayerInfo p) => p.Name))); args.Context.AddString(text2); }; <>c.<>9__0_0 = val; obj = (object)val; } Helper.Command("dmg", "[target] [amount] - (Negative values heal the character).", (ConsoleEvent)obj); AutoComplete.Register("dmg", delegate(int index) { switch (index) { case 0: { string item = "others"; string item2 = "all"; List<string> playerNames = ParameterInfo.PlayerNames; List<string> list = new List<string>(2 + playerNames.Count); list.Add(item); list.Add(item2); list.AddRange(playerNames); return list; } case 1: return ParameterInfo.Create("Value", "Positive = damage / Negative = healing"); default: return ParameterInfo.None; } }); } } public class EnvCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static Func<int, List<string>> <>9__0_1; internal void <.ctor>b__0_0(ConsoleEventArgs args) { <>c__DisplayClass0_0 CS$<>8__locals6 = new <>c__DisplayClass0_0(); EnvMan instance = EnvMan.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } if (args.Length < 2) { Helper.AddMessage(args.Context, $"Environment: {instance.GetCurrentEnvironment()}."); return; } CS$<>8__locals6.text = string.Join(" ", args.Args, 1, args.Args.Length - 1); if (!EnvMan.instance.m_environments.Any((EnvSetup env) => env.m_name == CS$<>8__locals6.text)) { CS$<>8__locals6.text = CS$<>8__locals6.text.Replace("_", " "); } Helper.AddMessage(args.Context, "Setting debug environment: " + CS$<>8__locals6.text); instance.m_debugEnv = CS$<>8__locals6.text; } internal List<string> <.ctor>b__0_1(int index) { if (index != 0) { return ParameterInfo.None; } return ParameterInfo.Environments; } } [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public string text; internal bool <.ctor>b__2(EnvSetup env) { return env.m_name == text; } } public EnvCommand() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { EnvMan instance = EnvMan.instance; if (Object.op_Implicit((Object)(object)instance)) { if (args.Length < 2) { Helper.AddMessage(args.Context, $"Environment: {instance.GetCurrentEnvironment()}."); } else { string text = string.Join(" ", args.Args, 1, args.Args.Length - 1); if (!EnvMan.instance.m_environments.Any((EnvSetup env) => env.m_name == text)) { text = text.Replace("_", " "); } Helper.AddMessage(args.Context, "Setting debug environment: " + text); instance.m_debugEnv = text; } } }; <>c.<>9__0_0 = val; obj = (object)val; } Helper.Command("env", "[value] - Prints or overrides the environment.", (ConsoleEvent)obj); AutoComplete.Register("env", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Environments); } } public class FindCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<LocationInstance, Tuple<string, Vector3>> <>9__0_3; public static Func<ZDO, Tuple<string, Vector3>> <>9__0_5; public static Func<Tuple<string, Vector3>, string> <>9__0_8; public static Func<Tuple<string, Vector3>, string> <>9__0_9; public static ConsoleEvent <>9__0_0; public static Func<int, List<string>> <>9__0_1; internal void <.ctor>b__0_0(ConsoleEventArgs args) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) <>c__DisplayClass0_0 CS$<>8__locals24 = new <>c__DisplayClass0_0 { args = args }; Helper.ArgsCheck(CS$<>8__locals24.args, 2, "Missing the search term."); if (CS$<>8__locals24.args.Length < 3) { ConsoleEventArgs obj = CS$<>8__locals24.args; string[] args2 = CS$<>8__locals24.args.Args; int num = 0; string[] array = new string[1 + args2.Length]; ReadOnlySpan<string> readOnlySpan = new ReadOnlySpan<string>(args2); readOnlySpan.CopyTo(new Span<string>(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; array[num] = "10"; obj.Args = array; } string[] args3 = Helper.AddPlayerPosXZY(CS$<>8__locals24.args.Args, 3); if (!ZNet.instance.IsServer()) { ServerExecution.Send((IEnumerable<string>)args3); return; } CS$<>8__locals24.prefabs = Selector.GetAllPrefabs(new string[1] { CS$<>8__locals24.args[1] }); CS$<>8__locals24.pos = Parse.VectorXZY(string.Join(",", CS$<>8__locals24.args.Args.Skip(3))); List<LocationInstance> list = (from l in ZoneSystem.instance.GetLocationList() where Helper.IsValid(l.m_location) && l.m_location.m_prefab.Name == CS$<>8__locals24.args[1] select l).ToList(); if (CS$<>8__locals24.prefabs.Count <= 0 && list.Count <= 0) { <>c__DisplayClass0_1 CS$<>8__locals20 = new <>c__DisplayClass0_1 { lower = CS$<>8__locals24.args[1].ToLower() }; list = (from l in ZoneSystem.instance.GetLocationList() where Helper.IsValid(l.m_location) && l.m_location.m_prefab.Name.ToLower().Contains(CS$<>8__locals20.lower) select l).ToList(); CS$<>8__locals24.prefabs = Selector.GetAllPrefabs(new string[1] { "*" + CS$<>8__locals24.args[1] + "*" }); } List<Tuple<string, Vector3>> list2 = list.Select((LocationInstance l) => Tuple.Create<string, Vector3>(l.m_location.m_prefab.Name, l.m_position)).ToList(); IEnumerable<ZDO> source = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => zdo.IsValid() && CS$<>8__locals24.prefabs.Contains(zdo.GetPrefab())); list2.AddRange(source.Select((ZDO zdo) => Tuple.Create<string, Vector3>(((Object)ZNetScene.instance.GetPrefab(zdo.m_prefab)).name, zdo.GetPosition()))); list2.Sort((Tuple<string, Vector3> a, Tuple<string, Vector3> b) => Vector3.Distance(a.Item2, CS$<>8__locals24.pos).CompareTo(Vector3.Distance(b.Item2, CS$<>8__locals24.pos))); int count = list2.Count; list2 = list2.Take(Parse.Int(CS$<>8__locals24.args.Args, 2, 10)).ToList(); List<string> values = list2.Select((Tuple<string, Vector3> p) => Format(CS$<>8__locals24.pos, p.Item2, p.Item1)).ToList(); CS$<>8__locals24.args.Context.AddString($"Found {count} of {CS$<>8__locals24.args[1]}. Showing {list2.Count} closest:"); CS$<>8__locals24.args.Context.AddString(string.Join("\n", values)); if (RedirectOutput.Target == null) { ServerExecution.RPC_Do_Pins(null, string.Join("|", list2.Select((Tuple<string, Vector3> item) => Helper.PrintVectorXZY(item.Item2)))); return; } RedirectOutput.Target.Invoke(ServerExecution.RPC_Pins, new object[1] { string.Join("|", list2.Select((Tuple<string, Vector3> item) => Helper.PrintVectorXZY(item.Item2))) }); } internal Tuple<string, Vector3> <.ctor>b__0_3(LocationInstance l) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return Tuple.Create<string, Vector3>(l.m_location.m_prefab.Name, l.m_position); } internal Tuple<string, Vector3> <.ctor>b__0_5(ZDO zdo) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return Tuple.Create<string, Vector3>(((Object)ZNetScene.instance.GetPrefab(zdo.m_prefab)).name, zdo.GetPosition()); } internal string <.ctor>b__0_8(Tuple<string, Vector3> item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Helper.PrintVectorXZY(item.Item2); } internal string <.ctor>b__0_9(Tuple<string, Vector3> item) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Helper.PrintVectorXZY(item.Item2); } internal List<string> <.ctor>b__0_1(int index) { return index switch { 0 => ParameterInfo.Ids, 1 => ParameterInfo.Create("Max amount", "a positive integer (default 10)"), 2 => ParameterInfo.Create("X coordinate", "if not specified, the current position is used"), 3 => ParameterInfo.Create("Z coordinate", "if not specified, the current position is used"), _ => ParameterInfo.None, }; } } [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public ConsoleEventArgs args; public HashSet<int> prefabs; public Vector3 pos; internal bool <.ctor>b__2(LocationInstance l) { //IL_0000: 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) if (Helper.IsValid(l.m_location)) { return l.m_location.m_prefab.Name == args[1]; } return false; } internal bool <.ctor>b__4(ZDO zdo) { if (zdo.IsValid()) { return prefabs.Contains(zdo.GetPrefab()); } return false; } internal int <.ctor>b__6(Tuple<string, Vector3> a, Tuple<string, Vector3> b) { //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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(a.Item2, pos).CompareTo(Vector3.Distance(b.Item2, pos)); } internal string <.ctor>b__7(Tuple<string, Vector3> p) { //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) return Format(pos, p.Item2, p.Item1); } } [CompilerGenerated] private sealed class <>c__DisplayClass0_1 { public string lower; internal bool <.ctor>b__10(LocationInstance l) { //IL_0000: 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) if (Helper.IsValid(l.m_location)) { return l.m_location.m_prefab.Name.ToLower().Contains(lower); } return false; } } public FindCommand() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown ConsoleCommand val = Terminal.commands["find"]; string description = val.Description; object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val2 = delegate(ConsoleEventArgs args) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing the search term."); if (args.Length < 3) { ConsoleEventArgs obj2 = args; string[] args2 = args.Args; int num = 0; string[] array = new string[1 + args2.Length]; ReadOnlySpan<string> readOnlySpan = new ReadOnlySpan<string>(args2); readOnlySpan.CopyTo(new Span<string>(array).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; array[num] = "10"; obj2.Args = array; } string[] args3 = Helper.AddPlayerPosXZY(args.Args, 3); if (!ZNet.instance.IsServer()) { ServerExecution.Send((IEnumerable<string>)args3); } else { HashSet<int> prefabs = Selector.GetAllPrefabs(new string[1] { args[1] }); Vector3 pos = Parse.VectorXZY(string.Join(",", args.Args.Skip(3))); List<LocationInstance> list = (from l in ZoneSystem.instance.GetLocationList() where Helper.IsValid(l.m_location) && l.m_location.m_prefab.Name == args[1] select l).ToList(); if (prefabs.Count <= 0 && list.Count <= 0) { string lower = args[1].ToLower(); list = (from l in ZoneSystem.instance.GetLocationList() where Helper.IsValid(l.m_location) && l.m_location.m_prefab.Name.ToLower().Contains(lower) select l).ToList(); prefabs = Selector.GetAllPrefabs(new string[1] { "*" + args[1] + "*" }); } List<Tuple<string, Vector3>> list2 = list.Select((LocationInstance l) => Tuple.Create<string, Vector3>(l.m_location.m_prefab.Name, l.m_position)).ToList(); IEnumerable<ZDO> source = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => zdo.IsValid() && prefabs.Contains(zdo.GetPrefab())); list2.AddRange(source.Select((ZDO zdo) => Tuple.Create<string, Vector3>(((Object)ZNetScene.instance.GetPrefab(zdo.m_prefab)).name, zdo.GetPosition()))); list2.Sort((Tuple<string, Vector3> a, Tuple<string, Vector3> b) => Vector3.Distance(a.Item2, pos).CompareTo(Vector3.Distance(b.Item2, pos))); int count = list2.Count; list2 = list2.Take(Parse.Int(args.Args, 2, 10)).ToList(); List<string> values = list2.Select((Tuple<string, Vector3> p) => Format(pos, p.Item2, p.Item1)).ToList(); args.Context.AddString($"Found {count} of {args[1]}. Showing {list2.Count} closest:"); args.Context.AddString(string.Join("\n", values)); if (RedirectOutput.Target == null) { ServerExecution.RPC_Do_Pins(null, string.Join("|", list2.Select((Tuple<string, Vector3> item) => Helper.PrintVectorXZY(item.Item2)))); } else { RedirectOutput.Target.Invoke(ServerExecution.RPC_Pins, new object[1] { string.Join("|", list2.Select((Tuple<string, Vector3> item) => Helper.PrintVectorXZY(item.Item2))) }); } } }; <>c.<>9__0_0 = val2; obj = (object)val2; } Helper.Command("find", description, (ConsoleEvent)obj); AutoComplete.Register("find", (int index) => index switch { 0 => ParameterInfo.Ids, 1 => ParameterInfo.Create("Max amount", "a positive integer (default 10)"), 2 => ParameterInfo.Create("X coordinate", "if not specified, the current position is used"), 3 => ParameterInfo.Create("Z coordinate", "if not specified, the current position is used"), _ => ParameterInfo.None, }); } private static string Format(Vector3 pos, Vector3 p, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(pos, p); return string.Format(Settings.FindFormat.Replace("{pos_x", "{0").Replace("{pos_y", "{1").Replace("{pos_z", "{2") .Replace("{distance", "{3") .Replace("{name", "{4"), p.x, p.y, p.z, num, name); } } public class GotoCommand { private Vector3? LastPosition; private Quaternion? LastRotation; private void ParseArgs(ConsoleEventArgs args, Player player, ref Vector3 pos, ref Quaternion rot) { //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: 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_016c: 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_00f2: 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_006c: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a2: Unknown result type (might be due to invalid IL or missing references) if (args.Length < 2) { pos.y = WorldGenerator.instance.GetHeight(pos.x, pos.z); return; } if (args.Length == 2 && args[1] == "last") { if (!LastPosition.HasValue) { throw new InvalidOperationException("No last position"); } pos = (Vector3)(((??)LastPosition) ?? pos); rot = (Quaternion)(((??)LastRotation) ?? rot); return; } string[] array = Parse.Split(args[1]); if (args.Length > 2) { array = args.Args.Skip(1).ToArray(); } if (Parse.TryFloat(array[0], out var value)) { if (array.Length < 2) { pos.y = value; return; } Vector3 val = Parse.VectorXZY(array); float num = (((Character)player).IsDebugFlying() ? ((Component)player).transform.position.y : WorldGenerator.instance.GetHeight(val.x, val.z)); pos = Parse.VectorXZY(array, new Vector3(pos.x, num, pos.z)); } else { PlayerInfo val2 = Helper.FindPlayer(string.Join(" ", args.Args.Skip(1))); pos = val2.m_position; } } public GotoCommand() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown AutoComplete.Register("goto", delegate(int index, int subIndex) { if (index == 0 && subIndex == 0) { return ParameterInfo.PublicPlayerNames; } return (index == 0) ? ParameterInfo.XZY("Coordinates", subIndex) : ParameterInfo.XZY("Coordinates", index); }); Helper.Command("goto", "[x,z,y or altitude or last or player or no parameter] - Teleports to the coordinates. If y is not given, teleports to the ground level.", (ConsoleEvent)delegate(ConsoleEventArgs args) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: 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_0057: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Player player = Helper.GetPlayer(); Vector3 pos = ((Component)player).transform.position; Quaternion rot = ((Component)player).transform.rotation; ParseArgs(args, player, ref pos, ref rot); LastPosition = ((Component)player).transform.position; LastRotation = ((Component)player).transform.rotation; ((Character)player).TeleportTo(pos, rot, true); Helper.AddMessage(args.Context, $"Teleported to (X,Z,Y): {pos.x}, {pos.z}, {pos.y}."); }); } } [HarmonyPatch(typeof(Player), "TeleportTo")] public class FasterTeleport1 { private static void Postfix(Player __instance, bool __result) { if (Settings.DebugModeFastTeleport && __result && Player.m_debugMode) { __instance.m_teleportTimer = 15f; } } } [HarmonyPatch(typeof(Player), "UpdateTeleport")] public class FasterTeleport2 { private static void Postfix(Player __instance) { if (Settings.DebugModeFastTeleport && Player.m_debugMode) { __instance.m_teleportCooldown = Mathf.Max(__instance.m_teleportCooldown, 1.5f); } } } public class HUDCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static Func<int, List<string>> <>9__0_1; internal void <.ctor>b__0_0(ConsoleEventArgs args) { if (!Object.op_Implicit((Object)(object)Hud.m_instance)) { Helper.AddMessage(args.Context, "Error: No HUD instance."); return; } if (args.Length >= 2) { Hud.m_instance.m_userHidden = args[1] != "1"; } else { Hud.m_instance.m_userHidden = !Hud.m_instance.m_userHidden; } string text = (Hud.m_instance.m_userHidden ? "disabled" : "enabled"); Helper.AddMessage(args.Context, "Hud " + text + "."); } internal List<string> <.ctor>b__0_1(int index) { if (index == 0) { return ParameterInfo.Create("1 = enable, 0 = disable, no value = toggle"); } return ParameterInfo.None; } } public HUDCommand() { //IL_0039: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { if (!Object.op_Implicit((Object)(object)Hud.m_instance)) { Helper.AddMessage(args.Context, "Error: No HUD instance."); } else { if (args.Length >= 2) { Hud.m_instance.m_userHidden = args[1] != "1"; } else { Hud.m_instance.m_userHidden = !Hud.m_instance.m_userHidden; } string text = (Hud.m_instance.m_userHidden ? "disabled" : "enabled"); Helper.AddMessage(args.Context, "Hud " + text + "."); } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("hud", "[value] - Toggles or sets the HUD visibility.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.Register("hud", (int index) => (index == 0) ? ParameterInfo.Create("1 = enable, 0 = disable, no value = toggle") : ParameterInfo.None); } } public class InventoryCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<ItemData, bool> <>9__5_2; public static Func<ItemData, bool> <>9__5_3; public static Func<ItemData, bool> <>9__5_4; public static ConsoleEvent <>9__5_0; public static Func<int, List<string>> <>9__5_1; internal void <.ctor>b__5_0(ConsoleEventArgs args) { <>c__DisplayClass5_0 CS$<>8__locals8 = new <>c__DisplayClass5_0(); Helper.ArgsCheck(args, 2, "Missing clear, level, refill, repair or upgrade."); CS$<>8__locals8.amount = Parse.IntNull(args.Args, 2); string text = Parse.String(args.Args, 3, "all"); if (!CS$<>8__locals8.amount.HasValue) { text = Parse.String(args.Args, 2, "all"); CS$<>8__locals8.amount = Parse.IntNull(args.Args, 3); } Player player = Helper.GetPlayer(); Inventory inventory = ((Humanoid)player).GetInventory(); List<ItemData> list = inventory.GetAllItems(); if (text == "hand" || text == "worn") { list = inventory.GetEquippedItems(); } if (text == "hand") { list = list.Where((ItemData item) => HandTypes.Contains(item.m_shared.m_itemType)).ToList(); } switch (args[