Decompiled source of ExtraTerminalCommands v1.6.3

BepInEx/plugins/ExtraTerminalCommands/ZachHaber.ExtraTerminalCommands.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using System.Timers;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExtraTerminalCommands.Handlers;
using ExtraTerminalCommands.Networking;
using ExtraTerminalCommands.TerminalCommands;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TerminalApi;
using TerminalApi.Classes;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Video;
using ZachHaber.ExtraTerminalCommands.NetcodePatcher;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ZachHaber")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.63+7411beb787619ed8ead1d0c6a13356db81b3ff8a")]
[assembly: AssemblyProduct("Extra Terminal Commands")]
[assembly: AssemblyTitle("ZachHaber.ExtraTerminalCommands")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ZachHaber/LCExtraTerminalCommands")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ExtraTerminalCommands
{
	public class Config
	{
		public static ConfigEntry<bool> configExtraCommandsList;

		public static ConfigEntry<bool> configLaunchCommand;

		public static ConfigEntry<bool> configAllowLaunchOnMoon;

		public static ConfigEntry<bool> configTimeCommand;

		public static ConfigEntry<bool> configTeleportCommand;

		public static ConfigEntry<bool> configTeleportPlayerCommand;

		public static ConfigEntry<bool> configInverseTeleportCommand;

		public static ConfigEntry<bool> configLightsCommand;

		public static ConfigEntry<bool> configDoorsCommand;

		public static ConfigEntry<bool> configIntroSongCommand;

		public static ConfigEntry<bool> configRandomMoonCommand;

		public static ConfigEntry<bool> configClearCommand;

		public static ConfigEntry<bool> configSwitchCommand;

		public static ConfigEntry<bool> configHornCommand;

		public static ConfigEntry<bool> configFlashCommand;

		public static ConfigEntry<bool> configPingCommand;

		public static ConfigEntry<bool> configAllowRandomWeatherFilter;

		public static ConfigEntry<bool> configHidePlanet;

		public static ConfigEntry<int> configRandomCommandPrice;

		public static ConfigEntry<int> configHornDefaultseconds;

		public static ConfigEntry<int> configHornMaxSeconds;

		public static ArrayConfigEntry launchCommandAliases = new ArrayConfigEntry("Aliases", "LaunchCommandAliases", "start", "Aliases for the Launch Command. Comma separated list of aliases.\nNote: Aliases are client-side only\nDefault: start");

		public static ArrayConfigEntry timeCommandAliases = new ArrayConfigEntry("Aliases", "TimeCommandAliases", "", "Aliases for the Time Command. Comma separated list of aliases");

		public static ArrayConfigEntry inverseTeleportCommandAliases = new ArrayConfigEntry("Aliases", "InverseTeleportCommandAliases", "", "Aliases for the InverseTeleport Command. Comma separated list of aliases");

		public static ArrayConfigEntry teleportCommandAliases = new ArrayConfigEntry("Aliases", "TeleportCommandAliases", "", "Aliases for the teleport Command. Comma separated list of aliases. Must be a single word with more than 1 character");

		public static ArrayConfigEntry lightsCommandAliases = new ArrayConfigEntry("Aliases", "LightsCommandAliases", "light", "Aliases for the Lights Command. Comma separated list of aliases\nDefault: light");

		public static ArrayConfigEntry doorsCommandAliases = new ArrayConfigEntry("Aliases", "DoorsCommandAliases", "door,d", "Aliases for the Doors Command. Comma separated list of aliases\nDefault: door,d");

		public static ArrayConfigEntry introSongCommandAliases = new ArrayConfigEntry("Aliases", "IntroSongCommandAliases", "", "Aliases for the IntroSong Command. Comma separated list of aliases");

		public static ArrayConfigEntry clearCommandAliases = new ArrayConfigEntry("Aliases", "ClearCommandAliases", "cls", "Aliases for the Clear Command. Comma separated list of aliases.\nDefault: cls");

		public static ArrayConfigEntry flashCommandAliases = new ArrayConfigEntry("Aliases", "FlashCommandAliases", "", "Aliases for the Flash Command. Comma separated list of aliases");

		public static ArrayConfigEntry pingCommandAliases = new ArrayConfigEntry("Aliases", "PingCommandAliases", "", "Aliases for the Ping Command. Comma separated list of aliases");

		public static ArrayConfigEntry hornCommandAliases = new ArrayConfigEntry("Aliases", "HornCommandAliases", "", "Aliases for the Horn Command. Comma separated list of aliases. Must be a single word with more than 1 character");

		public static ArrayConfigEntry switchCommandAliases = new ArrayConfigEntry("Aliases", "SwitchCommandAliases", "", "Aliases for the Switch Command. Comma separated list of aliases. Must be a single word with more than 1 character");

		public static ArrayConfigEntry randomCommandAliases = new ArrayConfigEntry("Aliases", "RandomCommandAliases", "", "Aliases for the Random Command. Comma separated list of aliases. Must be a single word with more than 1 character");

		public static void Bind()
		{
			ConfigFile config = ExtraTerminalCommandsBase.config;
			configExtraCommandsList = config.Bind<bool>("commands", "DisableCommandsList", false, "Disables the 'extra' command which shows the command list.");
			configLaunchCommand = config.Bind<bool>("commands", "DisableLaunch", false, "Disables the 'launch' command");
			configAllowLaunchOnMoon = config.Bind<bool>("launch", "AllowLaunch", true, "Allows the 'launch' command to be executed when on a moon. \nIf this is set to false the 'launch' command only works in space.");
			configTimeCommand = config.Bind<bool>("commands", "DisableTime", false, "Disables the 'time' command");
			configTeleportCommand = config.Bind<bool>("commands", "DisableTeleport", false, "Disables the 'tp' command");
			configTeleportPlayerCommand = config.Bind<bool>("commands", "DisableTeleportPlayer", false, "Disables the 'tp [player]' command for teleporting a specific player instead of the current one.\nOnly works if the main teleport command is enabled");
			configInverseTeleportCommand = config.Bind<bool>("commands", "DisableInverseTeleport", false, "Disables the 'itp' command");
			configFlashCommand = config.Bind<bool>("commands", "DisableFlashCommand", false, "Disables the 'flash' command");
			configPingCommand = config.Bind<bool>("commands", "DisablePingCommand", false, "Disables the 'ping' command");
			configLightsCommand = config.Bind<bool>("commands", "DisableLights", false, "Disables the 'lights' command");
			configDoorsCommand = config.Bind<bool>("commands", "DisableDoors", false, "Disables the 'doors' command");
			configIntroSongCommand = config.Bind<bool>("commands", "DisableIntroSong", false, "Disables the 'intro' command which plays the intro song when run");
			configRandomMoonCommand = config.Bind<bool>("commands", "DisableRandomMoon", false, "Disables the 'random' command to go to a random moon.");
			configClearCommand = config.Bind<bool>("commands", "DisableClear", false, "Disables the 'clear' command which clears all lines in the console.");
			configSwitchCommand = config.Bind<bool>("commands", "DisableSwitch", false, "Disables the 'sw' command, which does the same as the vanilla 'switch' command. Except that it also allows specifying a player by name");
			configHornCommand = config.Bind<bool>("commands", "DisableHorn", false, "Disables the 'horn' command, which sounds the horn for X amount of seconds");
			configRandomCommandPrice = config.Bind<int>("random", "RandomCommandPrice", 100, "The price of the 'random' command. You will not receive a confirmation warning.");
			configAllowRandomWeatherFilter = config.Bind<bool>("random", "AllowWeatherFilter", true, "When enabled allows you to filter out weather when going to a random moon by typing 'random weather'");
			configHidePlanet = config.Bind<bool>("random", "AllowPlanetHide", true, "When enabled will not show what planet you're going to when writing 'random'");
			configHornDefaultseconds = config.Bind<int>("horn", "SecondsEnabled", 10, "This is the default amount of seconds the horn will continue to sound when running 'horn'");
			configHornMaxSeconds = config.Bind<int>("horn", "MaxSeconds", 30, "This is the maximum amount of seconds the horn can sound when running 'horn [time]' Be warned, the higher this number more lag may occur.");
			launchCommandAliases.Bind();
			timeCommandAliases.Bind();
			teleportCommandAliases.Bind();
			inverseTeleportCommandAliases.Bind();
			flashCommandAliases.Bind();
			pingCommandAliases.Bind();
			lightsCommandAliases.Bind();
			doorsCommandAliases.Bind();
			introSongCommandAliases.Bind();
			randomCommandAliases.Bind();
			clearCommandAliases.Bind();
			switchCommandAliases.Bind();
			hornCommandAliases.Bind();
		}
	}
	public class ArrayConfigEntry
	{
		public string section;

		public string key;

		public string defaultValue;

		public string description;

		public ConfigEntry<string> config;

		public List<string> Value
		{
			get
			{
				return (from str in config.Value.Split(",", StringSplitOptions.RemoveEmptyEntries)
					select str.Trim()).ToList();
			}
			set
			{
				config.Value = string.Join(",", value);
			}
		}

		public ArrayConfigEntry(string section, string key, string defaultValue, string description)
		{
			this.section = section;
			this.key = key;
			this.defaultValue = defaultValue;
			this.description = description;
		}

		public void Bind()
		{
			config = ExtraTerminalCommandsBase.config.Bind<string>(section, key, defaultValue, description);
		}
	}
	[BepInPlugin("ZachHaber.ExtraTerminalCommands", "Extra Terminal Commands", "1.6.3")]
	[BepInDependency("atomic.terminalapi", "1.5.0")]
	public class ExtraTerminalCommandsBase : BaseUnityPlugin
	{
		public static ConfigFile config;

		public const string modGUID = "ZachHaber.ExtraTerminalCommands";

		public const string modName = "Extra Terminal Commands";

		public const string modVersion = "1.6.3";

		private readonly Harmony harmony = new Harmony("ZachHaber.ExtraTerminalCommands");

		public static AssetBundle MainAssetBundle;

		private static ExtraTerminalCommandsBase Instance;

		public static ManualLogSource mls;

		public static int daysJoined;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Extra Terminal Commands");
			config = ((BaseUnityPlugin)this).Config;
			Config.Bind();
			harmony.PatchAll();
			MainAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "extraterminalcommandsnetwork"));
			NetcodePatcher();
			mls.LogInfo((object)"Invoked NetcodePatcher");
			RegisterCommands();
			mls.LogInfo((object)"ZachHaber.ExtraTerminalCommands v1.6.3 has loaded!");
		}

		private void RegisterCommands()
		{
			if (!Config.configExtraCommandsList.Value)
			{
				ExtraCommands.extraCommands();
			}
			if (!Config.configLaunchCommand.Value)
			{
				LaunchCommand.launchCommand();
			}
			if (!Config.configDoorsCommand.Value)
			{
				DoorsCommand.doorsCommand();
			}
			if (!Config.configHornCommand.Value)
			{
				HornCommand.hornCommand();
			}
			if (!Config.configLightsCommand.Value)
			{
				LightsCommand.lightsCommand();
			}
			if (!Config.configTimeCommand.Value)
			{
				TimeCommand.timeCommand();
			}
			if (!Config.configSwitchCommand.Value)
			{
				SwitchCommand.switchCommand();
			}
			if (!Config.configTeleportCommand.Value)
			{
				TeleportCommand.teleportCommand();
			}
			if (!Config.configInverseTeleportCommand.Value)
			{
				InverseTeleportCommand.inverseTeleportCommand();
			}
			if (!Config.configFlashCommand.Value)
			{
				RadarBoosterCommands.FlashCommand();
			}
			if (!Config.configPingCommand.Value)
			{
				RadarBoosterCommands.PingCommand();
			}
			if (!Config.configRandomMoonCommand.Value)
			{
				RandomMoonCommand.randomMoonCommand();
			}
			if (!Config.configClearCommand.Value)
			{
				ClearScreenCommand.clearScreenCommand();
			}
			if (!Config.configIntroSongCommand.Value)
			{
				IntroSongCommand introSongCommand = new IntroSongCommand();
				introSongCommand.introSongCommand();
			}
			daysJoined = 0;
		}

		private static void NetcodePatcher()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				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);
					}
				}
			}
		}

		private void OnDestroy()
		{
			mls.LogInfo((object)"ZachHaber.ExtraTerminalCommands v1.6.3 was unloaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ZachHaber.ExtraTerminalCommands";

		public const string PLUGIN_NAME = "Extra Terminal Commands";

		public const string PLUGIN_VERSION = "1.6.3";
	}
}
namespace ExtraTerminalCommands.TerminalCommands
{
	internal class ClearScreenCommand
	{
		public static string description = "Clears the terminal view.";

		public static void clearScreenCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = description;
			val.DisplayTextSupplier = onClear;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("clear", commandInfo, Config.clearCommandAliases.Value);
		}

		private static string onClear()
		{
			if (ETCNetworkHandler.Instance.clearCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			return "";
		}
	}
	internal class DoorsCommand
	{
		public static string description = "Toggles the door switch.";

		public static void doorsCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = description;
			val.DisplayTextSupplier = onDoorCommand;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("doors", commandInfo, Config.doorsCommandAliases.Value);
		}

		private static string onDoorCommand()
		{
			if (ETCNetworkHandler.Instance.doorCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			if (!StartOfRound.Instance.shipDoorsEnabled)
			{
				return "You are currently not on a moon, you can not toggle the doors.\n\n";
			}
			string text = ((!StartOfRound.Instance.hangarDoorsClosed) ? "closed." : "opened.");
			InteractTrigger componentInChildren = GameObject.Find(StartOfRound.Instance.hangarDoorsClosed ? "StartButton" : "StopButton").GetComponentInChildren<InteractTrigger>();
			((UnityEvent<PlayerControllerB>)(object)componentInChildren.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
			return "Doors " + text + "\n\n";
		}
	}
	internal class ExtraCommands
	{
		public static void extraCommands()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			CommandInfo commandInfo = new CommandInfo
			{
				Category = "other",
				Description = "Shows extra commands."
			};
			Commands.AddCommandWithAliases("extra", commandInfo);
		}
	}
	internal class HornCommand
	{
		private const string hornSoundingText = "The horn will continue to sound.\n\n";

		private const string hornStoppingText = "Stopping the horn!\n\n";

		public static System.Timers.Timer blaringTimer = null;

		public static string description = "Holds the horn down for you for the next X-Amount of seconds or a pre-specified time if left unset.";

		public static void hornCommand()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_005b: Expected O, but got Unknown
			string cmd_string = "horn";
			Commands.Add(cmd_string, delegate(string input)
			{
				string text = returnText();
				if (text != "The horn will continue to sound.\n\n" && text != "Stopping the horn!\n\n")
				{
					return text;
				}
				if (input.Length == 0)
				{
					onHornTimed();
				}
				else
				{
					try
					{
						double val = double.Parse(input);
						val = Math.Min(val, ETCNetworkHandler.Instance.hornMaxSeconds);
						onHornTimed(val);
					}
					catch (Exception ex)
					{
						ExtraTerminalCommandsBase.mls.LogError((object)(ex.Message + "\n\nInputString: '" + input + "'"));
						return ex.Message + "\n\nInputString: '" + input + "'\n\n";
					}
				}
				return text;
			}, new CommandInfo
			{
				Title = "Horn [X seconds]?",
				Description = description,
				Category = "Extra"
			}, Config.hornCommandAliases.Value);
		}

		public static string returnText()
		{
			if (ETCNetworkHandler.Instance.hornCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			ShipAlarmCord horn = getHorn();
			if ((Object)(object)horn == (Object)null)
			{
				return "You have not yet purchased the horn.\n\n";
			}
			if (horn.otherClientHoldingCord)
			{
				return "The horn is already making sound!\n\n";
			}
			if (blaringTimer != null)
			{
				return "Stopping the horn!\n\n";
			}
			return "The horn will continue to sound.\n\n";
		}

		public static ShipAlarmCord getHorn()
		{
			return Object.FindAnyObjectByType<ShipAlarmCord>();
		}

		public static async Task onHornTimed(double seconds = 0.0)
		{
			if (blaringTimer != null)
			{
				StopHorn();
			}
			else
			{
				if (ETCNetworkHandler.Instance.hornCmdDisabled)
				{
					return;
				}
				seconds = ((seconds == 0.0) ? ((double)ETCNetworkHandler.Instance.hornSeconds) : seconds);
				ExtraTerminalCommandsBase.mls.LogInfo((object)$"Blaring horn for {seconds} seconds");
				ShipAlarmCord horn = getHorn();
				if (!((Object)(object)horn == (Object)null))
				{
					blaringTimer = new System.Timers.Timer(seconds * 1000.0);
					blaringTimer.Elapsed += delegate
					{
						OnTimerElapsedAsync();
					};
					blaringTimer.Start();
					while (blaringTimer.Enabled)
					{
						await Task.Delay(200);
						horn.HoldCordDown();
					}
				}
			}
		}

		private static void StopHorn()
		{
			if (blaringTimer != null)
			{
				blaringTimer.Stop();
				blaringTimer = null;
				ShipAlarmCord horn = getHorn();
				if (horn != null)
				{
					horn.StopHorn();
				}
			}
		}

		private static void OnTimerElapsedAsync()
		{
			StopHorn();
		}
	}
	internal class IntroSongCommand : NetworkBehaviour
	{
		public static string description = "Plays a song that reminds you what you are working towards!";

		public void introSongCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			//IL_002e: Expected O, but got Unknown
			CommandInfo commandInfo = new CommandInfo
			{
				Category = "Extra",
				Description = description,
				DisplayTextSupplier = PlayIntro
			};
			Commands.AddCommandWithAliases("intro", commandInfo, Config.introSongCommandAliases.Value);
		}

		public string PlayIntro()
		{
			if (ETCNetworkHandler.Instance.introCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			if (ETCNetworkHandler.Instance.introPlaying)
			{
				return "Song is already playing, please try again once it has stopped playing\n\n";
			}
			if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
			{
				ETCNetworkHandler.Instance.PlayIntroSongClientRpc();
			}
			else
			{
				ETCNetworkHandler.Instance.PlayIntroSongServerRpc();
			}
			return "Now playing a banger song!\n\n";
		}

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

		protected internal override string __getTypeName()
		{
			return "IntroSongCommand";
		}
	}
	internal class InverseTeleportCommand
	{
		public static string description = "Activates the Inverse Teleporter.";

		public static void inverseTeleportCommand()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = description;
			val.DisplayTextSupplier = OnInverseTeleportCommand;
			Commands.AddCommandWithAliases("itp", val, Config.inverseTeleportCommandAliases.Value);
		}

		private static string OnInverseTeleportCommand()
		{
			if (ETCNetworkHandler.Instance.itpCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			if (!StartOfRound.Instance.shipDoorsEnabled || !StartOfRound.Instance.currentLevel.planetHasTime)
			{
				return "You are currently not on a moon.\n\n";
			}
			if ((Object)(object)GameObject.Find("InverseTeleporter(Clone)") == (Object)null)
			{
				return "You do not own the inverse teleporter.\n\n";
			}
			ShipTeleporter component = GameObject.Find("InverseTeleporter(Clone)").GetComponent<ShipTeleporter>();
			FieldInfo field = ((object)component).GetType().GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);
			float num = (float)field.GetValue(component);
			if (field == null)
			{
				return "Your inverse teleporter does not have a cooldown.\n\n";
			}
			if ((Object)(object)component == (Object)null)
			{
				return "You do not own the inverse teleporter. If you do, try restarting the game.\n\n";
			}
			if (!component.buttonTrigger.interactable)
			{
				return "Inverse teleporter is on cooldown, " + Math.Round(num, 1) + " seconds remain.\n\n";
			}
			((UnityEvent<PlayerControllerB>)(object)component.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
			return "Teleporting player(s) into the facility.\n\n";
		}
	}
	internal class LaunchCommand
	{
		public static string description = "Launches or Lands the ship.";

		public static void launchCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = description;
			val.DisplayTextSupplier = OnLaunchCommand;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("launch", commandInfo, Config.launchCommandAliases.Value);
		}

		private static string OnLaunchCommand()
		{
			if (ETCNetworkHandler.Instance.launchCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			if (!NetworkManager.Singleton.IsHost && !NetworkManager.Singleton.IsServer && ExtraTerminalCommandsBase.daysJoined <= 0)
			{
				return "You have just joined this game. You can not launch the ship yet, please wait a day.\n\n";
			}
			if ((Object)(object)GameObject.Find("StartGameLever") == (Object)null)
			{
				return "Can not find start lever.\n\n";
			}
			StartMatchLever component = GameObject.Find("StartGameLever").GetComponent<StartMatchLever>();
			if ((Object)(object)component == (Object)null)
			{
				return "Can not find start lever.\n\n";
			}
			if ((StartOfRound.Instance.shipDoorsEnabled && !StartOfRound.Instance.shipHasLanded && !StartOfRound.Instance.shipIsLeaving) || (!StartOfRound.Instance.shipDoorsEnabled && StartOfRound.Instance.travellingToNewLevel))
			{
				return "Unable to complete action. The ship has already been launched.\n\n";
			}
			if (!ETCNetworkHandler.Instance.allowLaunchOnMoon && component.leverHasBeenPulled)
			{
				return "Could not launch to space, you can only launch to a moon. This is due to config settings.\n\n";
			}
			component.PullLever();
			component.LeverAnimation();
			if (component.leverHasBeenPulled)
			{
				component.StartGame();
				return "Ship landing\n\n";
			}
			component.EndGame();
			return "Ship launched\n\n";
		}
	}
	internal class LightsCommand
	{
		public static string description = "Switches the ship lights on and off.";

		public static void lightsCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = description;
			val.DisplayTextSupplier = onLightCommand;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("lights", commandInfo, Config.lightsCommandAliases.Value);
		}

		private static string onLightCommand()
		{
			if (ETCNetworkHandler.Instance.lightCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			string text = (StartOfRound.Instance.shipRoomLights.areLightsOn ? "off" : "on");
			((UnityEvent<PlayerControllerB>)(object)GameObject.Find("LightSwitch").GetComponent<InteractTrigger>().onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
			return "Turned the lights " + text + ".\n\n";
		}
	}
	internal class RadarBoosterCommands
	{
		public static string pingDescription = "Pings the current radar booster.";

		public static string flashDescription = "Flashes the current radar booster.";

		public static void PingCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = pingDescription;
			val.DisplayTextSupplier = OnPingCommand;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("ping", commandInfo, Config.pingCommandAliases.Value);
		}

		public static void FlashCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = flashDescription;
			val.DisplayTextSupplier = OnFlashCommand;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("flash", commandInfo, Config.flashCommandAliases.Value);
		}

		private static string OnPingCommand()
		{
			if (ETCNetworkHandler.Instance.pingCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			int currentRadarBooster = GetCurrentRadarBooster();
			if (currentRadarBooster <= 0)
			{
				return "Invalid target.\n\n";
			}
			ExtraTerminalCommandsBase.mls.LogInfo((object)$"Ping on {currentRadarBooster}");
			StartOfRound.Instance.mapScreen.PingRadarBooster(currentRadarBooster);
			return "Pinged radar booster.\n\n";
		}

		private static string OnFlashCommand()
		{
			if (ETCNetworkHandler.Instance.flashCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			int currentRadarBooster = GetCurrentRadarBooster();
			if (currentRadarBooster <= 0)
			{
				return "Invalid target.\n\n";
			}
			ExtraTerminalCommandsBase.mls.LogInfo((object)$"Flash on {currentRadarBooster}");
			StartOfRound.Instance.mapScreen.FlashRadarBooster(currentRadarBooster);
			return "Flashed radar booster.\n\n";
		}

		private static int GetCurrentRadarBooster()
		{
			int targetTransformIndex = StartOfRound.Instance.mapScreen.targetTransformIndex;
			PlayerControllerB targetedPlayer = StartOfRound.Instance.mapScreen.targetedPlayer;
			if ((Object)(object)targetedPlayer != (Object)null)
			{
				ExtraTerminalCommandsBase.mls.LogInfo((object)$"Ping/Flash called on Player {targetedPlayer.playerUsername} at targetTransformIndex {targetTransformIndex}");
				return -1;
			}
			if (targetTransformIndex < 0)
			{
				ExtraTerminalCommandsBase.mls.LogInfo((object)$"Ping/Flash called with invalid targetTransformIndex: {targetTransformIndex}");
				return -1;
			}
			return targetTransformIndex;
		}
	}
	internal class RandomMoonCommand
	{
		public static string description = "Sends you to a random moon. Use `random Weather` to blacklist moons with weather.";

		public static void randomMoonCommand()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_005b: Expected O, but got Unknown
			string cmd_string = "random";
			Commands.Add(cmd_string, delegate(string input)
			{
				if (input == "weather")
				{
					return onRandomMoonWeather();
				}
				return (input != "") ? ("Invalid option: '" + input + "'. option can only be 'weather'") : onRandomMoonNoFilter();
			}, new CommandInfo
			{
				Title = "random weather?",
				Category = "Extra",
				Description = description
			}, Config.randomCommandAliases.Value);
		}

		private static string getInvalidTravelText(StartOfRound startOfRound)
		{
			if (startOfRound.shipDoorsEnabled)
			{
				return "You are currently on a moon. Can not travel to a random moon\n\n";
			}
			if (startOfRound.travellingToNewLevel)
			{
				return "You are currently traveling to a moon\n\n";
			}
			return null;
		}

		private static string onRandomMoonNoFilter()
		{
			if (ETCNetworkHandler.Instance.randomCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			StartOfRound startOfRound = Object.FindObjectOfType<StartOfRound>();
			Terminal val = Object.FindObjectOfType<Terminal>();
			string invalidTravelText = getInvalidTravelText(startOfRound);
			if (invalidTravelText != null)
			{
				return invalidTravelText;
			}
			SelectableLevel[] moonsCatalogueList = val.moonsCatalogueList;
			List<SelectableLevel> list = new List<SelectableLevel>(moonsCatalogueList.Length);
			list.AddRange(moonsCatalogueList);
			List<SelectableLevel> moons = list;
			return goToRandomPlanet(moons);
		}

		private static string onRandomMoonWeather()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			if (!ETCNetworkHandler.Instance.allowWeatherFilter)
			{
				return "This filter is disabled by the host.\n\n";
			}
			StartOfRound startOfRound = Object.FindObjectOfType<StartOfRound>();
			Terminal val = Object.FindObjectOfType<Terminal>();
			string invalidTravelText = getInvalidTravelText(startOfRound);
			if (invalidTravelText != null)
			{
				return invalidTravelText;
			}
			List<SelectableLevel> list = new List<SelectableLevel>();
			SelectableLevel[] moonsCatalogueList = val.moonsCatalogueList;
			foreach (SelectableLevel val2 in moonsCatalogueList)
			{
				if ((int)val2.currentWeather == -1)
				{
					list.Add(val2);
				}
			}
			return goToRandomPlanet(list);
		}

		private static string goToRandomPlanet(List<SelectableLevel> moons)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound val = Object.FindObjectOfType<StartOfRound>();
			Terminal val2 = Object.FindObjectOfType<Terminal>();
			Random random = new Random();
			int num = Config.configRandomCommandPrice.Value;
			if (num < 0)
			{
				num = 0;
			}
			if (val2.groupCredits - num < 0)
			{
				return $"Could not go to a random moon, you have too little money, you need atleast: {num} credits.\n\n";
			}
			int index = random.Next(0, moons.Count);
			SelectableLevel val3 = moons[index];
			ExtraTerminalCommandsBase.mls.LogDebug((object)$"Traveling to Random Moon: {val3.PlanetName} - Weather {val3.currentWeather}");
			if (((NetworkBehaviour)val).IsHost || ((NetworkBehaviour)val).IsServer)
			{
				val.ChangeLevelClientRpc(val3.levelID, val2.groupCredits - num);
				ETCNetworkHandler.Instance.unknownPlanetClientRpc();
			}
			else
			{
				val.ChangeLevelServerRpc(val3.levelID, val2.groupCredits - num);
				ETCNetworkHandler.Instance.unknownPlanetServerRpc();
			}
			return "Traveled to ???\n\n";
		}
	}
	internal class SwitchCommand
	{
		public static string description = "Switches the camera view to the next or specified user";

		public static string basicDescription = "Switches the camera view to the next user. Does not allow specifying the user";

		public static void switchCommand()
		{
			//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_003d: 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_0062: Expected O, but got Unknown
			//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_0077: 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)
			//IL_00ae: Expected O, but got Unknown
			string text = "sw";
			Commands.Add(text, onSwitchCommand, new CommandInfo
			{
				Title = text.ToUpper() + " [Player Name]?",
				Category = "Extra",
				Description = description
			}, Config.switchCommandAliases.Value);
			TerminalApi.AddCommand("s", new CommandInfo
			{
				Category = "Extra",
				Description = basicDescription,
				DisplayTextSupplier = () => onSwitchCommand("")
			}, (string)null, true);
		}

		public static string returnText()
		{
			if (ETCNetworkHandler.Instance.switchCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			return "Switched radar scan view\n\n";
		}

		private static string onSwitchCommand(string input)
		{
			if (ETCNetworkHandler.Instance.switchCmdDisabled)
			{
				return returnText();
			}
			if (input.Length == 0)
			{
				switchNormal();
				return returnText();
			}
			if (switchInput(input))
			{
				return returnText();
			}
			return "Player '" + input + "' not found!\n\n";
		}

		public static bool switchNormal()
		{
			StartOfRound.Instance.mapScreen.SwitchRadarTargetForward(true);
			return true;
		}

		public static bool switchInput(string userInput)
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			int result = ((!int.TryParse(userInput, out result)) ? val.CheckForPlayerNameCommand("switch", userInput) : (result - 1));
			ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
			if (result < 0 || result >= mapScreen.radarTargets.Count || mapScreen.radarTargets[result] == null)
			{
				ExtraTerminalCommandsBase.mls.LogInfo((object)("'" + userInput + "' was not a valid player! "));
				return false;
			}
			PlayerControllerB component = ((Component)mapScreen.radarTargets[result].transform).gameObject.GetComponent<PlayerControllerB>();
			if ((Object)(object)component != (Object)null && !component.isPlayerControlled && !component.isPlayerDead && (Object)(object)component.redirectToEnemy == (Object)null)
			{
				ExtraTerminalCommandsBase.mls.LogInfo((object)$"Switch by player number: {result} is an invalid target");
				return false;
			}
			if (result < 0 || result >= StartOfRound.Instance.mapScreen.radarTargets.Count)
			{
				return false;
			}
			StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(result);
			return true;
		}
	}
	internal class TeleportCommand
	{
		public static string description = "Teleports the player name (or index) specified. Current selected if not specified.";

		public static void teleportCommand()
		{
			//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_003d: 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_0062: Expected O, but got Unknown
			string text = "tp";
			Commands.Add(text, OnTeleportCommand, new CommandInfo
			{
				Title = text.ToUpper() + " [Player Name]?",
				Category = "Extra",
				Description = description
			}, Config.teleportCommandAliases.Value);
		}

		public static async void TeleportOnMapSync(ShipTeleporter teleporter, string toTeleportUsername, int newIndex, int originalIndex)
		{
			int numDelays = 0;
			while (StartOfRound.Instance.mapScreen.targetTransformIndex != newIndex)
			{
				int num = numDelays + 1;
				numDelays = num;
				if (num > 10)
				{
					break;
				}
				ExtraTerminalCommandsBase.mls.LogInfo((object)("Waiting for camera update to finish... Currently Targeting " + StartOfRound.Instance.mapScreen.radarTargets.ElementAt(StartOfRound.Instance.mapScreen.targetTransformIndex)?.name + " != " + toTeleportUsername));
				await Task.Delay(20);
			}
			if (numDelays > 10)
			{
				ExtraTerminalCommandsBase.mls.LogError((object)"Syncing target players never finished!");
			}
			else
			{
				await Task.Delay(100);
				ExtraTerminalCommandsBase.mls.LogInfo((object)"Camera update finished!");
			}
			((UnityEvent<PlayerControllerB>)(object)teleporter.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
			if (originalIndex != -1)
			{
				await Task.Delay(100);
				StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(originalIndex);
			}
		}

		public static string OnTeleportCommand(string userInput = "")
		{
			if (ETCNetworkHandler.Instance.tpCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			if ((Object)(object)GameObject.Find("Teleporter(Clone)") == (Object)null)
			{
				return "You do not own the teleporter.\n\n";
			}
			ShipTeleporter component = GameObject.Find("Teleporter(Clone)").GetComponent<ShipTeleporter>();
			FieldInfo field = ((object)component).GetType().GetField("cooldownTime", BindingFlags.Instance | BindingFlags.NonPublic);
			float num = (float)field.GetValue(component);
			if (field == null)
			{
				return "Your teleporter does not have a cooldown.\n\n";
			}
			if ((Object)(object)component == (Object)null)
			{
				return "You do not own the teleporter. If you do, try restarting the game.\n\n";
			}
			if (!component.buttonTrigger.interactable)
			{
				return "Teleporter is on cooldown, " + Math.Round(num, 1) + " seconds remain.\n\n";
			}
			ManualCameraRenderer mapScreen = StartOfRound.Instance.mapScreen;
			ExtraTerminalCommandsBase.mls.LogInfo((object)("TP command called with '" + userInput + "'"));
			Terminal val = Object.FindObjectOfType<Terminal>();
			if (userInput.Length > 0 && !ETCNetworkHandler.Instance.tpPlayerCmdDisabled)
			{
				int result = ((!int.TryParse(userInput.Split(" ")[0], out result)) ? val.CheckForPlayerNameCommand("switch", userInput) : (result - 1));
				if (result < 0 || result >= mapScreen.radarTargets.Count || mapScreen.radarTargets[result] == null)
				{
					ExtraTerminalCommandsBase.mls.LogInfo((object)("'" + userInput + "' was not a valid player! "));
					return "Player " + userInput + " was not a valid player!\n\n";
				}
				PlayerControllerB component2 = ((Component)mapScreen.radarTargets[result].transform).gameObject.GetComponent<PlayerControllerB>();
				if ((Object)(object)component2 != (Object)null && !component2.isPlayerControlled && !component2.isPlayerDead && (Object)(object)component2.redirectToEnemy == (Object)null)
				{
					ExtraTerminalCommandsBase.mls.LogInfo((object)$"Teleport by player number: {result} is an invalid target");
					return $"Invalid target: {result}\n\n";
				}
				TransformAndName val2 = mapScreen.radarTargets[result];
				int targetTransformIndex = mapScreen.targetTransformIndex;
				if (targetTransformIndex != result)
				{
					ExtraTerminalCommandsBase.mls.LogInfo((object)$"'{userInput}' gave playerNum {result}. Radar is showing player '{mapScreen.radarTargets.ElementAt(targetTransformIndex)?.name}' - index {targetTransformIndex}. Transform index is {mapScreen.targetTransformIndex}. Switching to {val2.name} at index {result}");
					mapScreen.SwitchRadarTargetAndSync(result);
					TeleportOnMapSync(component, val2.name, result, targetTransformIndex);
					return $"Teleporting player {val2.name} {targetTransformIndex} to ship.\n\n";
				}
				ExtraTerminalCommandsBase.mls.LogInfo((object)"Already on the correct player! No switching needed!");
			}
			((UnityEvent<PlayerControllerB>)(object)component.buttonTrigger.onInteract).Invoke(GameNetworkManager.Instance.localPlayerController);
			if ((Object)(object)mapScreen.targetedPlayer == (Object)null)
			{
				mapScreen.SwitchRadarTargetForward(true);
			}
			return "Teleporting player to ship.\n\n";
		}
	}
	internal class TimeCommand
	{
		public static string description = "Displays the current time on the planet.";

		public static void timeCommand()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			CommandInfo val = new CommandInfo();
			val.Category = "Extra";
			val.Description = description;
			val.DisplayTextSupplier = OnTimeCommand;
			CommandInfo commandInfo = val;
			Commands.AddCommandWithAliases("time", commandInfo, Config.timeCommandAliases.Value);
		}

		private static string OnTimeCommand()
		{
			if (ETCNetworkHandler.Instance.timeCmdDisabled)
			{
				return "This command is disabled by the host.\n\n";
			}
			if (StartOfRound.Instance.currentLevel.planetHasTime && StartOfRound.Instance.shipDoorsEnabled)
			{
				return "The time is " + ((TMP_Text)HUDManager.Instance.clockNumber).text.Replace('\n', ' ') + ".\n\n";
			}
			return "You are currently not on a moon, please try again once you are on a moon.\n";
		}
	}
}
namespace ExtraTerminalCommands.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
		public static void HideMapScreenInfo(VideoPlayer ___screenLevelVideoReel, TextMeshProUGUI ___screenLevelDescription)
		{
			if (ETCNetworkHandler.Instance.allowHidePlanet && ETCNetworkHandler.Instance.randomMoonCommandRan)
			{
				((TMP_Text)___screenLevelDescription).text = "Orbiting: Unkown\nPopulation: Unknown\nConditions: Unknown\nFauna: Unknown\nWeather: Unknown";
				((Behaviour)___screenLevelVideoReel).enabled = false;
				___screenLevelVideoReel.clip = null;
				((Component)___screenLevelVideoReel).gameObject.SetActive(false);
				___screenLevelVideoReel.Stop();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("DisableShipSpeaker")]
		public static void DisableShipSpeaker()
		{
			if (ETCNetworkHandler.Instance.introPlaying)
			{
				if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
				{
					ETCNetworkHandler.Instance.canceledSongClientRpc();
				}
				else
				{
					ETCNetworkHandler.Instance.canceledSongServerRpc();
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnClientConnect")]
		public static void onClientConnectPatch()
		{
			ETCNetworkHandler instance = ETCNetworkHandler.Instance;
			if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)
			{
				ETCNetworkHandler.Instance.syncVariablesClientRpc(instance.extraCmdDisabled, instance.timeCmdDisabled, instance.launchCmdDisabled, instance.tpCmdDisabled, instance.itpCmdDisabled, instance.lightCmdDisabled, instance.doorCmdDisabled, instance.introCmdDisabled, instance.randomCmdDisabled, instance.clearCmdDisabled, instance.switchCmdDisabled, instance.hornCmdDisabled, instance.allowWeatherFilter, instance.allowHidePlanet, instance.randomMoonPrice, instance.allowLaunchOnMoon, instance.hornSeconds, instance.hornMaxSeconds, instance.tpPlayerCmdDisabled, instance.flashCmdDisabled, instance.pingCmdDisabled);
			}
			else
			{
				ETCNetworkHandler.Instance.syncVariablesServerRpc();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("OnLocalDisconnect")]
		public static void onLocalDisconnectPatch()
		{
			ExtraTerminalCommandsBase.daysJoined = 0;
		}

		[HarmonyPostfix]
		[HarmonyPatch("openingDoorsSequence")]
		public static void openingDoorsSequencePatch()
		{
			ExtraTerminalCommandsBase.daysJoined++;
		}
	}
}
namespace ExtraTerminalCommands.Networking
{
	public class ETCNetworkHandler : NetworkBehaviour
	{
		public bool introPlaying;

		public bool randomMoonCommandRan;

		public bool extraCmdDisabled = Config.configExtraCommandsList.Value;

		public bool timeCmdDisabled = Config.configTimeCommand.Value;

		public bool launchCmdDisabled = Config.configLaunchCommand.Value;

		public bool tpCmdDisabled = Config.configTeleportCommand.Value;

		public bool tpPlayerCmdDisabled = Config.configTeleportPlayerCommand.Value;

		public bool itpCmdDisabled = Config.configInverseTeleportCommand.Value;

		public bool flashCmdDisabled = Config.configFlashCommand.Value;

		public bool pingCmdDisabled = Config.configPingCommand.Value;

		public bool lightCmdDisabled = Config.configLightsCommand.Value;

		public bool doorCmdDisabled = Config.configDoorsCommand.Value;

		public bool introCmdDisabled = Config.configIntroSongCommand.Value;

		public bool randomCmdDisabled = Config.configRandomMoonCommand.Value;

		public bool clearCmdDisabled = Config.configClearCommand.Value;

		public bool switchCmdDisabled = Config.configSwitchCommand.Value;

		public bool hornCmdDisabled = Config.configHornCommand.Value;

		public bool allowWeatherFilter = Config.configAllowRandomWeatherFilter.Value;

		public bool allowHidePlanet = Config.configHidePlanet.Value;

		public int randomMoonPrice = Config.configRandomCommandPrice.Value;

		public bool allowLaunchOnMoon = Config.configAllowLaunchOnMoon.Value;

		public int hornSeconds = Config.configHornDefaultseconds.Value;

		public int hornMaxSeconds = Config.configHornMaxSeconds.Value;

		private CancellationTokenSource introTimerCancellation;

		public static ETCNetworkHandler Instance { get; private set; }

		public static event Action<string> LevelEvent;

		public override void OnNetworkSpawn()
		{
			ETCNetworkHandler.LevelEvent = null;
			if ((NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer) && (Object)(object)Instance != (Object)null)
			{
				((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true);
				ExtraTerminalCommandsBase.mls.LogWarning((object)"Despawned network object. Don't fear, if you just started a level, this may happen.");
			}
			Instance = this;
			((NetworkBehaviour)this).OnNetworkSpawn();
		}

		[ClientRpc]
		public void EventClientRpc(string eventName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: 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(1767865380u, val, (RpcDelivery)0);
				bool flag = eventName != null;
				((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
				if (flag)
				{
					((FastBufferWriter)(ref val2)).WriteValueSafe(eventName, false);
				}
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1767865380u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost) && ETCNetworkHandler.LevelEvent != null)
			{
				ETCNetworkHandler.LevelEvent(eventName);
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void syncVariablesServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(714943701u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 714943701u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					syncVariablesClientRpc(extraCmdDisabled, timeCmdDisabled, launchCmdDisabled, tpCmdDisabled, itpCmdDisabled, lightCmdDisabled, doorCmdDisabled, introCmdDisabled, randomCmdDisabled, clearCmdDisabled, switchCmdDisabled, hornCmdDisabled, allowWeatherFilter, allowHidePlanet, randomMoonPrice, allowLaunchOnMoon, hornSeconds, hornMaxSeconds, tpPlayerCmdDisabled, flashCmdDisabled, pingCmdDisabled);
				}
			}
		}

		[ClientRpc]
		public void syncVariablesClientRpc(bool extraCmd, bool timeCmd, bool launchCmd, bool tpCmd, bool itpCmd, bool lightCmd, bool doorCmd, bool introCmd, bool randomCmd, bool clearCmd, bool switchCmd, bool hornCmd, bool weatherFilter, bool hidePlanet, int moonPrice, bool launchOnMoon, int hornSec, int hornMaxSec, bool tpPlayerCmd, bool flashCmd, bool pingCmd)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			//IL_00b9: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: 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_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: 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_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(2873639102u, val, (RpcDelivery)0);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref extraCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref timeCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref launchCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref tpCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref itpCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref lightCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref doorCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref introCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref randomCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref clearCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref switchCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref hornCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref weatherFilter, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref hidePlanet, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, moonPrice);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref launchOnMoon, default(ForPrimitives));
					BytePacker.WriteValueBitPacked(val2, hornSec);
					BytePacker.WriteValueBitPacked(val2, hornMaxSec);
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref tpPlayerCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flashCmd, default(ForPrimitives));
					((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref pingCmd, default(ForPrimitives));
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2873639102u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					randomMoonPrice = moonPrice;
					extraCmdDisabled = extraCmd;
					timeCmdDisabled = timeCmd;
					launchCmdDisabled = launchCmd;
					tpCmdDisabled = tpCmd;
					itpCmdDisabled = itpCmd;
					tpPlayerCmdDisabled = tpPlayerCmd;
					flashCmdDisabled = flashCmd;
					pingCmdDisabled = pingCmd;
					lightCmdDisabled = lightCmd;
					doorCmdDisabled = doorCmd;
					introCmdDisabled = introCmd;
					randomCmdDisabled = randomCmd;
					clearCmdDisabled = clearCmd;
					switchCmdDisabled = switchCmd;
					hornCmdDisabled = hornCmd;
					allowWeatherFilter = weatherFilter;
					allowHidePlanet = hidePlanet;
					randomMoonPrice = moonPrice;
					allowLaunchOnMoon = launchOnMoon;
					hornSeconds = hornSec;
					hornMaxSeconds = hornMaxSec;
					ExtraTerminalCommandsBase.mls.LogInfo((object)"Synced variables with host.");
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void PlayIntroSongServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2218789444u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2218789444u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					ExtraTerminalCommandsBase.mls.LogInfo((object)"Called play intro ServerRPC");
					PlayIntroSongClientRpc();
				}
			}
		}

		[ClientRpc]
		public void PlayIntroSongClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: 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(2101638635u, val, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendClientRpc(ref val2, 2101638635u, val, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
			{
				ExtraTerminalCommandsBase.mls.LogInfo((object)"Called intro play ClientRPC");
				StartOfRound val3 = Object.FindObjectOfType<StartOfRound>();
				GameObject val4 = GameObject.Find("SpeakerAudio");
				if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
				{
					ExtraTerminalCommandsBase.mls.LogError((object)"Could not find speakers");
					return;
				}
				val4.GetComponent<AudioSource>().PlayOneShot(val3.shipIntroSpeechSFX);
				introPlaying = true;
				startIntroTimer();
			}
		}

		[ClientRpc]
		public void canceledSongClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(413619241u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 413619241u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					introPlaying = false;
					introTimerCancellation?.Cancel();
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void canceledSongServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(607983475u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 607983475u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					canceledSongClientRpc();
				}
			}
		}

		public async Task startIntroTimer()
		{
			try
			{
				await Task.Delay(38200, introTimerCancellation.Token);
				introPlaying = false;
			}
			catch (TaskCanceledException)
			{
				introPlaying = false;
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void unknownPlanetServerRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
				{
					ServerRpcParams val = default(ServerRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(3420009220u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendServerRpc(ref val2, 3420009220u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
				{
					unknownPlanetClientRpc();
				}
			}
		}

		[ClientRpc]
		public void unknownPlanetClientRpc()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost))
				{
					ClientRpcParams val = default(ClientRpcParams);
					FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(957917816u, val, (RpcDelivery)0);
					((NetworkBehaviour)this).__endSendClientRpc(ref val2, 957917816u, val, (RpcDelivery)0);
				}
				if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost))
				{
					randomMoonCommandRan = true;
					undoRandomMoonCmd();
				}
			}
		}

		private async Task undoRandomMoonCmd()
		{
			await Task.Delay(6000);
			randomMoonCommandRan = false;
		}

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

		[RuntimeInitializeOnLoadMethod]
		internal static void InitializeRPCS_ETCNetworkHandler()
		{
			//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
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			NetworkManager.__rpc_func_table.Add(1767865380u, new RpcReceiveHandler(__rpc_handler_1767865380));
			NetworkManager.__rpc_func_table.Add(714943701u, new RpcReceiveHandler(__rpc_handler_714943701));
			NetworkManager.__rpc_func_table.Add(2873639102u, new RpcReceiveHandler(__rpc_handler_2873639102));
			NetworkManager.__rpc_func_table.Add(2218789444u, new RpcReceiveHandler(__rpc_handler_2218789444));
			NetworkManager.__rpc_func_table.Add(2101638635u, new RpcReceiveHandler(__rpc_handler_2101638635));
			NetworkManager.__rpc_func_table.Add(413619241u, new RpcReceiveHandler(__rpc_handler_413619241));
			NetworkManager.__rpc_func_table.Add(607983475u, new RpcReceiveHandler(__rpc_handler_607983475));
			NetworkManager.__rpc_func_table.Add(3420009220u, new RpcReceiveHandler(__rpc_handler_3420009220));
			NetworkManager.__rpc_func_table.Add(957917816u, new RpcReceiveHandler(__rpc_handler_957917816));
		}

		private static void __rpc_handler_1767865380(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool flag = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives));
				string eventName = null;
				if (flag)
				{
					((FastBufferReader)(ref reader)).ReadValueSafe(ref eventName, false);
				}
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ETCNetworkHandler)(object)target).EventClientRpc(eventName);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_714943701(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ETCNetworkHandler)(object)target).syncVariablesServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2873639102(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0086: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				bool extraCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref extraCmd, default(ForPrimitives));
				bool timeCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref timeCmd, default(ForPrimitives));
				bool launchCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref launchCmd, default(ForPrimitives));
				bool tpCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref tpCmd, default(ForPrimitives));
				bool itpCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref itpCmd, default(ForPrimitives));
				bool lightCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref lightCmd, default(ForPrimitives));
				bool doorCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref doorCmd, default(ForPrimitives));
				bool introCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref introCmd, default(ForPrimitives));
				bool randomCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref randomCmd, default(ForPrimitives));
				bool clearCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref clearCmd, default(ForPrimitives));
				bool switchCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref switchCmd, default(ForPrimitives));
				bool hornCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hornCmd, default(ForPrimitives));
				bool weatherFilter = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref weatherFilter, default(ForPrimitives));
				bool hidePlanet = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref hidePlanet, default(ForPrimitives));
				int moonPrice = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref moonPrice);
				bool launchOnMoon = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref launchOnMoon, default(ForPrimitives));
				int hornSec = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref hornSec);
				int hornMaxSec = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref hornMaxSec);
				bool tpPlayerCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref tpPlayerCmd, default(ForPrimitives));
				bool flashCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flashCmd, default(ForPrimitives));
				bool pingCmd = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref pingCmd, default(ForPrimitives));
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ETCNetworkHandler)(object)target).syncVariablesClientRpc(extraCmd, timeCmd, launchCmd, tpCmd, itpCmd, lightCmd, doorCmd, introCmd, randomCmd, clearCmd, switchCmd, hornCmd, weatherFilter, hidePlanet, moonPrice, launchOnMoon, hornSec, hornMaxSec, tpPlayerCmd, flashCmd, pingCmd);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2218789444(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ETCNetworkHandler)(object)target).PlayIntroSongServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2101638635(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ETCNetworkHandler)(object)target).PlayIntroSongClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_413619241(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ETCNetworkHandler)(object)target).canceledSongClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_607983475(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ETCNetworkHandler)(object)target).canceledSongServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_3420009220(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((ETCNetworkHandler)(object)target).unknownPlanetServerRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_957917816(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				target.__rpc_exec_stage = (__RpcExecStage)2;
				((ETCNetworkHandler)(object)target).unknownPlanetClientRpc();
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "ETCNetworkHandler";
		}
	}
	[HarmonyPatch]
	public class NetworkObjectManager
	{
		private static GameObject networkPrefab;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(GameNetworkManager), "Start")]
		public static void Init()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			if (!((Object)(object)networkPrefab != (Object)null))
			{
				networkPrefab = (GameObject)ExtraTerminalCommandsBase.MainAssetBundle.LoadAsset("Assets/AssetsBundlesWanted/NetworkHandler.prefab");
				networkPrefab.AddComponent<ETCNetworkHandler>();
				NetworkManager.Singleton.AddNetworkPrefab(networkPrefab);
				ExtraTerminalCommandsBase.mls.LogInfo((object)"Loaded NetworkHandler");
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		private static void SpawnNetworkHandler()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsHost || NetworkManager.Singleton.IsServer)
			{
				GameObject val = Object.Instantiate<GameObject>(networkPrefab, Vector3.zero, Quaternion.identity);
				val.GetComponent<NetworkObject>().Spawn(false);
				ExtraTerminalCommandsBase.mls.LogInfo((object)"Spawned NetworkHandler");
			}
		}
	}
}
namespace ExtraTerminalCommands.Handlers
{
	public delegate TResult FuncWI<out TResult>(string input = "");
	public class Command
	{
		public CommandInfo cmd_info;

		public string cmd_string;

		public FuncWI<string> cmd_func { get; set; }
	}
	public class Commands
	{
		public static List<Command> CommandInfos = new List<Command>();

		public static void Add(string cmd_string, FuncWI<string> cmd_func, CommandInfo cmd_info = null, List<string> aliases = null)
		{
			//IL_000b: 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_001d: Expected O, but got Unknown
			cmd_string = cmd_string.ToLower();
			if (cmd_info == null)
			{
				cmd_info = new CommandInfo
				{
					Category = "None"
				};
			}
			cmd_info.DisplayTextSupplier = () => Execute(TerminalApi.GetTerminalInput());
			AddCommandWithAliases(cmd_string, cmd_info, aliases, "");
			Command item = new Command
			{
				cmd_string = cmd_string,
				cmd_info = cmd_info,
				cmd_func = cmd_func
			};
			CommandInfos.Add(item);
			if (aliases == null)
			{
				return;
			}
			foreach (string alias in aliases)
			{
				CommandInfos.Add(new Command
				{
					cmd_string = alias,
					cmd_info = cmd_info,
					cmd_func = cmd_func
				});
			}
		}

		public static string Execute(string cmd_text)
		{
			string[] array = cmd_text.Split(new char[1] { ' ' });
			string text = null;
			string cmd = array[0];
			string input = string.Join(" ", array.Skip(1).ToArray()).Trim();
			Command command = CommandInfos.FirstOrDefault((Command cI) => cI.cmd_string == cmd);
			if (command != null)
			{
				text = command.cmd_func(input);
				return text.Trim() + "\n\n";
			}
			return text ?? "";
		}

		public static void AddCommandWithAliases(string command, CommandInfo commandInfo, List<string> aliases = null, string verbWord = null)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			if (aliases != null && aliases.Count > 0)
			{
				string text = ((aliases.Count > 1) ? "es" : "");
				string text2 = " (alias" + text + ": " + string.Join(", ", aliases.Select((string alias) => "'" + alias + "'")) + ")";
				TerminalApi.AddCommand(command, new CommandInfo
				{
					Title = (commandInfo.Title ?? command.ToUpper()) + text2,
					Category = commandInfo.Category,
					Description = commandInfo.Description,
					DisplayTextSupplier = commandInfo.DisplayTextSupplier
				}, verbWord, true);
				{
					foreach (string alias in aliases)
					{
						CommandInfo val = new CommandInfo
						{
							Category = "None",
							Description = commandInfo.Description,
							DisplayTextSupplier = commandInfo.DisplayTextSupplier
						};
						ExtraTerminalCommandsBase.mls.LogInfo((object)("Command " + command + " - Adding alias " + alias + "."));
						TerminalApi.AddCommand(alias, val, verbWord, true);
					}
					return;
				}
			}
			TerminalApi.AddCommand(command, commandInfo, verbWord, true);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace ZachHaber.ExtraTerminalCommands.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}