Decompiled source of RunicSentinel v1.6.1

plugins/RunicSentinel/RunicSentinel.dll

Decompiled a week ago
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 GUIFramework;
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.Input;
using RunicSentinel.PlayerActions;
using RunicSentinel.Runtime;
using Splatform;
using Steamworks;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
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")]
[assembly: AssemblyDescription("Pinned-RSA policy verification, direct server-gated client admission, and bounded transport-identity evidence")]
[assembly: AssemblyCompany("Chazman")]
[assembly: AssemblyProduct("Runic Sentinel")]
[assembly: AssemblyFileVersion("1.6.1.0")]
[assembly: AssemblyInformationalVersion("1.6.1")]
[assembly: InternalsVisibleTo("RunicSentinel.Tests")]
[assembly: InternalsVisibleTo("RunicSentinel.Forge")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace 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
{
	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 ConfigEntry<KeyboardShortcut> AdminPanelKey;

		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
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			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>()));
			AdminPanelKey = config.Bind<KeyboardShortcut>("Administrator Panel", "OpenPanel", new KeyboardShortcut((KeyCode)284, Array.Empty<KeyCode>()), RunicText.Get("text_629c5f55524d"));
			PolicyFile.SettingChanged += Notify;
			SignatureFile.SettingChanged += Notify;
			PublicKeyFile.SettingChanged += Notify;
			TrustedPublicKeySha256.SettingChanged += Notify;
			AdminPanelKey.SettingChanged += Notify;
		}

		private static void Notify(object sender, EventArgs args)
		{
			SentinelConfig.Changed?.Invoke();
		}
	}
	[BepInPlugin("chazman.RunicSentinel", "Runic Sentinel", "1.6.1")]
	[BepInIncompatibility("server_devcommands")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInIncompatibility("chazman.RunicSentinelServer")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "chazman.RunicSentinel";

		public const string Name = "Runic Sentinel";

		public const string Version = "1.6.1";

		public const string ModuleId = "runic.sentinel";

		private SentinelRuntime _runtime;

		private SentinelEnforcementRuntime _enforcement;

		private SentinelOperatorCommands _operatorCommands;

		private SentinelManagedPolicyService _managedPolicy;

		private SentinelAdminControl _adminControl;

		private SentinelAdminPanel _adminPanel;

		private SentinelFlightRecorder _flightRecorder;

		private Harmony _harmony;

		private int _refreshRequested;

		private bool _runtimeStarted;

		public static bool PlayerActionsAvailable { get; private set; }

		public static bool BuildingLimitsAvailable { get; private set; }

		private void Awake()
		{
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			SentinelConfig.Bind(((BaseUnityPlugin)this).Config);
			ConfigEntry<bool> enabled = SentinelConfig.Enabled;
			if (enabled != null && !enabled.Value)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Sentinel is disabled; no worker or network handlers were created.");
				return;
			}
			try
			{
				SentinelBuildingLimits.Configure(((BaseUnityPlugin)this).Config);
				_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);
				PlayerActionsAvailable = true;
				_adminPanel = new SentinelAdminPanel(_adminControl);
				_harmony = new Harmony("chazman.RunicSentinel");
				Engine.Init(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
				_harmony.PatchAll(typeof(Plugin).Assembly);
				BuildingLimitsAvailable = true;
				SentinelConfig.Changed += Refresh;
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Runic Sentinel v1.6.1 initialized as a standalone plugin. Signed passports enforce exact plugin profiles, administrators, and banned accounts; Required admission gates the exact direct Valheim connection before its native admission. The complete plugin snapshot starts after chainloader initialization.");
			}
			catch (Exception ex)
			{
				Shutdown();
				((BaseUnityPlugin)this).Logger.LogError((object)("Runic Sentinel failed closed: " + ex));
			}
		}

		private void Start()
		{
			if (_runtime == null || _runtimeStarted)
			{
				return;
			}
			try
			{
				_runtime.Start(Paths.ConfigPath);
				_runtimeStarted = true;
			}
			catch (Exception ex)
			{
				Shutdown();
				((BaseUnityPlugin)this).Logger.LogError((object)("Runic Sentinel snapshot startup failed closed: " + ex));
			}
		}

		private void Refresh()
		{
			Interlocked.Exchange(ref _refreshRequested, 1);
		}

		private void Update()
		{
			try
			{
				_runtime?.TickNetwork();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel network request stopped: " + ex.Message));
			}
			try
			{
				_runtime?.TickIntegrity();
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel runtime-integrity check failed closed: " + ex2.Message));
			}
			try
			{
				_adminControl?.Tick();
				if (_adminControl != null)
				{
					Engine.Tick();
				}
			}
			catch (Exception ex3)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel admin transport stopped safely: " + ex3.Message));
			}
			try
			{
				_adminPanel?.Tick();
			}
			catch (Exception ex4)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel administrator panel stopped safely: " + ex4.Message));
			}
			try
			{
				_operatorCommands?.TickDedicatedConsole();
			}
			catch (Exception ex5)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel dedicated console input stopped safely: " + ex5.Message));
			}
			if (Interlocked.Exchange(ref _refreshRequested, 0) == 0 || _runtime == null)
			{
				return;
			}
			try
			{
				_runtime.Start(Paths.ConfigPath);
			}
			catch (Exception ex6)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Sentinel policy refresh failed closed: " + ex6.Message));
			}
		}

		private void OnGUI()
		{
			try
			{
				_adminPanel?.Draw();
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Sentinel administrator panel draw failed safely: " + ex.Message));
			}
		}

		private void OnDestroy()
		{
			Shutdown();
		}

		private void Shutdown()
		{
			BuildingLimitsAvailable = false;
			PlayerActionsAvailable = false;
			try
			{
				Engine.Stop();
			}
			catch
			{
			}
			SentinelConfig.Changed -= Refresh;
			Interlocked.Exchange(ref _refreshRequested, 0);
			_runtimeStarted = false;
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			_harmony = null;
			SentinelBuildingLimits.Reset();
			SentinelSteamSessions.Reset();
			try
			{
				_adminPanel?.Dispose();
			}
			catch
			{
			}
			_adminPanel = null;
			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;
		}
	}
}
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");
		}

		[HarmonyPatch(typeof(Chat), "Update")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> DisableDefaultBindExecution(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)typeof(Chat).GetField("m_wasFocused", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), (string)null)
			}).Advance(4).Insert((CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Pop, (object)null),
				new CodeInstruction(OpCodes.Ldc_I4_1, (object)null)
			})
				.InstructionEnumeration();
		}

		[HarmonyPatch(typeof(Chat), "Update")]
		[HarmonyPostfix]
		private static void ExecuteBestBinds(Chat __instance)
		{
			if (((TMP_InputField)((Terminal)__instance).m_input).isFocused || (Object.op_Implicit((Object)(object)Console.instance) && ((Component)((Terminal)Console.instance).m_chatWindow).gameObject.activeInHierarchy))
			{
				return;
			}
			foreach (CommandBind bestKeyCommand in BindManager.GetBestKeyCommands())
			{
				bestKeyCommand.Executed = true;
				if (!bestKeyCommand.WasExecuted && !(bestKeyCommand.Command == ""))
				{
					((Terminal)__instance).TryRunCommand(bestKeyCommand.Command, true, true);
				}
			}
			foreach (CommandBind offBind in BindManager.GetOffBinds())
			{
				offBind.WasExecuted = false;
				if (!(offBind.OffCommand == ""))
				{
					((Terminal)__instance).TryRunCommand(offBind.OffCommand, true, true);
				}
			}
		}

		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[1])
				{
				case "repair":
				{
					ItemData[] array5 = list.Where((ItemData item) => item.m_durability < item.GetMaxDurability()).ToArray();
					ItemData[] array2 = array5;
					foreach (ItemData obj3 in array2)
					{
						obj3.m_durability = obj3.GetMaxDurability();
					}
					Helper.AddMessage(args.Context, $"{array5.Length} items repaired.");
					break;
				}
				case "refill":
				{
					ItemData[] array3 = list.Where((ItemData item) => item.m_stack < item.m_shared.m_maxStackSize).ToArray();
					ItemData[] array2 = array3;
					foreach (ItemData obj in array2)
					{
						obj.m_stack = obj.m_shared.m_maxStackSize;
					}
					Helper.AddMessage(args.Context, $"{array3.Length} items filled.");
					break;
				}
				case "clear":
					((Humanoid)player).UnequipAllItems();
					Helper.AddMessage(args.Context, $"{list.Count} items cleared.");
					inventory.RemoveAll();
					break;
				case "level":
				{
					if (!CS$<>8__locals8.amount.HasValue)
					{
						throw new InvalidOperationException("Missing the level.");
					}
					ItemData[] array4 = list.Where(Valid).ToArray();
					ItemData[] array2 = array4;
					foreach (ItemData obj2 in array2)
					{
						obj2.m_quality = CS$<>8__locals8.amount.Value;
						obj2.m_durability = obj2.GetMaxDurability();
					}
					Helper.AddMessage(args.Context, $"{array4.Length} items upgraded.");
					break;
				}
				case "upgrade":
				{
					ItemData[] array = list.Where((ItemData item) => Valid(item) && (CS$<>8__locals8.amount.HasValue || item.m_quality != item.m_shared.m_maxQuality)).ToArray();
					ItemData[] array2 = array;
					foreach (ItemData val in array2)
					{
						if (CS$<>8__locals8.amount.HasValue)
						{
							val.m_quality = CS$<>8__locals8.amount.Value;
						}
						else
						{
							val.m_quality = val.m_shared.m_maxQuality;
						}
						val.m_durability = val.GetMaxDurability();
					}
					Helper.AddMessage(args.Context, $"{array.Length} items upgraded.");
					break;
				}
				default:
					throw new InvalidOperationException("Invalid operation. Use level, repair or upgrade.");
				}
				inventory.Changed(false, false);
			}

			internal bool <.ctor>b__5_2(ItemData item)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				return HandTypes.Contains(item.m_shared.m_itemType);
			}

			internal bool <.ctor>b__5_3(ItemData item)
			{
				return item.m_durability < item.GetMaxDurability();
			}

			internal bool <.ctor>b__5_4(ItemData item)
			{
				return item.m_stack < item.m_shared.m_maxStackSize;
			}

			internal List<string> <.ctor>b__5_1(int index)
			{
				return index switch
				{
					0 => Operations, 
					1 => Targets, 
					2 => ParameterInfo.Create("Amount", "How many levels to upgrade."), 
					_ => ParameterInfo.None, 
				};
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass5_0
		{
			public int? amount;

			internal bool <.ctor>b__5(ItemData item)
			{
				if (Valid(item))
				{
					if (!amount.HasValue)
					{
						return item.m_quality != item.m_shared.m_maxQuality;
					}
					return true;
				}
				return false;
			}
		}

		private static readonly List<string> Operations = new List<string>(5) { "clear", "level", "refill", "repair", "upgrade" };

		private static readonly List<string> Targets = new List<string>(3) { "all", "hand", "worn" };

		private static readonly HashSet<ItemType> HandTypes = new HashSet<ItemType>
		{
			(ItemType)4,
			(ItemType)3,
			(ItemType)5,
			(ItemType)15,
			(ItemType)19,
			(ItemType)14
		};

		private static readonly HashSet<ItemType> ArmorTypes = new HashSet<ItemType>
		{
			(ItemType)7,
			(ItemType)12,
			(ItemType)6,
			(ItemType)11,
			(ItemType)17
		};

		private static bool Valid(ItemData item)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (item.m_shared.m_maxQuality <= 1 && !HandTypes.Contains(item.m_shared.m_itemType))
			{
				return ArmorTypes.Contains(item.m_shared.m_itemType);
			}
			return true;
		}

		public InventoryCommand()
		{
			//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)
				{
					Helper.ArgsCheck(args, 2, "Missing clear, level, refill, repair or upgrade.");
					int? amount = Parse.IntNull(args.Args, 2);
					string text = Parse.String(args.Args, 3, "all");
					if (!amount.HasValue)
					{
						text = Parse.String(args.Args, 2, "all");
						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[1])
					{
					case "repair":
					{
						ItemData[] array5 = list.Where((ItemData item) => item.m_durability < item.GetMaxDurability()).ToArray();
						ItemData[] array2 = array5;
						foreach (ItemData obj4 in array2)
						{
							obj4.m_durability = obj4.GetMaxDurability();
						}
						Helper.AddMessage(args.Context, $"{array5.Length} items repaired.");
						break;
					}
					case "refill":
					{
						ItemData[] array3 = list.Where((ItemData item) => item.m_stack < item.m_shared.m_maxStackSize).ToArray();
						ItemData[] array2 = array3;
						foreach (ItemData obj2 in array2)
						{
							obj2.m_stack = obj2.m_shared.m_maxStackSize;
						}
						Helper.AddMessage(args.Context, $"{array3.Length} items filled.");
						break;
					}
					case "clear":
						((Humanoid)player).UnequipAllItems();
						Helper.AddMessage(args.Context, $"{list.Count} items cleared.");
						inventory.RemoveAll();
						break;
					case "level":
					{
						if (!amount.HasValue)
						{
							throw new InvalidOperationException("Missing the level.");
						}
						ItemData[] array4 = list.Where(Valid).ToArray();
						ItemData[] array2 = array4;
						foreach (ItemData obj3 in array2)
						{
							obj3.m_quality = amount.Value;
							obj3.m_durability = obj3.GetMaxDurability();
						}
						Helper.AddMessage(args.Context, $"{array4.Length} items upgraded.");
						break;
					}
					case "upgrade":
					{
						ItemData[] array = list.Where((ItemData item) => Valid(item) && (amount.HasValue || item.m_quality != item.m_shared.m_maxQuality)).ToArray();
						ItemData[] array2 = array;
						foreach (ItemData val2 in array2)
						{
							if (amount.HasValue)
							{
								val2.m_quality = amount.Value;
							}
							else
							{
								val2.m_quality = val2.m_shared.m_maxQuality;
							}
							val2.m_durability = val2.GetMaxDurability();
						}
						Helper.AddMessage(args.Context, $"{array.Length} items upgraded.");
						break;
					}
					default:
						throw new InvalidOperationException("Invalid operation. Use level, repair or upgrade.");
					}
					inventory.Changed(false, false);
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			Helper.Command("inventory", "[level/repair/upgrade] [hand/worn/all] [amount or max level if not given] - Modifies items in the inventory.", (ConsoleEvent)obj);
			AutoComplete.Register("inventory", (int index) => index switch
			{
				0 => Operations, 
				1 => Targets, 
				2 => ParameterInfo.Create("Amount", "How many levels to upgrade."), 
				_ => ParameterInfo.None, 
			});
		}
	}
	public class KillCommand
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__0_0;

			public static ConsoleEvent <>9__0_1;

			internal void <.ctor>b__0_0(ConsoleEventArgs args)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Expected O, but got Unkno