Decompiled source of Server devcommands v1.97.0

ServerDevcommands.dll

Decompiled 2 weeks 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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GUIFramework;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ServerDevcommands;
using Service;
using Splatform;
using Steamworks;
using TMPro;
using UnityEngine;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.ObjectPool;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ServerDevcommands")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1beba57fbfc1c16d36f9af3dfc5104b1335c7db5")]
[assembly: AssemblyProduct("ServerDevcommands")]
[assembly: AssemblyTitle("ServerDevcommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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 Service
{
	public class PlayerInfo
	{
		public string Name;

		public Vector3 Pos;

		public Quaternion Rot;

		public string HostId;

		public long PeerId;

		public ZDOID ZDOID;

		public PlayerInfo(ZNetPeer peer)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0067: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			HostId = peer.m_rpc.GetSocket().GetHostName();
			Name = peer.m_playerName;
			Pos = peer.m_refPos;
			ZDOID = peer.m_characterID;
			PeerId = ((ZDOID)(ref ZDOID)).UserID;
			ZDO zDO = ZDOMan.instance.GetZDO(peer.m_characterID);
			if (zDO != null)
			{
				Pos = zDO.m_position;
				Rot = zDO.GetRotation();
			}
		}

		public PlayerInfo(PlayerInfo info)
		{
			//IL_0024: 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_0031: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			HostId = ((object)(PlatformUserID)(ref info.m_userInfo.m_id)).ToString();
			Name = info.m_name;
			Pos = info.m_position;
			ZDOID = info.m_characterID;
			PeerId = ((ZDOID)(ref ZDOID)).UserID;
			ZDO zDO = ZDOMan.instance.GetZDO(info.m_characterID);
			if (zDO != null)
			{
				Pos = zDO.m_position;
				Rot = zDO.GetRotation();
			}
		}

		public PlayerInfo(Player player)
		{
			//IL_001f: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			HostId = "self";
			Name = player.GetPlayerName();
			ZDOID = ((Character)player).GetZDOID();
			PeerId = ((ZDOID)(ref ZDOID)).UserID;
			Pos = ((Component)player).transform.position;
			Rot = ((Component)player).transform.rotation;
		}

		public static List<PlayerInfo> FindPlayers(string[] args)
		{
			//IL_0169: 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_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerInfo> list = (ZNet.instance.IsServer() ? (from peer in ZNet.instance.GetPeers()
				select new PlayerInfo(peer)).ToList() : ZNet.instance.m_players.Select((PlayerInfo player) => new PlayerInfo(player)).ToList());
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && list.All((PlayerInfo p) => p.ZDOID != ((Character)Player.m_localPlayer).GetZDOID()))
			{
				list.Add(new PlayerInfo(Player.m_localPlayer));
			}
			Dictionary<ZDOID, PlayerInfo> dictionary = new Dictionary<ZDOID, PlayerInfo>();
			foreach (string text in args)
			{
				switch (text)
				{
				case "*":
				case "all":
					return list;
				case "others":
				{
					List<PlayerInfo> list2 = new List<PlayerInfo>();
					list2.AddRange(list.Where((PlayerInfo p) => p.ZDOID != ((Character)Player.m_localPlayer).GetZDOID()));
					return list2;
				}
				}
				string text2 = text.ToLowerInvariant();
				foreach (PlayerInfo item in list)
				{
					string text3 = item.Name.ToLowerInvariant();
					if (item.HostId == text)
					{
						dictionary[item.ZDOID] = item;
					}
					else if (text3 == text2)
					{
						dictionary[item.ZDOID] = item;
					}
					else if (text2[0] == '*' && text2[text2.Length - 1] == '*' && text3.Contains(text2.Substring(1, text2.Length - 2)))
					{
						dictionary[item.ZDOID] = item;
					}
					else if (text2[0] == '*' && item.Name.EndsWith(text2.Substring(1), StringComparison.OrdinalIgnoreCase))
					{
						dictionary[item.ZDOID] = item;
					}
					else if (text2[text2.Length - 1] == '*' && item.Name.StartsWith(text2.Substring(0, text2.Length - 1), StringComparison.OrdinalIgnoreCase))
					{
						dictionary[item.ZDOID] = item;
					}
				}
			}
			Dictionary<ZDOID, PlayerInfo>.ValueCollection values = dictionary.Values;
			List<PlayerInfo> list3 = new List<PlayerInfo>(values.Count);
			list3.AddRange(values);
			if (list3.Count == 0)
			{
				throw new InvalidOperationException("No target player found with id/name '" + string.Join(",", args) + "'.");
			}
			return list3;
		}
	}
	public class Hovered
	{
		public ZNetView Obj;

		public int Index;

		public Hovered(ZNetView obj, int index)
		{
			Obj = obj;
			Index = index;
			base..ctor();
		}
	}
	public static class Selector
	{
		private static KeyValuePair<int, int> RaftParent = ZDO.GetHashZDOID("MBParent");

		public static bool IsValid(ZNetView view)
		{
			if (Object.op_Implicit((Object)(object)view))
			{
				return IsValid(view.GetZDO());
			}
			return false;
		}

		public static bool IsValid(ZDO zdo)
		{
			if (zdo != null)
			{
				return zdo.IsValid();
			}
			return false;
		}

		public static ZNetView? GetHovered(float range, string[] included, string[] excluded)
		{
			return GetHovered(range, included, new HashSet<string>(), excluded);
		}

		public static ZNetView? GetHovered(float range, string[] included, HashSet<string> types, string[] excluded)
		{
			return GetHovered(Player.m_localPlayer, range, included, types, excluded)?.Obj;
		}

		public static int GetPrefabFromHit(RaycastHit hit)
		{
			return ((Component)((RaycastHit)(ref hit)).collider).GetComponentInParent<ZNetView>().GetZDO().GetPrefab();
		}

		public static Hovered? GetHovered(Player obj, float maxDistance, string[] included, string[] excluded, bool allowOtherPlayers = false)
		{
			return GetHovered(obj, maxDistance, included, new HashSet<string>(), excluded, allowOtherPlayers);
		}

		public static Hovered? GetHovered(Player obj, float maxDistance, string[] included, HashSet<string> types, string[] excluded, bool allowOtherPlayers = false)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			allowOtherPlayers |= included.Contains("Player");
			HashSet<int> allPrefabs = GetAllPrefabs(included);
			if (included.Length != 0 && allPrefabs.Count == 0)
			{
				throw new InvalidOperationException("No valid prefabs found.");
			}
			HashSet<int> excludedPrefabs = GetExcludedPrefabs(excluded);
			float num = Math.Max(maxDistance + 5f, 50f);
			int mask = LayerMask.GetMask(new string[11]
			{
				"item", "piece", "piece_nonsolid", "Default", "static_solid", "Default_small", "character", "character_net", "terrain", "vehicle",
				"character_trigger"
			});
			RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, num, mask);
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			RaycastHit[] array2 = array;
			MineRock5 val2 = default(MineRock5);
			MineRock val3 = default(MineRock);
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				if (Vector3.Distance(((RaycastHit)(ref val)).point, ((Character)obj).m_eye.position) >= maxDistance)
				{
					continue;
				}
				ZNetView componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<ZNetView>();
				if (!IsValid(componentInParent) || (allPrefabs.Count > 0 && !allPrefabs.Contains(componentInParent.GetZDO().GetPrefab())) || excludedPrefabs.Contains(componentInParent.GetZDO().GetPrefab()) || Object.op_Implicit((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponent<EffectArea>()))
				{
					continue;
				}
				Player componentInChildren = ((Component)componentInParent).GetComponentInChildren<Player>();
				if ((Object)(object)componentInChildren == (Object)(object)obj || (!allowOtherPlayers && Object.op_Implicit((Object)(object)componentInChildren)) || (types.Count > 0 && !ComponentInfo.HasComponent(componentInParent, types)))
				{
					continue;
				}
				int index = -1;
				if (((Component)componentInParent).TryGetComponent<MineRock5>(ref val2))
				{
					index = val2.GetAreaIndex(((RaycastHit)(ref val)).collider);
				}
				if (((Component)componentInParent).TryGetComponent<MineRock>(ref val3))
				{
					index = val3.GetAreaIndex(((RaycastHit)(ref val)).collider);
				}
				Room componentInParent2 = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Room>();
				if (Object.op_Implicit((Object)(object)componentInParent2))
				{
					Transform transform = ((Component)componentInParent).transform;
					for (int j = 0; j < transform.childCount; j++)
					{
						if ((Object)(object)((Component)transform.GetChild(j)).gameObject == (Object)(object)((Component)componentInParent2).gameObject)
						{
							index = j;
							break;
						}
					}
				}
				return new Hovered(componentInParent, index);
			}
			return null;
		}

		private static float GetX(float x, float y, float angle)
		{
			return Mathf.Cos(angle) * x - Mathf.Sin(angle) * y;
		}

		private static float GetY(float x, float y, float angle)
		{
			return Mathf.Sin(angle) * x + Mathf.Cos(angle) * y;
		}

		public static bool Within(Vector3 position, Vector3 center, float angle, Range<float> width, Range<float> depth, float height)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			float x = position.x - center.x;
			float y = position.z - center.z;
			float x2 = GetX(x, y, angle);
			float y2 = GetY(x, y, angle);
			if (!WithinHeight(position, center, height))
			{
				return false;
			}
			return Helper.Within(width, depth, Mathf.Abs(x2), Mathf.Abs(y2));
		}

		public static bool Within(Vector3 position, Vector3 center, Range<float> radius, float height)
		{
			//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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!WithinHeight(position, center, height))
			{
				return false;
			}
			return Helper.Within(radius, Utils.DistanceXZ(position, center));
		}

		private static bool WithinHeight(Vector3 position, Vector3 center, float height)
		{
			//IL_0000: 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)
			float y = center.y;
			float y2 = position.y;
			if (Helper.IsZero(height))
			{
				return Mathf.Abs(y2 - y) <= 1000f;
			}
			float num = Mathf.Min(y, y + height);
			float num2 = Mathf.Max(y, y + height);
			if (y2 >= num)
			{
				return y2 <= num2;
			}
			return false;
		}

		private static bool IsIncluded(string id, string name)
		{
			if (id.StartsWith("*", StringComparison.Ordinal) && id.EndsWith("*", StringComparison.Ordinal))
			{
				return name.Contains(id.Substring(1, id.Length - 3));
			}
			if (id.StartsWith("*", StringComparison.Ordinal))
			{
				return name.EndsWith(id.Substring(1), StringComparison.Ordinal);
			}
			if (id.EndsWith("*", StringComparison.Ordinal))
			{
				return name.StartsWith(id.Substring(0, id.Length - 2), StringComparison.Ordinal);
			}
			return id == name;
		}

		public static HashSet<int> GetExcludedPrefabs(string[] ids)
		{
			HashSet<int> hashSet = new HashSet<int>();
			foreach (string id in ids)
			{
				hashSet.UnionWith(GetExcludedPrefabs(id));
			}
			return hashSet;
		}

		private static HashSet<int> GetExcludedPrefabs(string id)
		{
			string id2 = id;
			if (id2 == "")
			{
				return new HashSet<int>();
			}
			id2 = id2.ToLower();
			return (from prefab in ZNetScene.instance.m_namedPrefabs.Values
				where IsIncluded(id2, ((Object)prefab).name.ToLower())
				select StringExtensionMethods.GetStableHashCode(((Object)prefab).name)).ToHashSet();
		}

		public static HashSet<int> GetPrefabs(string[] ids)
		{
			if (ids.Length == 0)
			{
				return GetSafePrefabs("");
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (string id in ids)
			{
				hashSet.UnionWith(GetSafePrefabs(id));
			}
			return hashSet;
		}

		public static HashSet<int> GetAllPrefabs(string[] ids)
		{
			if (ids.Length == 0)
			{
				return new HashSet<int>();
			}
			HashSet<int> hashSet = new HashSet<int>();
			foreach (string id in ids)
			{
				hashSet.UnionWith(GetAllPrefabs(id));
			}
			return hashSet;
		}

		private static HashSet<int> GetSafePrefabs(string id)
		{
			string id2 = id;
			id2 = id2.ToLower();
			IEnumerable<GameObject> source = ZNetScene.instance.m_namedPrefabs.Values;
			if (id2 != "player")
			{
				source = source.Where((GameObject prefab) => ((Object)prefab).name != "Player");
			}
			source = ((id2 == "*" || id2 == "") ? source.Where((GameObject prefab) => !((Object)prefab).name.StartsWith("_", StringComparison.Ordinal)) : ((!id2.Contains("*")) ? source.Where((GameObject prefab) => ((Object)prefab).name.ToLower() == id2) : source.Where((GameObject prefab) => IsIncluded(id2, ((Object)prefab).name.ToLower()))));
			return source.Select((GameObject prefab) => StringExtensionMethods.GetStableHashCode(((Object)prefab).name)).ToHashSet();
		}

		private static HashSet<int> GetAllPrefabs(string id)
		{
			string id2 = id;
			id2 = id2.ToLower();
			IEnumerable<GameObject> source = ZNetScene.instance.m_namedPrefabs.Values;
			if (!(id2 == "*") && !(id2 == ""))
			{
				source = ((!id2.Contains("*")) ? source.Where((GameObject prefab) => ((Object)prefab).name.ToLower() == id2) : source.Where((GameObject prefab) => IsIncluded(id2, ((Object)prefab).name.ToLower())));
			}
			return source.Select((GameObject prefab) => StringExtensionMethods.GetStableHashCode(((Object)prefab).name)).ToHashSet();
		}

		public static ZNetView[] GetNearby(string[] included, HashSet<string> types, string[] excluded, Vector3 center, Range<float> radius, float height)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Range<float> radius2 = radius;
			HashSet<int> prefabs = GetPrefabs(included);
			if (included.Length != 0 && prefabs.Count == 0)
			{
				throw new InvalidOperationException("No valid prefabs found.");
			}
			HashSet<int> excludedPrefabs = GetExcludedPrefabs(excluded);
			return GetNearby(prefabs, types, excludedPrefabs, checker);
			bool checker(Vector3 pos)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return Within(pos, center, radius2, height);
			}
		}

		public static ZNetView[] GetNearby(string[] included, HashSet<string> types, string[] excluded, Vector3 center, float angle, Range<float> width, Range<float> depth, float height)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			Range<float> width2 = width;
			Range<float> depth2 = depth;
			HashSet<int> prefabs = GetPrefabs(included);
			if (included.Length != 0 && prefabs.Count == 0)
			{
				throw new InvalidOperationException("No valid prefabs found.");
			}
			HashSet<int> excludedPrefabs = GetExcludedPrefabs(excluded);
			return GetNearby(prefabs, types, excludedPrefabs, checker);
			bool checker(Vector3 pos)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return Within(pos, center, angle, width2, depth2, height);
			}
		}

		public static ZNetView[] GetNearby(HashSet<int> included, HashSet<string> types, HashSet<int> excluded, Func<Vector3, bool> checker)
		{
			HashSet<int> included2 = included;
			HashSet<int> excluded2 = excluded;
			Func<Vector3, bool> checker2 = checker;
			_ = ZNetScene.instance;
			IEnumerable<ZNetView> source = ZNetScene.instance.m_instances.Values.Where(IsValid);
			if (included2.Count > 0)
			{
				source = source.Where((ZNetView view) => included2.Contains(view.GetZDO().GetPrefab()));
			}
			if (excluded2.Count > 0)
			{
				source = source.Where((ZNetView view) => !excluded2.Contains(view.GetZDO().GetPrefab()));
			}
			source = source.Where((ZNetView view) => checker2(view.GetZDO().GetPosition()));
			if (types.Count > 0)
			{
				source = ComponentInfo.HaveComponent(source, types);
			}
			ZNetView[] array = source.ToArray();
			if (array.Length == 0)
			{
				throw new InvalidOperationException("Nothing is nearby.");
			}
			return array;
		}

		public static ZNetView[] GetConnectedRaft(ZNetView baseView, HashSet<int> included, HashSet<int> excluded)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			HashSet<int> included2 = included;
			HashSet<int> excluded2 = excluded;
			ZDOID id = baseView.GetZDO().GetZDOID(RaftParent);
			IEnumerable<ZNetView> source = ZNetScene.instance.m_instances.Values.Where(IsValid);
			if (included2.Count > 0)
			{
				source = source.Where((ZNetView view) => included2.Contains(view.GetZDO().GetPrefab()));
			}
			if (excluded2.Count > 0)
			{
				source = source.Where((ZNetView view) => !excluded2.Contains(view.GetZDO().GetPrefab()));
			}
			source = source.Where((ZNetView view) => view.GetZDO().m_uid == id || view.GetZDO().GetZDOID(RaftParent) == id);
			return source.ToArray();
		}

		public static ZNetView[] GetConnected(ZNetView baseView, string[] included, string[] excluded)
		{
			//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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			HashSet<int> includedPrefabs = GetPrefabs(included);
			HashSet<int> excludedPrefabs = GetExcludedPrefabs(excluded);
			if (baseView.GetZDO().GetZDOID(RaftParent) != ZDOID.None)
			{
				return GetConnectedRaft(baseView, includedPrefabs, excludedPrefabs);
			}
			WearNTear item = ((Component)baseView).GetComponent<WearNTear>() ?? throw new InvalidOperationException("Connected doesn't work for this object.");
			HashSet<ZNetView> hashSet = new HashSet<ZNetView> { baseView };
			Queue<WearNTear> queue = new Queue<WearNTear>();
			queue.Enqueue(item);
			while (queue.Count > 0)
			{
				WearNTear val = queue.Dequeue();
				if (val.m_colliders == null)
				{
					val.SetupColliders();
				}
				foreach (BoundData bound in val.m_bounds)
				{
					int num = Physics.OverlapBoxNonAlloc(bound.m_pos, bound.m_size, WearNTear.s_tempColliders, bound.m_rot, WearNTear.s_rayMask);
					for (int i = 0; i < num; i++)
					{
						Collider val2 = WearNTear.s_tempColliders[i];
						if (!val2.isTrigger && !((Object)(object)val2.attachedRigidbody != (Object)null) && !val.m_colliders.Contains(val2))
						{
							WearNTear componentInParent = ((Component)val2).GetComponentInParent<WearNTear>();
							if (Object.op_Implicit((Object)(object)componentInParent) && IsValid(componentInParent.m_nview) && !hashSet.Contains(componentInParent.m_nview) && !excludedPrefabs.Contains(componentInParent.m_nview.GetZDO().GetPrefab()))
							{
								hashSet.Add(componentInParent.m_nview);
								queue.Enqueue(componentInParent);
							}
						}
					}
				}
			}
			IEnumerable<ZNetView> source = hashSet;
			if (includedPrefabs.Count > 0)
			{
				source = source.Where((ZNetView view) => includedPrefabs.Contains(view.GetZDO().GetPrefab()));
			}
			return source.ToArray();
		}
	}
}
namespace ServerDevcommands
{
	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");
				Player player = Helper.GetPlayer();
				int stableHashCode = StringExtensionMethods.GetStableHashCode(args[1]);
				((Character)player).GetSEMan().AddStatusEffect(stableHashCode, true, 0, 0f);
				StatusEffect statusEffect = ((Character)player).GetSEMan().GetStatusEffect(stableHashCode);
				if ((Object)(object)statusEffect == (Object)null)
				{
					return;
				}
				float ttl = default(float);
				if (args.TryParameterFloat(2, ref ttl))
				{
					statusEffect.m_ttl = ttl;
				}
				float num = default(float);
				if (!args.TryParameterFloat(3, ref num))
				{
					return;
				}
				SE_Shield val = (SE_Shield)(object)((statusEffect is SE_Shield) ? statusEffect : null);
				if (val != null)
				{
					val.m_absorbDamage = num;
				}
				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(num);
					}
					else
					{
						val2.m_spiritDamageLeft = 0f;
						val2.AddSpiritDamage(num);
					}
				}
				SE_Poison val3 = (SE_Poison)(object)((statusEffect is SE_Poison) ? statusEffect : null);
				if (val3 != null)
				{
					val3.m_damageLeft = num;
					val3.m_damagePerHit = num / 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");
					Player player = Helper.GetPlayer();
					int stableHashCode = StringExtensionMethods.GetStableHashCode(args[1]);
					((Character)player).GetSEMan().AddStatusEffect(stableHashCode, true, 0, 0f);
					StatusEffect statusEffect = ((Character)player).GetSEMan().GetStatusEffect(stableHashCode);
					if (!((Object)(object)statusEffect == (Object)null))
					{
						float ttl = default(float);
						if (args.TryParameterFloat(2, ref ttl))
						{
							statusEffect.m_ttl = ttl;
						}
						float num = default(float);
						if (args.TryParameterFloat(3, ref num))
						{
							SE_Shield val2 = (SE_Shield)(object)((statusEffect is SE_Shield) ? statusEffect : null);
							if (val2 != null)
							{
								val2.m_absorbDamage = num;
							}
							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(num);
								}
								else
								{
									val3.m_spiritDamageLeft = 0f;
									val3.AddSpiritDamage(num);
								}
							}
							SE_Poison val4 = (SE_Poison)(object)((statusEffect is SE_Poison) ? statusEffect : null);
							if (val4 != null)
							{
								val4.m_damageLeft = num;
								val4.m_damagePerHit = num / 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 ConsoleEvent <>9__0_0;

			public static Func<string, string> <>9__1_2;

			public static ConsoleEvent <>9__1_0;

			public static Func<int, int, List<string>> <>9__1_1;

			internal void <AddCommand>b__0_0(ConsoleEventArgs args)
			{
			}

			internal void <.ctor>b__1_0(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					args.Context.AddString(string.Join("\n", Settings.AliasKeys.Select((string key) => key + " -> " + Settings.GetAliasValue(key))));
				}
				else if (args.Length < 3)
				{
					Settings.RemoveAlias(args[1]);
					if (Terminal.commands.ContainsKey(args[1]))
					{
						Terminal.commands.Remove(args[1]);
					}
					args.Context.updateCommandList();
					AliasManager.ToBeSaved = true;
				}
				else
				{
					string value = string.Join(" ", args.Args.Skip(2));
					Settings.AddAlias(args[1], value);
					AddCommand(args[1], value);
					args.Context.updateCommandList();
					AliasManager.ToBeSaved = true;
				}
			}

			internal string <.ctor>b__1_2(string key)
			{
				return key + " -> " + Settings.GetAliasValue(key);
			}

			internal List<string> <.ctor>b__1_1(int index, int subIndex)
			{
				if (index == 0)
				{
					return ParameterInfo.Create("Name of the alias.");
				}
				return ParameterInfo.None;
			}
		}

		public static void AddCommand(string key, string value)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			string text = Aliasing.Plain(value);
			string key2 = text.Split(new char[1] { ' ' }).First();
			if (Terminal.commands.TryGetValue(key2, out var value2))
			{
				new ConsoleCommand(key, text, value2.action, value2.IsCheat, value2.IsNetwork, value2.OnlyServer, value2.IsSecret, value2.AllowInDevBuild, value2.m_tabOptionsFetcher, false, false, false);
				return;
			}
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate
				{
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand(key, text, (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}

		public AliasCommand()
		{
			//IL_0038: 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__1_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate(ConsoleEventArgs args)
				{
					if (args.Length < 2)
					{
						args.Context.AddString(string.Join("\n", Settings.AliasKeys.Select((string key) => key + " -> " + Settings.GetAliasValue(key))));
					}
					else if (args.Length < 3)
					{
						Settings.RemoveAlias(args[1]);
						if (Terminal.commands.ContainsKey(args[1]))
						{
							Terminal.commands.Remove(args[1]);
						}
						args.Context.updateCommandList();
						AliasManager.ToBeSaved = true;
					}
					else
					{
						string value = string.Join(" ", args.Args.Skip(2));
						Settings.AddAlias(args[1], value);
						AddCommand(args[1], value);
						args.Context.updateCommandList();
						AliasManager.ToBeSaved = true;
					}
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("alias", "[name] [command] - Sets a command alias.", (ConsoleEvent)obj, 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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, (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, (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, (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, (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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			return new CodeMatcher(instructions, (ILGenerator)null).MatchStartForward((CodeMatch[])(object)new CodeMatch[1]
			{
				new CodeMatch((OpCode?)OpCodes.Stfld, (object)AccessTools.Field(typeof(Chat), "m_wasFocused"), (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 val4 = (MessageType)((args[2] == "side") ? 1 : 2);
					string text2 = string.Join(" ", args.Args.Skip(2));
					MessageHud.instance.MessageAll(val4, text2);
				};
				<>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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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, (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");
			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", delegate(int index)
			{
				switch (index)
				{
				case 0:
					return ParameterInfo.ObjectIds;
				case 1:
					return ParameterInfo.Create("Amount", "a positive integer (default 1)");
				case 2:
					return ParameterInfo.Create("Level", "a positive integer (default 1)");
				default:
					if (index == 2)
					{
						return ParameterInfo.Create("<color=yellow>p</color> to automatically pick up items. <color=yellow>e</color> to automatically equip items.");
					}
					return 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();
				SkillType val = (SkillType)999;
				if (!list.Contains(((object)(SkillType)(ref val)).ToString()))
				{
					val = (SkillType)999;
					list.Add(((object)(SkillType)(ref val)).ToString());
				}
				return list;
			}
		}
	}
	public class DevcommandsCommand
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__3_0;

			internal void <.ctor>b__3_0(ConsoleEventArgs args)
			{
				if (Terminal.m_cheat)
				{
					Set(args.Context, value: false);
					return;
				}
				if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer())
				{
					Toggle(args.Context);
					return;
				}
				args.Context.AddString("Authenticating for devcommands...");
				Admin.ManualCheck();
			}
		}

		public static void Toggle(Terminal terminal)
		{
			bool value = !Terminal.m_cheat;
			if (terminal != null)
			{
				terminal.AddString("Devcommands: " + value);
			}
			Gogan.LogEvent("Cheat", "CheatsEnabled", value.ToString(), 0L);
			Set(value);
		}

		public static void Set(Terminal terminal, bool value)
		{
			if (terminal != null)
			{
				terminal.AddString("Devcommands: " + value);
			}
			Gogan.LogEvent("Cheat", "CheatsEnabled", value.ToString(), 0L);
			Set(value);
		}

		public static void Set(bool value)
		{
			if (Terminal.m_cheat == value)
			{
				return;
			}
			if (Settings.AutoTod != "" && !value)
			{
				((Terminal)Console.instance).TryRunCommand("tod -1", false, false);
			}
			if (Settings.AutoEnv != "" && !value)
			{
				((Terminal)Console.instance).TryRunCommand("resetenv", false, false);
			}
			Terminal.m_cheat = value;
			if (Settings.AutoTod != "" && value)
			{
				((Terminal)Console.instance).TryRunCommand("tod " + Settings.AutoTod, false, false);
			}
			if (Settings.AutoEnv != "" && value)
			{
				((Terminal)Console.instance).TryRunCommand("env " + Settings.AutoEnv, false, false);
			}
			((Terminal)Console.instance).updateCommandList();
			((Terminal)Chat.instance).updateCommandList();
			Player localPlayer = Player.m_localPlayer;
			if (Settings.AutoDebugMode)
			{
				Player.m_debugMode = value;
			}
			if (Object.op_Implicit((Object)(object)localPlayer))
			{
				if (Settings.AutoGodMode)
				{
					localPlayer.SetGodMode(value);
				}
				if (Settings.AutoGhostMode)
				{
					localPlayer.SetGhostMode(value);
				}
				if (Settings.AutoFly)
				{
					localPlayer.m_debugFly = value;
					((Character)localPlayer).m_nview.GetZDO().Set(ZDOVars.s_debugFly, value);
				}
				if (Settings.AutoNoCost)
				{
					localPlayer.m_noPlacementCost = value;
				}
			}
			if (value && Settings.AutoExecDevOn != "")
			{
				((Terminal)Console.instance).TryRunCommand(Settings.AutoExecDevOn, false, false);
			}
			if (!value && Settings.AutoExecDevOff != "")
			{
				((Terminal)Console.instance).TryRunCommand(Settings.AutoExecDevOff, false, false);
			}
		}

		public DevcommandsCommand()
		{
			//IL_0038: 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__3_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())
					{
						Toggle(args.Context);
					}
					else
					{
						args.Context.AddString("Authenticating for devcommands...");
						Admin.ManualCheck();
					}
				};
				<>c.<>9__3_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("devcommands", "Toggles cheats", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			AutoComplete.RegisterEmpty("devcommands");
		}
	}
	public class DevCommandsAdmin : DefaultAdmin
	{
		protected override void OnSuccess()
		{
			base.OnSuccess();
			DevcommandsCommand.Set(value: true);
			((Terminal)Console.instance).AddString("Authorized to use devcommands.");
		}

		protected override void OnFail()
		{
			base.OnFail();
			DevcommandsCommand.Set(value: false);
			((Terminal)Console.instance).AddString("Unauthorized to use devcommands.");
		}

		public override void AutomaticCheck()
		{
			if (Settings.AutoDevcommands)
			{
				base.AutomaticCheck();
			}
		}

		public override void Reset()
		{
			base.Reset();
			DevcommandsCommand.Set(value: false);
		}
	}
	[HarmonyPatch(typeof(Terminal), "IsCheatsEnabled")]
	public class IsCheatsEnabledWithoutServerCheck
	{
		private static void Postfix(ref bool __result)
		{
			int num;
			if (!Terminal.m_cheat)
			{
				ZNet instance = ZNet.instance;
				num = ((instance != null && instance.IsDedicated()) ? 1 : 0);
			}
			else
			{
				num = 1;
			}
			__result = (byte)num != 0;
		}
	}
	[HarmonyPatch(typeof(ConsoleCommand), "IsValid")]
	public class IsValidWithoutServerCheck
	{
		private static void Postfix(ref bool __result)
		{
			int num;
			if (!__result && !Terminal.m_cheat)
			{
				ZNet instance = ZNet.instance;
				num = ((instance != null && instance.IsDedicated()) ? 1 : 0);
			}
			else
			{
				num = 1;
			}
			__result = (byte)num != 0;
		}
	}
	[HarmonyPatch(typeof(Terminal), "Awake")]
	public class AutoCompleteSecrets
	{
		private static void Postfix(ref bool ___m_autoCompleteSecrets)
		{
			___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> list2 = PlayerInfo.FindPlayers(new string[1] { text });
					foreach (PlayerInfo item3 in list2)
					{
						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(", ", list2.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__locals0 = 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__locals0.text = string.Join(" ", args.Args, 1, args.Args.Length - 1);
				if (!EnvMan.instance.m_environments.Any((EnvSetup env) => env.m_name == CS$<>8__locals0.text))
				{
					CS$<>8__locals0.text = CS$<>8__locals0.text.Replace("_", " ");
				}
				Helper.AddMessage(args.Context, "Setting debug environment: " + CS$<>8__locals0.text);
				instance.m_debugEnv = CS$<>8__locals0.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__locals0 = new <>c__DisplayClass0_0
				{
					args = args
				};
				Helper.ArgsCheck(CS$<>8__locals0.args, 2, "Missing the search term.");
				if (CS$<>8__locals0.args.Length < 3)
				{
					ConsoleEventArgs args2 = CS$<>8__locals0.args;
					string[] args3 = CS$<>8__locals0.args.Args;
					int num = 0;
					string[] array = new string[1 + args3.Length];
					string[] array2 = args3;
					foreach (string text in array2)
					{
						array[num] = text;
						num++;
					}
					array[num] = "10";
					num++;
					args2.Args = array;
				}
				string[] args4 = Helper.AddPlayerPosXZY(CS$<>8__locals0.args.Args, 3);
				if (!ZNet.instance.IsServer())
				{
					ServerExecution.Send((IEnumerable<string>)args4);
					return;
				}
				CS$<>8__locals0.prefabs = Selector.GetAllPrefabs(new string[1] { CS$<>8__locals0.args[1] });
				CS$<>8__locals0.pos = Parse.VectorXZY(string.Join(",", CS$<>8__locals0.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__locals0.args[1]
					select l).ToList();
				if (CS$<>8__locals0.prefabs.Count <= 0 && list.Count <= 0)
				{
					<>c__DisplayClass0_1 CS$<>8__locals1 = new <>c__DisplayClass0_1
					{
						lower = CS$<>8__locals0.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__locals1.lower)
						select l).ToList();
					CS$<>8__locals0.prefabs = Selector.GetAllPrefabs(new string[1] { "*" + CS$<>8__locals0.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__locals0.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__locals0.pos).CompareTo(Vector3.Distance(b.Item2, CS$<>8__locals0.pos)));
				int count = list2.Count;
				list2 = list2.Take(Parse.Int(CS$<>8__locals0.args.Args, 2, 10)).ToList();
				List<string> values = list2.Select((Tuple<string, Vector3> p) => Format(CS$<>8__locals0.pos, p.Item2, p.Item1)).ToList();
				CS$<>8__locals0.args.Context.AddString($"Found {count} of {CS$<>8__locals0.args[1]}. Showing {list2.Count} closest:");
				CS$<>8__locals0.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 val3 = args;
						string[] args2 = args.Args;
						int num = 0;
						string[] array = new string[1 + args2.Length];
						string[] array2 = args2;
						foreach (string text in array2)
						{
							array[num] = text;
							num++;
						}
						array[num] = "10";
						num++;
						val3.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_0038: 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, (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__locals0 = new <>c__DisplayClass5_0();
				Helper.ArgsCheck(args, 2, "Missing clear, level, refill, repair or upgrade.");
				CS$<>8__locals0.amount = Parse.IntNull(args.Args, 2);
				string text = Parse.String(args.Args, 3, "all");
				if (!CS$<>8__locals0.amount.HasValue)
				{
					text = Parse.String(args.Args, 2, "all");
					CS$<>8__locals0.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__locals0.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__locals0.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__locals0.amount.HasValue || item.m_quality != item.m_shared.m_maxQuality)).ToArray();
					ItemData[] array2 = array;
					foreach (ItemData val in array2)
					{
						if (CS$<>8__locals0.amount.HasValue)
						{
							val.m_quality = CS$<>8__locals0.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();
			}

			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