Decompiled source of SimpleCommands v1.2.2

BepInEx/plugins/SimpleCommands/Simple-Commands.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using JLL.API;
using JLL.API.Compatability;
using JLL.API.LevelProperties;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using Simple-Commands.NetcodePatcher;
using SimpleCommands;
using SimpleCommands.Commands;
using SimpleCommands.Components;
using SimpleCommands.Managers;
using SimpleCommands.Patches;
using Simple_Commands.Commands;
using Simple_Commands.Commands.Compatability;
using Simple_Commands.Patches;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using WeatherRegistry;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Simple-Commands")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Simple-Commands")]
[assembly: AssemblyTitle("Simple-Commands")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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;
		}
	}
}
namespace Simple_Commands.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPatch(typeof(Terminal), "CallFunctionInAccessibleTerminalObject")]
		public static void terminalObjectRequest(Terminal instance, string word)
		{
			throw new NotImplementedException("It's a stub");
		}
	}
}
namespace Simple_Commands.Commands
{
	public class SimplePrefabs
	{
		public class SimplePrefab
		{
			public GameObject prefab;

			public Vector3 spawnOffset = Vector3.zero;

			public virtual GameObject SpawnPrefab(Vector3 pos, Quaternion rot)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = Object.Instantiate<GameObject>(prefab);
				val.transform.position = pos;
				val.transform.rotation = rot;
				NetworkObject val2 = default(NetworkObject);
				if (val.TryGetComponent<NetworkObject>(ref val2))
				{
					val2.Spawn(false);
				}
				return val;
			}
		}

		public class CruiserPrefab : SimplePrefab
		{
			public override GameObject SpawnPrefab(Vector3 pos, Quaternion rot)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = base.SpawnPrefab(pos, rot);
				VehicleController val2 = default(VehicleController);
				if (val.TryGetComponent<VehicleController>(ref val2))
				{
					val2.hasBeenSpawned = true;
					val2.inDropshipAnimation = false;
				}
				return val;
			}
		}

		internal class PrefabCommand : SimpleCommand
		{
			public PrefabCommand()
				: base("prefab", "spawn registered prefabs")
			{
				instructions.Add("[/cmd] [name] - Spawns prefab at the player.");
				instructions.Add("[/cmd] [target] [name] - Spawns prefab at the target.");
				instructions.Add("[/cmd] [name] [x] [y] [z] - Spawns prefab at specified coordinates.");
			}

			public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				success = false;
				if (!parameters.IsEmpty())
				{
					string @string = parameters.GetString();
					Vector3 val = ((Component)sender).transform.position;
					bool flag = false;
					if (parameters.Count() >= 4)
					{
						if (!parameters.GetRelativeVector(((Component)sender).transform.position, out var vector))
						{
							return UnknownVectorException();
						}
						val = vector;
						flag = true;
					}
					else if (parameters.Count() >= 2)
					{
						PlayerControllerB player = SimpleCommand.GetPlayer(@string);
						if (!((Object)(object)player != (Object)null))
						{
							return UnknownPlayerException(@string);
						}
						val = ((Component)player).transform.position;
						@string = parameters.GetString();
					}
					List<KeyValuePair<string, SimplePrefab>> list = new List<KeyValuePair<string, SimplePrefab>>();
					foreach (KeyValuePair<string, SimplePrefab> prefab in Prefabs)
					{
						if (prefab.Key.ToLower().StartsWith(@string.ToLower()))
						{
							list.Add(prefab);
						}
					}
					if (list.Count > 0)
					{
						int index = 0;
						for (int i = 0; i < list.Count; i++)
						{
							if (list[i].Key.Length < list[index].Key.Length)
							{
								index = i;
							}
						}
						if (Prefabs.ContainsKey(list[index].Key))
						{
							SimplePrefab simplePrefab = Prefabs[list[index].Key];
							simplePrefab.SpawnPrefab(val + (flag ? Vector3.zero : simplePrefab.spawnOffset), ((Component)sender).transform.rotation);
							success = true;
							return "Spawned " + list[index].Key + "!";
						}
					}
					return "Unknown Prefab: " + @string;
				}
				return "";
			}
		}

		internal class PrefabsCommand : SimpleCommand
		{
			public PrefabsCommand()
				: base("prefabs", "list spawnable prefabs")
			{
				instructions.Add("[/cmd] - Lists spawnable prefabs");
				instructions.Add("[/cmd] [page]");
			}

			public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
			{
				int page = 0;
				if (!parameters.IsEmpty())
				{
					page = parameters.GetNumber();
				}
				success = true;
				SimpleCommand.ClearChat();
				return PagedList("Spawnable Prefabs:", Prefabs.Keys.ToList(), page, 8);
			}
		}

		private static readonly Dictionary<string, SimplePrefab> Prefabs = new Dictionary<string, SimplePrefab>();

		private static bool registeredBasePrefabs = false;

		public static void RegisterSimplePrefab(string name, SimplePrefab prefab)
		{
			if (!Prefabs.ContainsKey(name))
			{
				Prefabs.Add(name.Replace(' ', '_'), prefab);
			}
		}

		public static void RegisterSimplePrefab(string name, GameObject prefab)
		{
			RegisterSimplePrefab(name, new SimplePrefab
			{
				prefab = prefab
			});
		}

		internal static void RegisterBasePrefabs()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (registeredBasePrefabs)
			{
				return;
			}
			registeredBasePrefabs = true;
			SimpleCommandsBase.Instance.mls.LogInfo((object)"Registering Base Game Prefabs.");
			Terminal val = Object.FindObjectOfType<Terminal>();
			RegisterSimplePrefab("Cruiser", (SimplePrefab)new CruiserPrefab
			{
				prefab = val.buyableVehicles[0].vehiclePrefab,
				spawnOffset = new Vector3(0f, 14f, 0f)
			});
			SimpleCommandsBase.Instance.mls.LogInfo((object)$"Vanilla Map Hazards: {val.moonsCatalogueList[1].spawnableMapObjects.Length}");
			SpawnableMapObject[] spawnableMapObjects = val.moonsCatalogueList[1].spawnableMapObjects;
			foreach (SpawnableMapObject val2 in spawnableMapObjects)
			{
				string name = ((Object)val2.prefabToSpawn).name;
				if (1 == 0)
				{
				}
				string text = ((name == "SpikeRoofTrapHazard") ? "SpikeRoofTrap" : ((!(name == "TurretContainer")) ? name : "Turret"));
				if (1 == 0)
				{
				}
				name = text;
				RegisterSimplePrefab(name, new SimplePrefab
				{
					prefab = val2.prefabToSpawn
				});
			}
			SimpleCommandsBase.Instance.mls.LogInfo((object)$"LethalLib Map Hazards: {MapObjects.mapObjects.Count}");
			foreach (RegisteredMapObject mapObject in MapObjects.mapObjects)
			{
				RegisterSimplePrefab(((Object)mapObject.mapObject.prefabToSpawn).name, new SimplePrefab
				{
					prefab = mapObject.mapObject.prefabToSpawn
				});
			}
		}
	}
}
namespace Simple_Commands.Commands.Compatability
{
	public class WeatherRegistryCommand : SimpleCommand
	{
		public WeatherRegistryCommand()
			: base("weatherregistry", "WeatherRegistry (mrov)")
		{
			overrideShowOutput = true;
			permissionRequired = false;
			instructions.Add("[/cmd] - lists weathers registered through WeatherRegistry");
			instructions.Add("[/cmd] [page]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			List<string> list = new List<string>();
			foreach (Weather weather in WeatherManager.Weathers)
			{
				list.Add(((Object)weather).name.Replace(" ", "_"));
			}
			int page = 0;
			if (!parameters.IsEmpty())
			{
				page = parameters.GetNumber();
			}
			success = true;
			SimpleCommand.ClearChat();
			return PagedList("WeatherRegistry:", list, page, 7);
		}
	}
}
namespace SimpleCommands
{
	[BepInPlugin("JacobG5.SimpleCommands", "SimpleCommands", "1.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SimpleCommandsBase : BaseUnityPlugin
	{
		private const string modGUID = "JacobG5.SimpleCommands";

		private const string modName = "SimpleCommands";

		private const string modVersion = "1.2.2";

		private readonly Harmony harmony = new Harmony("JacobG5.SimpleCommands");

		public static SimpleCommandsBase Instance;

		public ManualLogSource mls;

		public GameObject networkObject;

		public static ConfigEntry<string> commandPrefix;

		public static ConfigEntry<bool> hostOnly;

		public static ConfigEntry<bool> hideDefault;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			hostOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "hostOnly", true, "Restricts commands to only being executed by the host.");
			hideDefault = ((BaseUnityPlugin)this).Config.Bind<bool>("Main", "hideDefault", false, "Hides command feedback by default. ('hide' flag now shows command feedback.)");
			commandPrefix = ((BaseUnityPlugin)this).Config.Bind<string>("Main", "commandPrefix", "/", "Prefix for SimpleCommands");
			mls = Logger.CreateLogSource("JacobG5.SimpleCommands");
			NetcodeRequired(mls);
			networkObject = NetworkPrefabs.CreateNetworkPrefab("SimpleCommandsNetworkManager");
			networkObject.AddComponent<SimpleCommandsNetworkManager>();
			harmony.PatchAll(typeof(HUDManagerPatch));
			harmony.PatchAll(typeof(PlayerControllerBPatch));
			harmony.PatchAll(typeof(StartOfRoundPatch));
			harmony.PatchAll(typeof(TerminalPatch));
			RegisterBaseCommands();
		}

		private static void NetcodeRequired(ManualLogSource logSource)
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				try
				{
					MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
					MethodInfo[] array2 = methods;
					foreach (MethodInfo methodInfo in array2)
					{
						object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
						if (customAttributes.Length != 0)
						{
							methodInfo.Invoke(null, null);
						}
					}
				}
				catch
				{
					logSource.LogInfo((object)"Skipping Netcode Class");
				}
			}
			logSource.LogInfo((object)"Netcode Successfully Patched!");
		}

		private void RegisterBaseCommands()
		{
			SimpleCommand.Register(new HelpCommand());
			SimpleCommand.Register(new ClearCommand());
			SimpleCommand.Register(new ListCommand());
			SimpleCommand.Register(new PayCommand());
			SimpleCommand.Register(new WeatherCommand());
			SimpleCommand.Register(new HealCommand());
			SimpleCommand.Register(new InvulnerabilityCommand());
			SimpleCommand.Register(new InfiniteSprintCommand());
			SimpleCommand.Register(new ItemCommand());
			SimpleCommand.Register(new ItemsCommand());
			SimpleCommand.Register(new TeleportCommand());
			SimpleCommand.Register(new TerminalCommand());
			SimpleCommand.Register(new SimplePrefabs.PrefabCommand());
			SimpleCommand.Register(new SimplePrefabs.PrefabsCommand());
			SimpleCommand.Register(new ChargeCommand());
			SimpleCommand.Register(new ExtendCommand());
			if (JCompatabilityHelper.IsModLoaded.WeatherRegistry)
			{
				SimpleCommand.Register(new WeatherRegistryCommand());
			}
		}
	}
}
namespace SimpleCommands.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatch
	{
		[HarmonyPatch("AddTextToChatOnServer")]
		[HarmonyPrefix]
		public static bool patchAddTextToChatOnServer(string chatMessage, int playerId, HUDManager __instance)
		{
			if (playerId != -1)
			{
				PlayerControllerB val = __instance.playersManager.allPlayerScripts[playerId];
				string prefix = SimpleCommand.GetPrefix();
				if (chatMessage.StartsWith(prefix))
				{
					string text = chatMessage.Substring(prefix.Length);
					text = text.Replace("&//=", "").Replace(prefix, "&//=");
					if (((NetworkBehaviour)val).IsHost || ((NetworkBehaviour)val).IsServer)
					{
						SimpleCommandsNetworkManager.Instance.CommandExecutionClientRpc(playerId, text, SimpleCommandsBase.hideDefault.Value);
					}
					else
					{
						SimpleCommandsBase.Instance.mls.LogInfo((object)"Sending Command Request.");
						SimpleCommandsNetworkManager.Instance.RequestCommandExecutionServerRpc(playerId, text);
					}
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void patchStart(PlayerControllerB __instance)
		{
			((Component)__instance).gameObject.AddComponent<PlayerModification>();
		}

		[HarmonyPatch("KillPlayer")]
		[HarmonyPrefix]
		public static bool patchKillPlayer(PlayerControllerB __instance)
		{
			return CheckInvulnerability(__instance);
		}

		[HarmonyPatch("DamagePlayer")]
		[HarmonyPrefix]
		public static bool patchDamagePlayer(PlayerControllerB __instance)
		{
			return CheckInvulnerability(__instance);
		}

		public static bool CheckInvulnerability(PlayerControllerB player)
		{
			if (((Component)player).GetComponent<PlayerModification>().invulnerable)
			{
				player.health = 100;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		public static void spawnNetworkManager(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).IsHost || ((NetworkBehaviour)__instance).IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(SimpleCommandsBase.Instance.networkObject);
				val.GetComponent<NetworkObject>().Spawn(false);
				SimpleCommandsBase.Instance.mls.LogInfo((object)"Simple Command Manager Initialized.");
			}
		}
	}
}
namespace SimpleCommands.Managers
{
	public class SimpleCommandsNetworkManager : NetworkBehaviour
	{
		public static SimpleCommandsNetworkManager Instance;

		public void Awake()
		{
			Instance = this;
			SimplePrefabs.RegisterBasePrefabs();
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestCommandExecutionServerRpc(int playerId, string commandMessage)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val = default(ServerRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1796766225u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				bool flag = commandMessage != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(commandMessage, false);
				}
				((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1796766225u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
			{
				return;
			}
			SimpleCommandsBase.Instance.mls.LogInfo((object)"[Server] Processing Command Request.");
			if (SimpleCommand.tryParseCommand(commandMessage, out SimpleCommand command, out SimpleCommand.CommandParameters parameters))
			{
				if (command == null || parameters == null)
				{
					return;
				}
				if (command.permissionRequired && SimpleCommandsBase.hostOnly.Value)
				{
					SendErrorTipClientRpc(playerId, "Permission Denied", "Only the host is allowed to execute commands due to the server's config.", isError: true);
					return;
				}
			}
			CommandExecutionClientRpc(playerId, commandMessage, SimpleCommandsBase.hideDefault.Value);
		}

		[ClientRpc]
		public void CommandExecutionClientRpc(int playerId, string commandMessage, bool hideDefault)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1085875477u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				bool flag = commandMessage != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(commandMessage, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref hideDefault, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1085875477u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				CommandExecution(StartOfRound.Instance.allPlayerScripts[playerId], commandMessage, hideDefault);
			}
		}

		private void CommandExecution(PlayerControllerB sender, string commandMessage, bool hideDefault)
		{
			HUDManager instance = HUDManager.Instance;
			SimpleCommandsBase.Instance.mls.LogInfo((object)("Parsing: " + commandMessage));
			bool flag = GameNetworkManager.Instance.localPlayerController.actualClientId == sender.actualClientId;
			string[] array = commandMessage.Split("&//=");
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (text == "")
				{
					continue;
				}
				if (SimpleCommand.tryParseCommand(text, out SimpleCommand command, out SimpleCommand.CommandParameters parameters))
				{
					if (command == null || parameters == null)
					{
						break;
					}
					string text2 = (parameters.IsEmpty() ? "" : ("\n" + parameters.asString()));
					SimpleCommandsBase.Instance.mls.LogInfo((object)("Player: " + sender.playerUsername + " | Executing: " + SimpleCommand.GetPrefix() + command.name + text2));
					bool success;
					string text3 = command.Execute(sender, parameters, out success);
					if (text3 == null || !(text3 != ""))
					{
						continue;
					}
					SimpleCommandsBase.Instance.mls.LogInfo((object)$"\nSuccess: {success}\nResult: {text3}");
					if (success)
					{
						if ((((NetworkBehaviour)instance).IsHost || ((NetworkBehaviour)instance).IsServer) && (parameters.isFlagged("hide") == hideDefault || command.overrideShowOutput))
						{
							instance.AddTextToChatOnServer(text3, -1);
						}
					}
					else if (flag)
					{
						JHudHelper.QueueDisplayTip("Command Failure:", text3, false, false, "LC_Tip1");
					}
				}
				else if (flag)
				{
					JHudHelper.QueueDisplayTip("Unknown Command:", SimpleCommand.GetPrefix() + text.Split(' ')[0], true, false, "LC_Tip1");
				}
			}
		}

		[ClientRpc]
		public void SendErrorTipClientRpc(int playerId, string title, string description, bool isError)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Invalid comparison between Unknown and I4
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
			{
				ClientRpcParams val = default(ClientRpcParams);
				FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(746899919u, val, (RpcDelivery)0);
				BytePacker.WriteValueBitPacked(val2, playerId);
				bool flag = title != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(title, false);
				}
				bool flag2 = description != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives));
				if (flag2)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(description, false);
				}
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref isError, default(ForPrimitives));
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 746899919u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				HUDManager instance = HUDManager.Instance;
				if (instance.localPlayer.actualClientId == instance.playersManager.allPlayerScripts[playerId].actualClientId)
				{
					instance.DisplayTip(title, description, isError, false, "LC_Tip1");
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_SimpleCommandsNetworkManager()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1796766225u, new RpcReceiveHandler(__rpc_handler_1796766225));
			NetworkManager.__rpc_func_table.Add(1085875477u, new RpcReceiveHandler(__rpc_handler_1085875477));
			NetworkManager.__rpc_func_table.Add(746899919u, new RpcReceiveHandler(__rpc_handler_746899919));
		}

		private static void __rpc_handler_1796766225(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string commandMessage = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref commandMessage, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((SimpleCommandsNetworkManager)(object)target).RequestCommandExecutionServerRpc(playerId, commandMessage);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_1085875477(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string commandMessage = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref commandMessage, false);
				}
				bool hideDefault = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hideDefault, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SimpleCommandsNetworkManager)(object)target).CommandExecutionClientRpc(playerId, commandMessage, hideDefault);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_746899919(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_00ac: 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_00c1: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				int playerId = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref playerId);
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string title = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref title, false);
				}
				bool flag2 = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives));
				string description = null;
				if (flag2)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref description, false);
				}
				bool isError = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isError, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((SimpleCommandsNetworkManager)(object)target).SendErrorTipClientRpc(playerId, title, description, isError);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "SimpleCommandsNetworkManager";
		}
	}
}
namespace SimpleCommands.Components
{
	internal class PlayerModification : MonoBehaviour
	{
		private PlayerControllerB player;

		public bool infinateSprint = false;

		public bool invulnerable = false;

		public void Start()
		{
			player = ((Component)this).gameObject.GetComponent<PlayerControllerB>();
		}

		public void Update()
		{
			ApplyUpdate();
		}

		private void ApplyUpdate()
		{
			if (infinateSprint)
			{
				player.sprintMeter = 1f;
			}
		}
	}
}
namespace SimpleCommands.Commands
{
	public class ChargeCommand : SimpleCommand
	{
		public ChargeCommand()
			: base("charge", "charges held item")
		{
			instructions.Add("[/cmd]");
			instructions.Add("[/cmd] [target]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			PlayerControllerB val = sender;
			if (!parameters.IsEmpty())
			{
				string stringAt = parameters.GetStringAt(0);
				PlayerControllerB player = SimpleCommand.GetPlayer(stringAt);
				if (!((Object)(object)player != (Object)null))
				{
					success = false;
					return UnknownPlayerException(stringAt);
				}
				val = player;
			}
			GrabbableObject currentlyHeldObjectServer = val.currentlyHeldObjectServer;
			if ((Object)(object)currentlyHeldObjectServer != (Object)null && currentlyHeldObjectServer.itemProperties.requiresBattery)
			{
				currentlyHeldObjectServer.insertedBattery = new Battery(false, 1f);
			}
			success = true;
			return "Charged " + val.playerUsername + "'s Item.";
		}
	}
	public class ClearCommand : SimpleCommand
	{
		public ClearCommand()
			: base("clear", "clears chat")
		{
			instructions.Add("[/cmd] - clears chat");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			success = true;
			SimpleCommand.ClearChat();
			JHudHelper.ClearDisplayTipQueue();
			return "";
		}
	}
	public class ExtendCommand : SimpleCommand
	{
		public ExtendCommand()
			: base("extend", "extends quota")
		{
			instructions.Add("[/cmd] - Extends Quota 1 Day");
			instructions.Add("[/cmd] [days]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			int num = (parameters.IsEmpty() ? 1 : parameters.GetNumber());
			if (num != 0)
			{
				TimeOfDay instance = TimeOfDay.Instance;
				instance.timeUntilDeadline += instance.totalTime * (float)num;
				instance.UpdateProfitQuotaCurrentTime();
				success = true;
				return "Extended Deadline " + num + " day(s).";
			}
			success = false;
			return "";
		}
	}
	public class HealCommand : SimpleCommand
	{
		public HealCommand()
			: base("heal", "heals players")
		{
			instructions.Add("[/cmd]");
			instructions.Add("[/cmd] [target]");
			instructions.Add("[/cmd] [target] [value]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = sender;
			int num = 100;
			if (!parameters.IsEmpty())
			{
				string stringAt = parameters.GetStringAt(0);
				PlayerControllerB player = SimpleCommand.GetPlayer(stringAt);
				if (!((Object)(object)player != (Object)null))
				{
					success = false;
					return UnknownPlayerException(stringAt);
				}
				val = player;
				if (parameters.Count() > 1)
				{
					bool isNumber;
					int numberAt = parameters.GetNumberAt(1, out isNumber);
					if (isNumber)
					{
						num = numberAt;
					}
				}
			}
			val.DamagePlayer(-num, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
			success = true;
			return "Healed " + val.playerUsername + ".";
		}
	}
	public class InfiniteSprintCommand : SimpleCommand
	{
		public InfiniteSprintCommand()
			: base("stamina", "toggle infinate sprint")
		{
			instructions.Add("[/cmd]");
			instructions.Add("[/cmd] [target]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			PlayerControllerB val = sender;
			success = false;
			if (!parameters.IsEmpty())
			{
				string stringAt = parameters.GetStringAt(0);
				PlayerControllerB player = SimpleCommand.GetPlayer(stringAt);
				if (!((Object)(object)player != (Object)null))
				{
					return UnknownPlayerException(stringAt);
				}
				val = player;
			}
			if (toggleInfiniteStamina(val, out var newValue))
			{
				success = true;
				return "Infinite Stamina for " + val.playerUsername + " set to " + newValue;
			}
			return "";
		}

		private bool toggleInfiniteStamina(PlayerControllerB player, out bool newValue)
		{
			PlayerModification playerModification = default(PlayerModification);
			if (((Component)player).TryGetComponent<PlayerModification>(ref playerModification))
			{
				newValue = !playerModification.infinateSprint;
				playerModification.infinateSprint = newValue;
				return true;
			}
			newValue = false;
			return false;
		}
	}
	public class InvulnerabilityCommand : SimpleCommand
	{
		public InvulnerabilityCommand()
			: base("god", "toggle invulnerability")
		{
			instructions.Add("[/cmd]");
			instructions.Add("[/cmd] [target]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			PlayerControllerB val = sender;
			success = false;
			if (!parameters.IsEmpty())
			{
				string stringAt = parameters.GetStringAt(0);
				PlayerControllerB player = SimpleCommand.GetPlayer(stringAt);
				if (!((Object)(object)player != (Object)null))
				{
					return UnknownPlayerException(stringAt);
				}
				val = player;
			}
			if (toggleInvulnerability(val, out var newValue))
			{
				success = true;
				return "Invulnerability for " + val.playerUsername + " set to " + newValue;
			}
			return "";
		}

		private bool toggleInvulnerability(PlayerControllerB player, out bool newValue)
		{
			PlayerModification playerModification = default(PlayerModification);
			if (((Component)player).TryGetComponent<PlayerModification>(ref playerModification))
			{
				newValue = !playerModification.invulnerable;
				playerModification.invulnerable = newValue;
				return true;
			}
			newValue = false;
			return false;
		}
	}
	public class ItemCommand : SimpleCommand
	{
		public ItemCommand()
			: base("item", "spawns item")
		{
			instructions.Add("[/cmd] [item]");
			instructions.Add("[/cmd] [target] [item]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			success = false;
			if (((NetworkBehaviour)sender).IsHost || ((NetworkBehaviour)sender).IsServer)
			{
				PlayerControllerB val = sender;
				string text = "";
				if (!parameters.IsEmpty())
				{
					string @string = parameters.GetString();
					if (parameters.Count(2))
					{
						PlayerControllerB player = SimpleCommand.GetPlayer(@string);
						text = parameters.GetString();
						if (!((Object)(object)player != (Object)null))
						{
							return UnknownPlayerException(name);
						}
						val = player;
					}
					else
					{
						text = @string;
					}
				}
				Terminal terminal = SimpleCommand.GetTerminal();
				if ((Object)(object)terminal == (Object)null)
				{
					return MissingTerminal();
				}
				List<Item> list = new List<Item>();
				foreach (Item items in RoundManager.Instance.playersManager.allItemsList.itemsList)
				{
					if (items.itemName.ToLower().Replace(' ', '_').StartsWith(text.ToLower()))
					{
						list.Add(items);
					}
				}
				if (list.Count > 0)
				{
					int index = 0;
					for (int i = 0; i < list.Count; i++)
					{
						if (list[i].itemName.Length < list[index].itemName.Length)
						{
							index = i;
						}
					}
					GameObject val2 = Object.Instantiate<GameObject>(list[index].spawnPrefab, ((Component)val).transform.position, Quaternion.identity);
					GrabbableObject component = val2.GetComponent<GrabbableObject>();
					component.fallTime = 0f;
					if (list[index].isScrap)
					{
						component.SetScrapValue(Random.Range(list[index].minValue, list[index].maxValue));
					}
					((Component)component).GetComponent<NetworkObject>().Spawn(false);
					success = true;
					return "Gave " + val.playerUsername + " " + list[index].itemName + ".";
				}
				return "Unknown Item: " + text;
			}
			return "";
		}
	}
	public class ItemsCommand : SimpleCommand
	{
		public ItemsCommand()
			: base("items", "lists items")
		{
			overrideShowOutput = true;
			permissionRequired = false;
			instructions.Add("[/cmd] - lists item ids");
			instructions.Add("[/cmd] [page]");
			tagInfo.Add("'Store':\nFilters to show store items");
			tagInfo.Add("'Scrap':\nFilters to show scrap items");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			List<Item> list = new List<Item>();
			string header = "";
			bool flag = parameters.isFlagged("store");
			bool flag2 = parameters.isFlagged("scrap");
			if (flag || flag2)
			{
				if (flag)
				{
					header = "Buyable Items:";
					Terminal terminal = SimpleCommand.GetTerminal();
					if ((Object)(object)terminal == (Object)null)
					{
						success = false;
						return MissingTerminal();
					}
					list.AddRange(terminal.buyableItemsList);
				}
				if (flag2)
				{
					header = "Scrap for Moon:";
					foreach (SpawnableItemWithRarity item in StartOfRound.Instance.currentLevel.spawnableScrap)
					{
						list.Add(item.spawnableItem);
					}
				}
				if (flag && flag2)
				{
					header = "Buyables & Scrap:";
				}
			}
			else
			{
				header = "All Items:";
				list.AddRange(RoundManager.Instance.playersManager.allItemsList.itemsList);
			}
			List<string> list2 = new List<string>();
			foreach (Item item2 in list)
			{
				list2.Add(item2.itemName.Replace(' ', '_'));
			}
			int page = 0;
			if (!parameters.IsEmpty())
			{
				page = parameters.GetNumber();
			}
			success = true;
			SimpleCommand.ClearChat();
			return PagedList(header, list2, page, 8);
		}
	}
	public class ListCommand : SimpleCommand
	{
		public ListCommand()
			: base("list", "lists players")
		{
			overrideShowOutput = true;
			permissionRequired = false;
			instructions.Add("[/cmd]");
			instructions.Add("[/cmd] [page]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			List<string> list = new List<string>();
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			PlayerControllerB[] array = allPlayerScripts;
			foreach (PlayerControllerB val in array)
			{
				if (val.isPlayerControlled && !val.isPlayerDead)
				{
					list.Add(val.playerUsername.Replace(' ', '_'));
				}
			}
			int page = 0;
			if (!parameters.IsEmpty())
			{
				page = parameters.GetNumber();
			}
			success = true;
			return PagedList("Players in Lobby:", list, page, 4);
		}
	}
	public class HelpCommand : SimpleCommand
	{
		public HelpCommand()
			: base("help", "lists commands")
		{
			overrideShowOutput = true;
			permissionRequired = false;
			instructions.Add("[/cmd] - Lists Commands");
			instructions.Add("[/cmd] [page]");
			instructions.Add("[/cmd] [cmd]");
			instructions.Add("[/cmd] [cmd] [page]");
			instructions.Add("[/cmd] [cmd] (flags)");
			instructions.Add("[/cmd] [cmd] (flags) [page]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			success = true;
			int page = 0;
			if (!parameters.IsEmpty())
			{
				page = parameters.GetNumberAt(0, out var isNumber);
				if (!isNumber)
				{
					string @string = parameters.GetString();
					SimpleCommand simpleCommand = SimpleCommand.tryGetCommand(@string);
					if (simpleCommand != null)
					{
						if (parameters.Count(2))
						{
							string string2 = parameters.GetString();
							if (string2 == "flags")
							{
								if (parameters.Count(3))
								{
									page = parameters.GetNumberAt(2);
								}
								SimpleCommand.ClearChat();
								return PagedList(simpleCommand.name.ToUpper() + " Accepted Flags:", simpleCommand.tagInfo, page, 4);
							}
							page = parameters.GetNumberAt(1);
						}
						SimpleCommand.ClearChat();
						return PagedList(simpleCommand.name.ToUpper() + " Use Cases:\n" + SimpleCommand.GetPrefix() + "help " + simpleCommand.name + " flags\nfor flag info]", simpleCommand.instructions, page).Replace("[/cmd]", SimpleCommand.GetPrefix() + @string);
					}
					if (@string.ToLower() == "flags")
					{
						return "Flags Example:\n" + SimpleCommand.GetPrefix() + "pay | hide\n" + SimpleCommand.GetPrefix() + "help [cmd] flags\nto see flag modifiers.";
					}
				}
			}
			List<string> list = new List<string>();
			foreach (SimpleCommand command in SimpleCommand.GetCommands())
			{
				list.Add(SimpleCommand.GetPrefix() + command.name + " - " + command.description);
			}
			SimpleCommand.ClearChat();
			return PagedList("List of Commands:", list, page);
		}
	}
	public class PayCommand : SimpleCommand
	{
		public PayCommand()
			: base("pay", "free credits")
		{
			instructions.Add("[/cmd] - Grants 100 credits");
			instructions.Add("[/cmd] [value]");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			success = false;
			Terminal terminal = SimpleCommand.GetTerminal();
			if ((Object)(object)terminal == (Object)null)
			{
				return MissingTerminal();
			}
			int num = ((!parameters.IsEmpty()) ? parameters.GetNumber() : 100);
			if (num != 0)
			{
				terminal.groupCredits += num;
				success = true;
				return "Received " + num + " Credits.";
			}
			return "";
		}
	}
	public abstract class SimpleCommand
	{
		public class CommandParameters
		{
			private List<string> parameters;

			private List<string> flags;

			private int place = 0;

			public CommandParameters(List<string> parameters, List<string> flags)
			{
				this.parameters = parameters;
				this.flags = flags;
			}

			public bool isFlagged(string flag)
			{
				return flags.Contains(flag.ToLower());
			}

			public bool Count(int value)
			{
				return parameters.Count >= value;
			}

			public int Count()
			{
				return parameters.Count;
			}

			public bool IsEmpty()
			{
				return parameters.Count == 0;
			}

			public string asString()
			{
				return "parameters: [" + string.Join(", ", parameters.ToArray()) + "], flags: [" + string.Join(", ", flags.ToArray()) + "]";
			}

			public string GetLowerCase()
			{
				return GetString().ToLower();
			}

			public string GetString()
			{
				string stringAt = GetStringAt(Math.Min(parameters.Count - 1, place));
				place++;
				return stringAt;
			}

			public string GetStringAt(int index)
			{
				return parameters[index];
			}

			public string GetLast()
			{
				return GetStringAt(parameters.Count - 1);
			}

			public int GetNumber()
			{
				bool isNumber;
				int numberAt = GetNumberAt(Math.Min(parameters.Count - 1, place), out isNumber);
				place++;
				return numberAt;
			}

			public int GetNumberAt(int index)
			{
				bool isNumber;
				return GetNumberAt(index, out isNumber);
			}

			public int GetNumberAt(int index, out bool isNumber)
			{
				isNumber = int.TryParse(parameters[index], out var result);
				if (isNumber)
				{
					return result;
				}
				return 0;
			}

			public PlayerControllerB? GetPlayer()
			{
				PlayerControllerB playerAt = GetPlayerAt(Math.Min(parameters.Count - 1, place));
				place++;
				return playerAt;
			}

			public PlayerControllerB? GetPlayerAt(int index)
			{
				return SimpleCommand.GetPlayer(parameters[index]);
			}

			public bool GetVector(out Vector3 vector)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return GetRelativeVector(Vector3.zero, out vector);
			}

			public bool GetVectorAt(int startIndex, out Vector3 vector)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				return GetRelativeVectorAt(startIndex, Vector3.zero, out vector);
			}

			public bool GetRelativeVector(Vector3 origin, out Vector3 vector)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				bool relativeVectorAt = GetRelativeVectorAt(Math.Min(parameters.Count - 1, place), origin, out vector);
				place += 3;
				return relativeVectorAt;
			}

			public bool GetRelativeVectorAt(int startIndex, Vector3 origin, out Vector3 vector)
			{
				//IL_0002: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: 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)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				vector = Vector3.zero;
				if (startIndex + 2 < parameters.Count)
				{
					int[] array = new int[3];
					bool[] array2 = new bool[3];
					for (int i = 0; i < 3; i++)
					{
						string stringAt = GetStringAt(startIndex + i);
						if (stringAt.StartsWith("~"))
						{
							array2[i] = true;
							stringAt = stringAt.Substring(1);
							if (!int.TryParse(stringAt, out array[i]))
							{
								array[i] = 0;
							}
						}
						else
						{
							array2[i] = false;
							if (!int.TryParse(stringAt, out array[i]))
							{
								return false;
							}
						}
					}
					vector = new Vector3((float)array[0] + (array2[0] ? origin.x : 0f), (float)array[1] + (array2[1] ? origin.y : 0f), (float)array[2] + (array2[2] ? origin.z : 0f));
					return true;
				}
				return false;
			}
		}

		public string name;

		public string description;

		public bool permissionRequired = true;

		public bool overrideShowOutput = false;

		public List<string> instructions = new List<string>();

		public List<string> tagInfo = new List<string>();

		private static Terminal Terminal;

		private static readonly List<SimpleCommand> SimpleCommands = new List<SimpleCommand>();

		public SimpleCommand(string name, string description)
		{
			this.name = name;
			this.description = description;
		}

		public abstract string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success);

		public string PagedList(string header, List<string> entries, int page, int pageMax = 5)
		{
			List<string> list = new List<string>();
			int num = (int)Math.Ceiling((float)entries.Count / ((float)pageMax + 0f));
			page = Math.Clamp(page - 1, 0, num - 1);
			if (entries.Count > pageMax)
			{
				for (int i = Math.Clamp(page * pageMax, 0, entries.Count - 1); i < Math.Min(entries.Count, (page + 1) * pageMax); i++)
				{
					list.Add(entries[i]);
				}
				list.Add($"[Page {Math.Min(page + 1, num)} of {num}]");
			}
			else
			{
				list = entries;
			}
			return header + "\n" + string.Join("\n", list);
		}

		public string UnknownPlayerException(string username)
		{
			return "\"" + username + "\" is not in this lobby.";
		}

		public string UnknownNumberException()
		{
			return "A Number was not able to be parsed.";
		}

		public string UnknownVectorException()
		{
			return "A Position (X Y Z) was not able to be parsed.";
		}

		public string MissingTerminal()
		{
			return "Missing Terminal.";
		}

		public static List<SimpleCommand> GetCommands()
		{
			return SimpleCommands;
		}

		public static string GetPrefix()
		{
			return SimpleCommandsBase.commandPrefix.Value;
		}

		public static void Register(SimpleCommand command)
		{
			if (!command.overrideShowOutput)
			{
				command.tagInfo.Add("'Hide':\nHides command chat output.");
			}
			SimpleCommands.Add(command);
			SimpleCommandsBase.Instance.mls.LogInfo((object)("Registered Simple Command: " + GetPrefix() + " " + command.name));
		}

		public static bool tryParseCommand(string cmd, out SimpleCommand? command, out CommandParameters? parameters)
		{
			parameters = null;
			string[] array = cmd.Split(' ');
			command = tryGetCommand(array[0]);
			if (command == null)
			{
				return false;
			}
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			bool flag = true;
			for (int i = 1; i < array.Length; i++)
			{
				if (flag)
				{
					if (!(array[i] == ""))
					{
						if (array[i] == "|")
						{
							flag = false;
						}
						else
						{
							list.Add(array[i]);
						}
					}
				}
				else
				{
					list2.Add(array[i].ToLower());
				}
			}
			parameters = new CommandParameters(list, list2);
			return true;
		}

		public static SimpleCommand? tryGetCommand(string name)
		{
			foreach (SimpleCommand simpleCommand in SimpleCommands)
			{
				if (simpleCommand.name.ToLower() == name.ToLower())
				{
					return simpleCommand;
				}
			}
			return null;
		}

		public static PlayerControllerB? GetPlayer(string name)
		{
			List<PlayerControllerB> list = new List<PlayerControllerB>();
			PlayerControllerB[] allPlayerScripts = RoundManager.Instance.playersManager.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (val.playerUsername.ToLower().Replace(' ', '_').StartsWith(name.ToLower().Replace(' ', '_')))
				{
					list.Add(val);
				}
			}
			if (list.Count > 0)
			{
				int index = 0;
				for (int j = 0; j < list.Count; j++)
				{
					if (((Object)list[j]).name.Length < ((Object)list[index]).name.Length)
					{
						index = j;
					}
				}
				return list[index];
			}
			return null;
		}

		public static Terminal GetTerminal()
		{
			if (Object.op_Implicit((Object)(object)Terminal))
			{
				return Terminal;
			}
			return Terminal = Object.FindObjectOfType<Terminal>();
		}

		public static void ClearChat()
		{
			HUDManager instance = HUDManager.Instance;
			instance.ChatMessageHistory.Clear();
			((TMP_Text)instance.chatText).SetText("", true);
			instance.lastChatMessage = "";
		}
	}
	public class TeleportCommand : SimpleCommand
	{
		public TeleportCommand()
			: base("tp", "teleports players")
		{
			instructions.Add("[/cmd] [destination] - Teleports Self");
			instructions.Add("[/cmd] (ship | main | exit{#}) - Teleports Self");
			instructions.Add("[/cmd] [target] [destination]");
			instructions.Add("[/cmd] [target] (ship | main | exit{#})");
			instructions.Add("[/cmd] [x] [y] [z] - Teleports self");
			instructions.Add("[/cmd] [target] [x] [y] [z]");
			tagInfo.Add("'Animate':\nTeleport instantly skipping teleport animation.");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			string formalName = "";
			bool instant = !parameters.isFlagged("animate");
			success = false;
			switch (parameters.Count())
			{
			case 1:
			{
				string @string = parameters.GetString();
				PlayerControllerB player = SimpleCommand.GetPlayer(@string);
				if ((Object)(object)player != (Object)null)
				{
					text = sender.playerUsername;
					formalName = player.playerUsername;
					TeleportPlayer(sender, ((Component)player).transform.position, instant);
					break;
				}
				if (GetSpecialLocation(@string, out Vector3 pos2, out formalName, sender))
				{
					text = sender.playerUsername;
					TeleportPlayer(sender, pos2, instant);
					break;
				}
				return UnknownPlayerException(@string);
			}
			case 2:
			{
				string @string = parameters.GetString();
				PlayerControllerB player = SimpleCommand.GetPlayer(@string);
				if ((Object)(object)player == (Object)null)
				{
					return UnknownPlayerException(@string);
				}
				string string2 = parameters.GetString();
				PlayerControllerB player2 = SimpleCommand.GetPlayer(string2);
				if ((Object)(object)player2 == (Object)null)
				{
					if (!GetSpecialLocation(string2, out Vector3 pos, out formalName, player))
					{
						return UnknownPlayerException(string2);
					}
					text = player.playerUsername;
					TeleportPlayer(player, pos, instant);
				}
				else
				{
					text = sender.playerUsername;
					formalName = player.playerUsername;
					TeleportPlayer(player, ((Component)player2).transform.position, instant);
				}
				break;
			}
			case 3:
			{
				if (parameters.GetRelativeVector(((Component)sender).transform.position, out var vector2))
				{
					text = sender.playerUsername;
					formalName = vector2.x + ", " + vector2.y + ", " + vector2.z;
					TeleportPlayer(sender, vector2, instant);
					break;
				}
				return UnknownVectorException();
			}
			case 4:
			{
				string @string = parameters.GetString();
				PlayerControllerB player = SimpleCommand.GetPlayer(@string);
				if ((Object)(object)player != (Object)null)
				{
					if (parameters.GetRelativeVector(((Component)player).transform.position, out var vector))
					{
						text = player.playerUsername;
						formalName = vector.x + ", " + vector.y + ", " + vector.z;
						TeleportPlayer(player, vector, instant);
						break;
					}
					return UnknownVectorException();
				}
				return UnknownPlayerException(@string);
			}
			}
			if (text != "")
			{
				success = true;
				return "Teleporting " + text + " to " + formalName;
			}
			return "";
		}

		private bool GetSpecialLocation(string name, out Vector3 pos, out string formalName, PlayerControllerB target)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			if (name == "ship")
			{
				pos = new Vector3(0f, 0f, -14f);
				formalName = "your Autopilot Ship";
				return true;
			}
			int num = -1;
			int result;
			if (name == "main")
			{
				num = 0;
			}
			else if (name.StartsWith("exit") && int.TryParse(name.Substring(4), out result))
			{
				num = result;
			}
			if (num >= 0)
			{
				Vector3? entranceTeleportLocation = JLevelPropertyRegistry.GetEntranceTeleportLocation(num, !target.isInsideFactory, true);
				if (entranceTeleportLocation.HasValue)
				{
					pos = entranceTeleportLocation.Value;
					formalName = ((num == 0) ? "the Main Entrance" : $"Fire Exit #{num}");
					return true;
				}
			}
			formalName = "";
			pos = Vector3.zero;
			return false;
		}

		private void TeleportPlayer(PlayerControllerB player, Vector3 pos, bool instant)
		{
			//IL_001e: 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)
			if (instant)
			{
				player.TeleportPlayer(pos, false, 0f, false, true);
			}
			else
			{
				((MonoBehaviour)player).StartCoroutine(beamUpPlayer(player, pos));
			}
		}

		private IEnumerator beamUpPlayer(PlayerControllerB player, Vector3 pos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				Debug.Log((object)"Targeted player is null");
				yield break;
			}
			player.shipTeleporterId = 1;
			player.beamUpParticle.Play();
			yield return (object)new WaitForSeconds(3f);
			player.averageVelocity = 0f;
			player.velocityLastFrame = Vector3.zero;
			player.TeleportPlayer(pos, false, 0f, false, true);
			player.shipTeleporterId = -1;
		}
	}
	public class TerminalCommand : SimpleCommand
	{
		public TerminalCommand()
			: base("terminal", "Send Terminal Codes")
		{
			instructions.Add("[/cmd] [code] - Used for opening doors / disabling hazards.");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			success = false;
			Terminal terminal = SimpleCommand.GetTerminal();
			if ((Object)(object)terminal == (Object)null)
			{
				return MissingTerminal();
			}
			if (!parameters.IsEmpty())
			{
				string @string = parameters.GetString();
				TerminalPatch.terminalObjectRequest(terminal, @string);
				success = true;
				return "";
			}
			return "";
		}
	}
	public class WeatherCommand : SimpleCommand
	{
		public static Dictionary<string, string> weatherAlias = new Dictionary<string, string>();

		public WeatherCommand()
			: base("weather", "changes weather")
		{
			instructions.Add("[/cmd] (clear | dusty | foggy | rainy | stormy | eclipsed)");
			if (JCompatabilityHelper.IsModLoaded.WeatherRegistry)
			{
				instructions.Add("{Check /weatherregistry for weather registry weather ids}");
			}
			weatherAlias.Add("clear", "none");
			weatherAlias.Add("dust", "dustclouds");
			weatherAlias.Add("dusty", "dustclouds");
			weatherAlias.Add("fog", "foggy");
			weatherAlias.Add("rain", "rainy");
			weatherAlias.Add("storm", "stormy");
			weatherAlias.Add("eclipse", "eclipsed");
		}

		public override string Execute(PlayerControllerB sender, CommandParameters parameters, out bool success)
		{
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			success = false;
			if (!StartOfRound.Instance.inShipPhase)
			{
				return "Can not change weather mid round!";
			}
			if (parameters.Count() >= 1)
			{
				string text = parameters.GetLowerCase();
				string text2 = string.Empty;
				if (weatherAlias.ContainsKey(text))
				{
					text = weatherAlias[text];
				}
				if (JCompatabilityHelper.IsModLoaded.WeatherRegistry)
				{
					foreach (string customWeatherName in JWeatherRegistryHelper.GetCustomWeatherNames())
					{
						if (customWeatherName.ToLower().Replace(" ", "_").Equals(text))
						{
							text2 = customWeatherName;
							break;
						}
					}
				}
				SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
				if (text2.Equals(string.Empty))
				{
					LevelWeatherType currentWeather;
					switch (text)
					{
					case "none":
						currentWeather = (LevelWeatherType)(-1);
						break;
					case "dustclouds":
						currentWeather = (LevelWeatherType)0;
						break;
					case "foggy":
						currentWeather = (LevelWeatherType)3;
						break;
					case "rainy":
						currentWeather = (LevelWeatherType)1;
						break;
					case "stormy":
						currentWeather = (LevelWeatherType)2;
						break;
					case "eclipsed":
						currentWeather = (LevelWeatherType)5;
						break;
					default:
						return "Unknown Weather: " + text;
					}
					currentLevel.currentWeather = currentWeather;
				}
				else
				{
					JWeatherRegistryHelper.ChangeWeather(text2, currentLevel);
				}
				success = true;
				return "Set Weather for " + currentLevel.PlanetName + " to " + text + ".";
			}
			return "";
		}
	}
}
namespace Simple-Commands.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}