Decompiled source of VoiceShipControl v1.0.5

BepInEx/plugins/VoiceShipControl/VoiceShipControl.dll

Decompiled 9 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalConfig;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json.Linq;
using Unity.Netcode;
using UnityEngine;
using VoiceShipControl;
using VoiceShipControl.Helpers;
using VoiceShipControl.Patches;
using VoiceShipControl.Shared;

[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("VoiceShipControl")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+79825b0a2903cd4702a9c251865e1764677eaf9c")]
[assembly: AssemblyProduct("VoiceShipControl")]
[assembly: AssemblyTitle("VoiceShipControl")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
public delegate void MessageReceivedEvent(string message, EventArgs e);
public delegate void ErrorReceivedEvent(string error, EventArgs e);
public class SocketListener : MonoBehaviour
{
	public static SocketListener Instance;

	private static Socket _socket;

	private static Socket _handler;

	private static IPEndPoint remoteEndPoint;

	public static int connectionPort = 5050;

	public static bool IsServerStarted = false;

	public static bool IsWaitingMessage = false;

	public static bool IsConnectionStarted = false;

	public static TaskScheduler mainThreadContext;

	public static event MessageReceivedEvent OnMessageReceivedEvent;

	public static event ErrorReceivedEvent OnErrorReceivedEvent;

	public static void InitSocketListener(bool visible = false, string name = "SocketListener")
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		if ((Object)(object)Instance != (Object)null)
		{
			return;
		}
		if (Application.isPlaying)
		{
			GameObject val = new GameObject();
			if (!visible)
			{
				((Object)val).hideFlags = (HideFlags)61;
			}
			Instance = val.AddComponent<SocketListener>();
			Debug.Log((object)"SocketListener object created");
			StartServer();
		}
		mainThreadContext = TaskScheduler.FromCurrentSynchronizationContext();
	}

	public static void StartServer()
	{
		IPAddress iPAddress = IPAddress.Parse("127.0.0.1");
		IPEndPoint iPEndPoint = new IPEndPoint(iPAddress, connectionPort);
		_socket = new Socket(iPAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
		_socket.Bind(iPEndPoint);
		Console.WriteLine($"Server listening on {iPEndPoint}");
		_socket.Listen(10);
		Console.WriteLine("Waiting for a connection...");
	}

	public void Update()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		if (!IsServerStarted)
		{
			if (!IsConnectionStarted && _socket != null)
			{
				IsConnectionStarted = true;
				Console.WriteLine("Connecting...");
				((MonoBehaviour)Instance).StartCoroutine(Connect());
			}
			return;
		}
		KeyCode value = PluginConstants.VoiceActivationButton.Value;
		int mouseButton = KeyBindingHelper.GetMouseButton(value);
		if (Recognizer.IsProcessStarted && (UnityInput.Current.GetKeyDown(value) || UnityInput.Current.GetMouseButtonDown(mouseButton)) && !IsWaitingMessage)
		{
			Console.WriteLine("Broadcasting started");
			((MonoBehaviour)Instance).StartCoroutine(Broadcasting());
		}
	}

	public static IEnumerator Connect()
	{
		yield return (object)new WaitForSeconds(0.5f);
		try
		{
			Console.WriteLine("Trying to connect");
			_handler = _socket.Accept();
			if (_handler != null)
			{
				IsServerStarted = true;
				Console.WriteLine("Socket listener started");
				remoteEndPoint = (IPEndPoint)_handler.RemoteEndPoint;
				Console.WriteLine($"Accepted connection from {remoteEndPoint}");
			}
		}
		catch (Exception e)
		{
			Console.WriteLine(e.ToString());
		}
	}

	public static IEnumerator Broadcasting()
	{
		IsWaitingMessage = true;
		yield return (object)new WaitForSeconds(0f);
		SendData("continue");
		Thread receiveDataThread = new Thread(OnReceiveData);
		receiveDataThread.Start();
	}

	private static void OnReceiveData()
	{
		Task.Run(delegate
		{
			byte[] buffer = new byte[1024];
			int bytesReceived = _handler.Receive(buffer);
			Task.Factory.StartNew(delegate
			{
				if (bytesReceived > 0)
				{
					string @string = Encoding.UTF8.GetString(buffer, 0, bytesReceived);
					if (@string.Contains("Error"))
					{
						Instance.ErrorRecivedEventTrigger(@string);
					}
					else
					{
						Instance.MessageRecivedEventTrigger(@string);
					}
				}
				IsWaitingMessage = false;
			}, CancellationToken.None, TaskCreationOptions.None, mainThreadContext);
		});
	}

	public static void SendData(string data)
	{
		if (_handler == null)
		{
			Debug.Log((object)"Socket server not started SendData failed");
			return;
		}
		try
		{
			byte[] bytes = Encoding.ASCII.GetBytes(data.ToString());
			_handler.Send(bytes);
		}
		catch (Exception ex)
		{
			Console.WriteLine(ex.ToString());
		}
	}

	protected virtual void MessageRecivedEventTrigger(string value)
	{
		SocketListener.OnMessageReceivedEvent?.Invoke(value, EventArgs.Empty);
	}

	protected virtual void ErrorRecivedEventTrigger(string value)
	{
		ErrorReceivedEvent onErrorReceivedEvent = SocketListener.OnErrorReceivedEvent;
		Debug.Log((object)value);
		onErrorReceivedEvent?.Invoke(value, EventArgs.Empty);
	}

	public static void StopSocketListener()
	{
		SendData("stop");
		_socket = (_handler = null);
		IsServerStarted = (IsWaitingMessage = (IsConnectionStarted = false));
	}

	private void OnDestroy()
	{
		Delegate[] invocationList = SocketListener.OnMessageReceivedEvent.GetInvocationList();
		foreach (Delegate @delegate in invocationList)
		{
			OnMessageReceivedEvent -= (MessageReceivedEvent)@delegate;
		}
		Delegate[] invocationList2 = SocketListener.OnErrorReceivedEvent.GetInvocationList();
		foreach (Delegate delegate2 in invocationList2)
		{
			OnErrorReceivedEvent -= (ErrorReceivedEvent)delegate2;
		}
		Debug.Log((object)"Destriy SocketListener");
		StopSocketListener();
	}

	private void OnApplicationQuit()
	{
		StopSocketListener();
		Object.Destroy((Object)(object)this);
	}
}
namespace VoiceShipControl
{
	public enum SupportedLanguages
	{
		Afrikaans,
		Albanian,
		Amharic,
		Arabic,
		Armenian,
		Azerbaijani,
		Basque,
		Belarusian,
		Bengali,
		Bosnian,
		Bulgarian,
		Catalan,
		ChineseCantonese,
		ChineseMandarinSimplified,
		ChineseMandarinTraditional,
		Croatian,
		Czech,
		Danish,
		Dutch,
		English,
		Estonian,
		Filipino,
		Finnish,
		French,
		Galician,
		Georgian,
		German,
		Greek,
		Gujarati,
		Hebrew,
		Hindi,
		Hungarian,
		Icelandic,
		Indonesian,
		Italian,
		Japanese,
		Javanese,
		Kannada,
		Kazakh,
		Khmer,
		Korean,
		Kurdish,
		Kyrgyz,
		Lao,
		Latvian,
		Lithuanian,
		Luxembourgish,
		Macedonian,
		Malay,
		Malayalam,
		Marathi,
		Mongolian,
		Nepali,
		Norwegian,
		Oriya,
		Pashto,
		Persian,
		Polish,
		PortugueseBrazil,
		PortuguesePortugal,
		Punjabi,
		Romanian,
		Russian,
		Serbian,
		Sinhala,
		Slovak,
		Slovenian,
		Somali,
		Spanish,
		Sundanese,
		Swahili,
		Swedish,
		Tamil,
		Telugu,
		Thai,
		Turkish,
		Ukrainian,
		Urdu,
		Uzbek,
		Vietnamese,
		Welsh,
		Xhosa,
		Yiddish,
		Yoruba,
		Zulu
	}
	public static class PluginConstants
	{
		public static ConfigEntry<bool> IsUserCanUseCommandsOutsideTheShip;

		public static ConfigEntry<bool> IsUserCanUseCommandsWhenDead;

		public static ConfigEntry<bool> IsUserCanUseTeleportAlways;

		public static ConfigEntry<KeyCode> VoiceActivationButton;

		public static ConfigEntry<SupportedLanguages> LanguageCode;

		public static string PathToFolder = ((BaseUnityPlugin)VoiceShipControl.Instance).Info.Location.TrimEnd("VoiceShipControl.dll".ToCharArray());

		public static ConfigEntry<string> BuyKeyPhrase;

		public static ConfigEntry<string> TransmitKeyPhrase;

		public static ConfigEntry<string> RerouteKeyPhrase;

		public const string BuyVoiceCommandsKey = "buy-voice-commands";

		public static Dictionary<string, ConfigEntry<string>> BuyVoiceCommands = new Dictionary<string, ConfigEntry<string>>();

		public const string BuyVoiceCountCommandsKey = "buy-voice-count-commands";

		public static Dictionary<string, ConfigEntry<string>> BuyVoiceCountCommands = new Dictionary<string, ConfigEntry<string>>();

		public const string TerminalVoiceCommandsKey = "terminal-voice-commands";

		public static Dictionary<string, ConfigEntry<string>> TerminalVoiceCommands = new Dictionary<string, ConfigEntry<string>>();

		public const string VoiceCommandsKey = "voice-commands";

		public static Dictionary<string, ConfigEntry<string>> VoiceCommands = new Dictionary<string, ConfigEntry<string>>();

		public const string ReroutePlanetComandsKey = "reroute-planet-commands";

		public static Dictionary<string, ConfigEntry<string>> ReroutePlanetComands = new Dictionary<string, ConfigEntry<string>>();

		public const string VoicePlayAudioAssetsKey = "voice-assets";

		public static Dictionary<string, ConfigEntry<string>> VoicePlayAudioAssetNames = new Dictionary<string, ConfigEntry<string>>();

		public const string StartOfRoundAudioAssetNameKey = "start-game-voice-assets";

		public static ConfigEntry<string> StartOfRoundAudioAssetName;

		public const string EndOfRoundAudioAssetNameKey = "end-game-voice-assets";

		public static ConfigEntry<string> EndOfRoundAudioAssetName;

		public const string BuySuccessAudioAssetNameKey = "buy-success-voice-assets";

		public static ConfigEntry<string> BuySuccessAudioAssetName;

		public const string BuyDeclinedAudioAssetNameKey = "buy-declined-voice-assets";

		public static ConfigEntry<string> BuyDeclinedAudioAssetName;

		public const string ShipIntroAudioAssetNameKey = "ship-intro-assets";

		public static ConfigEntry<string> ShipIntroAudioAssetName;

		public const string StartGameKey = "start-game";

		public static ConfigEntry<string> StartGame;

		public const string EndGameKey = "end-game";

		public static ConfigEntry<string> EndGame;

		public const string CloseDoorKey = "close-door";

		public static ConfigEntry<string> CloseDoor;

		public const string OpenDoorKey = "open-door";

		public static ConfigEntry<string> OpenDoor;

		public const string SwitchOnKey = "switch-on";

		public static ConfigEntry<string> SwitchOn;

		public const string SwitchOffKey = "switch-off";

		public static ConfigEntry<string> SwitchOff;

		public const string TeleporterKey = "teleporter";

		public static ConfigEntry<string> Teleporter;

		public const string InverseTeleporterKey = "inverse-teleporter";

		public static ConfigEntry<string> InverseTeleporter;

		public const string SwitchMonitorKey = "switch-monitor";

		public static ConfigEntry<string> SwitchMonitor;

		public const string ToggleMonitorKey = "toggle-monitor";

		public static ConfigEntry<string> ToggleMonitor;

		public static readonly Dictionary<SupportedLanguages, string> LanguageDictionary = new Dictionary<SupportedLanguages, string>
		{
			{
				SupportedLanguages.Afrikaans,
				"af-ZA"
			},
			{
				SupportedLanguages.Albanian,
				"sq-AL"
			},
			{
				SupportedLanguages.Amharic,
				"am-ET"
			},
			{
				SupportedLanguages.Arabic,
				"ar-SA"
			},
			{
				SupportedLanguages.Armenian,
				"hy-AM"
			},
			{
				SupportedLanguages.Azerbaijani,
				"az-AZ"
			},
			{
				SupportedLanguages.Basque,
				"eu-ES"
			},
			{
				SupportedLanguages.Belarusian,
				"be-BY"
			},
			{
				SupportedLanguages.Bengali,
				"bn-IN"
			},
			{
				SupportedLanguages.Bosnian,
				"bs-BA"
			},
			{
				SupportedLanguages.Bulgarian,
				"bg-BG"
			},
			{
				SupportedLanguages.Catalan,
				"ca-ES"
			},
			{
				SupportedLanguages.ChineseCantonese,
				"yue-Hant-HK"
			},
			{
				SupportedLanguages.ChineseMandarinSimplified,
				"zh-CN"
			},
			{
				SupportedLanguages.ChineseMandarinTraditional,
				"zh-TW"
			},
			{
				SupportedLanguages.Croatian,
				"hr-HR"
			},
			{
				SupportedLanguages.Czech,
				"cs-CZ"
			},
			{
				SupportedLanguages.Danish,
				"da-DK"
			},
			{
				SupportedLanguages.Dutch,
				"nl-NL"
			},
			{
				SupportedLanguages.English,
				"en-US"
			},
			{
				SupportedLanguages.Estonian,
				"et-EE"
			},
			{
				SupportedLanguages.Filipino,
				"fil-PH"
			},
			{
				SupportedLanguages.Finnish,
				"fi-FI"
			},
			{
				SupportedLanguages.French,
				"fr-FR"
			},
			{
				SupportedLanguages.Galician,
				"gl-ES"
			},
			{
				SupportedLanguages.Georgian,
				"ka-GE"
			},
			{
				SupportedLanguages.German,
				"de-DE"
			},
			{
				SupportedLanguages.Greek,
				"el-GR"
			},
			{
				SupportedLanguages.Gujarati,
				"gu-IN"
			},
			{
				SupportedLanguages.Hebrew,
				"he-IL"
			},
			{
				SupportedLanguages.Hindi,
				"hi-IN"
			},
			{
				SupportedLanguages.Hungarian,
				"hu-HU"
			},
			{
				SupportedLanguages.Icelandic,
				"is-IS"
			},
			{
				SupportedLanguages.Indonesian,
				"id-ID"
			},
			{
				SupportedLanguages.Italian,
				"it-IT"
			},
			{
				SupportedLanguages.Japanese,
				"ja-JP"
			},
			{
				SupportedLanguages.Javanese,
				"jv-ID"
			},
			{
				SupportedLanguages.Kannada,
				"kn-IN"
			},
			{
				SupportedLanguages.Kazakh,
				"kk-KZ"
			},
			{
				SupportedLanguages.Khmer,
				"km-KH"
			},
			{
				SupportedLanguages.Korean,
				"ko-KR"
			},
			{
				SupportedLanguages.Kurdish,
				"ku-IQ"
			},
			{
				SupportedLanguages.Kyrgyz,
				"ky-KG"
			},
			{
				SupportedLanguages.Lao,
				"lo-LA"
			},
			{
				SupportedLanguages.Latvian,
				"lv-LV"
			},
			{
				SupportedLanguages.Lithuanian,
				"lt-LT"
			},
			{
				SupportedLanguages.Luxembourgish,
				"lb-LU"
			},
			{
				SupportedLanguages.Macedonian,
				"mk-MK"
			},
			{
				SupportedLanguages.Malay,
				"ms-MY"
			},
			{
				SupportedLanguages.Malayalam,
				"ml-IN"
			},
			{
				SupportedLanguages.Marathi,
				"mr-IN"
			},
			{
				SupportedLanguages.Mongolian,
				"mn-MN"
			},
			{
				SupportedLanguages.Nepali,
				"ne-NP"
			},
			{
				SupportedLanguages.Norwegian,
				"nb-NO"
			},
			{
				SupportedLanguages.Oriya,
				"or-IN"
			},
			{
				SupportedLanguages.Pashto,
				"ps-AF"
			},
			{
				SupportedLanguages.Persian,
				"fa-IR"
			},
			{
				SupportedLanguages.Polish,
				"pl-PL"
			},
			{
				SupportedLanguages.PortugueseBrazil,
				"pt-BR"
			},
			{
				SupportedLanguages.PortuguesePortugal,
				"pt-PT"
			},
			{
				SupportedLanguages.Punjabi,
				"pa-IN"
			},
			{
				SupportedLanguages.Romanian,
				"ro-RO"
			},
			{
				SupportedLanguages.Russian,
				"ru-RU"
			},
			{
				SupportedLanguages.Serbian,
				"sr-RS"
			},
			{
				SupportedLanguages.Sinhala,
				"si-LK"
			},
			{
				SupportedLanguages.Slovak,
				"sk-SK"
			},
			{
				SupportedLanguages.Slovenian,
				"sl-SI"
			},
			{
				SupportedLanguages.Somali,
				"so-SO"
			},
			{
				SupportedLanguages.Spanish,
				"es-ES"
			},
			{
				SupportedLanguages.Sundanese,
				"su-ID"
			},
			{
				SupportedLanguages.Swahili,
				"sw-TZ"
			},
			{
				SupportedLanguages.Swedish,
				"sv-SE"
			},
			{
				SupportedLanguages.Tamil,
				"ta-IN"
			},
			{
				SupportedLanguages.Telugu,
				"te-IN"
			},
			{
				SupportedLanguages.Thai,
				"th-TH"
			},
			{
				SupportedLanguages.Turkish,
				"tr-TR"
			},
			{
				SupportedLanguages.Ukrainian,
				"uk-UA"
			},
			{
				SupportedLanguages.Urdu,
				"ur-PK"
			},
			{
				SupportedLanguages.Uzbek,
				"uz-UZ"
			},
			{
				SupportedLanguages.Vietnamese,
				"vi-VN"
			},
			{
				SupportedLanguages.Welsh,
				"cy-GB"
			},
			{
				SupportedLanguages.Xhosa,
				"xh-ZA"
			},
			{
				SupportedLanguages.Yiddish,
				"yi-DE"
			},
			{
				SupportedLanguages.Yoruba,
				"yo-NG"
			},
			{
				SupportedLanguages.Zulu,
				"zu-ZA"
			}
		};
	}
	[BepInPlugin("Judik.VoiceShipControl", "Voice Ship Control", "1.0.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class VoiceShipControl : BaseUnityPlugin
	{
		private const string _modGUID = "Judik.VoiceShipControl";

		private const string _modName = "Voice Ship Control";

		private const string _modVersion = "1.0.4";

		private readonly Harmony harmony = new Harmony("Judik.VoiceShipControl");

		public static VoiceShipControl Instance;

		internal ManualLogSource _logger;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
				ConfigureVoiceShipControlSettings();
				_logger = Logger.CreateLogSource("Judik.VoiceShipControl");
				_logger.LogInfo((object)"Judik.VoiceShipControl has started");
				harmony.PatchAll(typeof(StartOfRoundPatch));
				AddSettingsMenu();
			}
		}

		public void AddSettingsMenu()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//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_003c: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0054: 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_006a: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: 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_0179: Expected O, but got Unknown
			//IL_017b: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Expected O, but got Unknown
			//IL_021b: 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_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Expected O, but got Unknown
			InputComponent terminalKeyInput = new InputComponent
			{
				Placeholder = "Terminal command (try use exist commands)"
			};
			InputComponent terminalValueInput = new InputComponent
			{
				Placeholder = "Command key phrase"
			};
			InputComponent voicePhraseValueInput = new InputComponent
			{
				Placeholder = "Command key phrase"
			};
			InputComponent voicePhraseAssetValueInput = new InputComponent
			{
				Placeholder = "Asset name"
			};
			ModSettingsConfig val = new ModSettingsConfig();
			val.Name = "Voice Ship Controll";
			val.Id = "Judik.VoiceShipControl";
			val.Version = "1.0.4";
			val.Description = "Here you can add your own key phrases with assets what should be played like an 'answer' to your in game 'assistant'. " + Environment.NewLine + "1. After any of 'Add' buttons click key phrase will be added to Lethal Config Settings, but not displayed untill game restart." + Environment.NewLine + "2. All key phrases can have multiple meaning. That's mean you can add more than 1 audio asset or phrase connected to same command. To separate it type '|' beetwen phrases/assets." + Environment.NewLine + "3. All key phrases stored in VoiceShipControl.json file. That's mean you can modify them directly there without this menu." + Environment.NewLine + "4. All assets what you can connect stored in VoiceShipControl/Assets folder." + Environment.NewLine + "5. For now there is no logic to remove commands, so if  you want to do it go to VoiceShipControl.json and just remove raw with that command what you want.";
			MenuComponent[] obj = new MenuComponent[9]
			{
				(MenuComponent)new LabelComponent
				{
					Text = "Add terminal key phrases.",
					FontSize = 14f
				},
				default(MenuComponent),
				default(MenuComponent),
				default(MenuComponent),
				default(MenuComponent),
				default(MenuComponent),
				default(MenuComponent),
				default(MenuComponent),
				default(MenuComponent)
			};
			HorizontalComponent val2 = new HorizontalComponent();
			val2.Children = (MenuComponent[])(object)new MenuComponent[2]
			{
				(MenuComponent)terminalKeyInput,
				(MenuComponent)terminalValueInput
			};
			obj[1] = (MenuComponent)val2;
			obj[2] = (MenuComponent)new ButtonComponent
			{
				Text = "Add",
				OnClick = delegate
				{
					JsonHelper.SetKeyValuePair(terminalKeyInput.Value, "terminal-voice-commands", terminalValueInput.Value);
					terminalValueInput.Value = string.Empty;
					terminalKeyInput.Value = string.Empty;
					PluginConstants.TerminalVoiceCommands.Add(terminalKeyInput.Value, ((BaseUnityPlugin)this).Config.Bind<string>("Terminal voice commands", terminalKeyInput.Value, terminalValueInput.Value, "Key phrase what you need to say to make some action via terminal. You can separate text with '|' to add multiple options"));
				}
			};
			obj[3] = (MenuComponent)new LabelComponent
			{
				Text = "Add custom voice commands.",
				FontSize = 14f
			};
			val2 = new HorizontalComponent();
			val2.Children = (MenuComponent[])(object)new MenuComponent[2]
			{
				(MenuComponent)new LabelComponent
				{
					Text = "Custom voice Key phrase: " + (PluginConstants.VoiceCommands.Count + 1),
					FontSize = 12f
				},
				(MenuComponent)terminalValueInput
			};
			obj[4] = (MenuComponent)val2;
			obj[5] = (MenuComponent)new ButtonComponent
			{
				Text = "Add",
				OnClick = delegate
				{
					JsonHelper.SetKeyValuePair("Custom voice Key phrase: " + PluginConstants.VoiceCommands.Count, "voice-commands", voicePhraseValueInput.Value);
					voicePhraseValueInput.Value = string.Empty;
					PluginConstants.VoiceCommands.Add("Custom Asset Key phrase: " + PluginConstants.VoiceCommands.Count, ((BaseUnityPlugin)this).Config.Bind<string>("Any voice commands", "Custom voice Key phrase: " + (PluginConstants.VoiceCommands.Count + 1), voicePhraseValueInput.Value, "Any Key phrase by which one will be played audio asset. You can separate text with '|' to add multiple options"));
				}
			};
			obj[6] = (MenuComponent)new LabelComponent
			{
				Text = "Add custom voice asset.",
				FontSize = 14f
			};
			val2 = new HorizontalComponent();
			val2.Children = (MenuComponent[])(object)new MenuComponent[2]
			{
				(MenuComponent)new LabelComponent
				{
					Text = "Custom voice asset for Key phrase: " + (PluginConstants.VoiceCommands.Count + 1),
					FontSize = 12f
				},
				(MenuComponent)terminalValueInput
			};
			obj[7] = (MenuComponent)val2;
			obj[8] = (MenuComponent)new ButtonComponent
			{
				Text = "Add",
				OnClick = delegate
				{
					JsonHelper.SetKeyValuePair("Custom voice asset for Key phrase: " + PluginConstants.VoicePlayAudioAssetNames.Count, "voice-commands", voicePhraseAssetValueInput.Value);
					voicePhraseValueInput.Value = string.Empty;
					PluginConstants.VoicePlayAudioAssetNames.Add("Custom Asset Key phrase: " + PluginConstants.VoicePlayAudioAssetNames.Count, ((BaseUnityPlugin)this).Config.Bind<string>("Played by voice audio assets", "Custom voice asset for Key phrase: " + (PluginConstants.VoicePlayAudioAssetNames.Count + 1), voicePhraseAssetValueInput.Value, "Any audio asset what will play by 'Any voice command'. You can separate text with '|' to add multiple options"));
				}
			};
			val.MenuComponents = (MenuComponent[])(object)obj;
			ModMenu.RegisterMod(val);
		}

		public void ConfigureVoiceShipControlSettings()
		{
			LethalConfigManager.SetModDescription("Enjoy my friends <3");
			PluginConstants.LanguageCode = ((BaseUnityPlugin)this).Config.Bind<SupportedLanguages>("General", "Language Code", SupportedLanguages.English, "Voice recognizer language code");
			PluginConstants.VoiceActivationButton = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Voice Command Activation Button", (KeyCode)327, "Voice command activation button");
			PluginConstants.IsUserCanUseCommandsOutsideTheShip = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Is user can use commands outside the ship?", false, "If user can use commands outside the ship then x if not empty");
			PluginConstants.IsUserCanUseCommandsWhenDead = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Is user can use commands when dead?", false, "If user can use commands outside the ship then x if not empty");
			PluginConstants.IsUserCanUseTeleportAlways = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Is user can use teleport always?", false, "If user can use teleport without cooldown");
			PluginConstants.BuyKeyPhrase = ((BaseUnityPlugin)this).Config.Bind<string>("Main key phrases", "Buy Key Phrase", "buy|need|waiting", "Key phrase what you need to say to make related purchase. You can separate text with '|' to add multiple options");
			PluginConstants.RerouteKeyPhrase = ((BaseUnityPlugin)this).Config.Bind<string>("Main key phrases", "Reroute Key Phrase", "route|go to|next planet", "Key phrase what you need to say to make rerouting to other planet. You can separate text with '|' to add multiple options");
			PluginConstants.TransmitKeyPhrase = ((BaseUnityPlugin)this).Config.Bind<string>("Main key phrases", "Transmit Key Phrase", "transmit|send|all", "Key phrase what you need to say to make message transmiting with 'Message transmitter'. You can separate text with '|' to add multiple options");
			string value = JsonHelper.GetValue("start-game");
			PluginConstants.StartGame = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Start game", value, "Start game command. You can separate text with '|' to add multiple options");
			string value2 = JsonHelper.GetValue("end-game");
			PluginConstants.EndGame = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "End game", value2, "End game command. You can separate text with '|' to add multiple options");
			string value3 = JsonHelper.GetValue("open-door");
			PluginConstants.OpenDoor = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Open ship door", value3, "Open ship door command. You can separate text with '|' to add multiple options");
			string value4 = JsonHelper.GetValue("close-door");
			PluginConstants.CloseDoor = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Close ship door", value4, "Close ship door command. You can separate text with '|' to add multiple options");
			string value5 = JsonHelper.GetValue("switch-on");
			PluginConstants.SwitchOn = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Turn ON ship light", value5, "Turn ON ship light command. You can separate text with '|' to add multiple options");
			string value6 = JsonHelper.GetValue("switch-off");
			PluginConstants.SwitchOff = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Turn OFF ship light", value6, "Turn OFF ship light command. You can separate text with '|' to add multiple options");
			string value7 = JsonHelper.GetValue("teleporter");
			PluginConstants.Teleporter = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Start teleporter", value7, "Start ship teleporter command. You can separate text with '|' to add multiple options");
			string value8 = JsonHelper.GetValue("inverse-teleporter");
			PluginConstants.InverseTeleporter = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Start inverse teleporter", value8, "Start inverse teleporter command. You can separate text with '|' to add multiple options");
			string value9 = JsonHelper.GetValue("switch-monitor");
			PluginConstants.SwitchMonitor = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Switch monitor view", value9, "Switch monitor view command. You can separate text with '|' to add multiple options");
			string value10 = JsonHelper.GetValue("toggle-monitor");
			PluginConstants.ToggleMonitor = ((BaseUnityPlugin)this).Config.Bind<string>("Static commands", "Toggle monitor", value10, "Toggle monitor command. You can separate text with '|' to add multiple options");
			string value11 = JsonHelper.GetValue("ship-intro-assets");
			PluginConstants.ShipIntroAudioAssetName = ((BaseUnityPlugin)this).Config.Bind<string>("Static assets", "Ship intro audio asset name", value11, "Any audio asset what will play instead default audio on ship from speacker. You can separate text with '|' to add multiple options");
			string value12 = JsonHelper.GetValue("buy-success-voice-assets");
			PluginConstants.BuySuccessAudioAssetName = ((BaseUnityPlugin)this).Config.Bind<string>("Static assets", "Buy SUCCESS audio asset name", value12, "Any audio asset what will play if purchase was SUCCESS. You can separate text with '|' to add multiple options");
			string value13 = JsonHelper.GetValue("buy-declined-voice-assets");
			PluginConstants.BuyDeclinedAudioAssetName = ((BaseUnityPlugin)this).Config.Bind<string>("Static assets", "Buy DICLINED audio asset name", value13, "Any audio asset what will play if purchase was DICLINED. You can separate text with '|' to add multiple options");
			string value14 = JsonHelper.GetValue("start-game-voice-assets");
			PluginConstants.StartOfRoundAudioAssetName = ((BaseUnityPlugin)this).Config.Bind<string>("Static assets", "Start of round audio asset name", value14, "Any audio asset what will play when round is started. You can separate text with '|' to add multiple options");
			string value15 = JsonHelper.GetValue("end-game-voice-assets");
			PluginConstants.EndOfRoundAudioAssetName = ((BaseUnityPlugin)this).Config.Bind<string>("Static assets", "End of round audio asset name", value15, "Any audio asset what will play when round is ended. You can separate text with '|' to add multiple options");
			Dictionary<string, string> keyValuePairs = JsonHelper.GetKeyValuePairs("reroute-planet-commands");
			foreach (KeyValuePair<string, string> item in keyValuePairs)
			{
				PluginConstants.ReroutePlanetComands.Add(item.Key, ((BaseUnityPlugin)this).Config.Bind<string>("Reroute key Phrases", item.Key, item.Value, "Key phrase what you need to say with 'Reroute Key Phrase' to land on other planet. You can separate text with '|' to add multiple options"));
			}
			Dictionary<string, string> keyValuePairs2 = JsonHelper.GetKeyValuePairs("buy-voice-commands");
			foreach (KeyValuePair<string, string> item2 in keyValuePairs2)
			{
				PluginConstants.BuyVoiceCommands.Add(item2.Key, ((BaseUnityPlugin)this).Config.Bind<string>("Buy key Phrases", item2.Key, item2.Value, "Key phrase what you need to say with 'Buy Key Phrase' to buy this item. You can separate text with '|' to add multiple options"));
			}
			Dictionary<string, string> keyValuePairs3 = JsonHelper.GetKeyValuePairs("buy-voice-count-commands");
			foreach (KeyValuePair<string, string> item3 in keyValuePairs3)
			{
				PluginConstants.BuyVoiceCountCommands.Add(item3.Key, ((BaseUnityPlugin)this).Config.Bind<string>("Buy count key Phrases", item3.Key, item3.Value, "Key phrase what you need to say with 'Buy Key Phrase' to buy related count of items. You can separate text with '|' to add multiple options"));
			}
			Dictionary<string, string> keyValuePairs4 = JsonHelper.GetKeyValuePairs("terminal-voice-commands");
			foreach (KeyValuePair<string, string> item4 in keyValuePairs4)
			{
				PluginConstants.TerminalVoiceCommands.Add(item4.Key, ((BaseUnityPlugin)this).Config.Bind<string>("Terminal voice commands", item4.Key, item4.Value, "Key phrase what you need to say to make some action via terminal. You can separate text with '|' to add multiple options"));
			}
			Dictionary<string, string> keyValuePairs5 = JsonHelper.GetKeyValuePairs("voice-commands");
			for (int i = 0; i < keyValuePairs5.Count; i++)
			{
				PluginConstants.VoiceCommands.Add("Custom Asset Key phrase: " + i, ((BaseUnityPlugin)this).Config.Bind<string>("Any voice commands", "Custom voice Key phrase: " + (i + 1), keyValuePairs5.Values.ElementAt(i), "Any Key phrase by which one will be played audio asset. You can separate text with '|' to add multiple options"));
			}
			Dictionary<string, string> keyValuePairs6 = JsonHelper.GetKeyValuePairs("voice-assets");
			for (int j = 0; j < keyValuePairs6.Count; j++)
			{
				PluginConstants.VoicePlayAudioAssetNames.Add("Custom Asset Key phrase: " + j, ((BaseUnityPlugin)this).Config.Bind<string>("Audio assets played by voice command", "Custom voice asset for Key phrase: " + (j + 1), keyValuePairs6.Values.ElementAt(j), "Any audio asset what will play by 'Any voice command'. You can separate text with '|' to add multiple options"));
			}
		}
	}
}
namespace VoiceShipControl.Shared
{
	public static class FileHelper
	{
		public static string GetFilePath(string fileName)
		{
			string[] files = Directory.GetFiles(PluginConstants.PathToFolder, fileName, SearchOption.AllDirectories);
			if (files.Length != 0)
			{
				return files[0];
			}
			Console.WriteLine("File '" + fileName + "' not found in '" + PluginConstants.PathToFolder + "' or its subdirectories.");
			return string.Empty;
		}
	}
	public class KeyBindingHelper
	{
		public static int GetMouseButton(KeyCode code)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected I4, but got Unknown
			return (code - 323) switch
			{
				0 => 0, 
				1 => 1, 
				2 => 2, 
				3 => 3, 
				4 => 4, 
				_ => -1, 
			};
		}
	}
}
namespace VoiceShipControl.Helpers
{
	internal class AssetData<T>
	{
		public T Result { get; set; }

		public AssetBundle Bundle { get; set; }

		public AssetData(T result, AssetBundle bundle)
		{
			Result = result;
			Bundle = bundle;
		}
	}
	internal class AssetLoader
	{
		public static AssetData<T> Load<T>(string assetName) where T : Object
		{
			AssetBundle val = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle x) => ((Object)x).name == assetName));
			if ((Object)(object)val == (Object)null)
			{
				val = AssetBundle.LoadFromFile(FileHelper.GetFilePath(assetName));
			}
			T val2;
			if ((Object)(object)val != (Object)null)
			{
				val2 = val.LoadAsset<T>(assetName);
				if ((Object)(object)val2 != (Object)null)
				{
					Debug.Log((object)(assetName + " loaded succesfuly"));
				}
				else
				{
					Debug.Log((object)(assetName + " asset not exist"));
				}
			}
			else
			{
				val2 = default(T);
				Debug.Log((object)("Error while loading " + assetName));
			}
			return new AssetData<T>(val2, val);
		}
	}
	internal class AudioClipHelper
	{
		private static void PlayAudioSourceVoice(string assetName, AudioSource audioSource)
		{
			try
			{
				Console.WriteLine("Start Play audioSource " + assetName);
				AssetData<AudioClip> assetData = AssetLoader.Load<AudioClip>(assetName);
				if ((Object)(object)assetData.Result == (Object)null)
				{
					if ((Object)(object)assetData.Bundle != (Object)null)
					{
						assetData.Bundle.Unload(false);
					}
					return;
				}
				if ((Object)(object)audioSource == (Object)null)
				{
					assetData.Bundle.Unload(false);
					return;
				}
				Console.WriteLine("PlayAudioSourceVoice Play");
				if (audioSource.isPlaying)
				{
					audioSource.Stop();
					audioSource.PlayOneShot(assetData.Result);
				}
				else
				{
					audioSource.PlayOneShot(assetData.Result);
				}
				assetData.Bundle.Unload(false);
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
		}

		public static void PlayValuePairAudioSourceByKey(string assetKey, AudioSource audioSource)
		{
			if ((Object)(object)audioSource == (Object)null)
			{
				Debug.Log((object)"audioSource empty");
				return;
			}
			try
			{
				Debug.Log((object)assetKey);
				KeyValuePair<string, ConfigEntry<string>> keyValuePair = PluginConstants.VoicePlayAudioAssetNames.FirstOrDefault((KeyValuePair<string, ConfigEntry<string>> x) => x.Key == assetKey);
				if (keyValuePair.Value == null || string.IsNullOrEmpty(keyValuePair.Value.Value) || string.IsNullOrEmpty(keyValuePair.Key))
				{
					return;
				}
				Console.WriteLine(keyValuePair.Value.Value + " founded asset");
				if (!string.IsNullOrEmpty(keyValuePair.Value.Value))
				{
					if (keyValuePair.Value.Value.Contains("|"))
					{
						Console.WriteLine(keyValuePair.Value.Value + " Contains |");
						string[] array = keyValuePair.Value.Value.Split('|');
						Random random = new Random();
						int num = random.Next(0, array.Length);
						PlayAudioSourceVoice(array[num], audioSource);
					}
					else
					{
						PlayAudioSourceVoice(keyValuePair.Value.Value, audioSource);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
		}

		public static void PlayAudioSourceByValue(string assetValue, AudioSource audioSource)
		{
			if ((Object)(object)audioSource == (Object)null)
			{
				Debug.Log((object)"audioSource empty");
				return;
			}
			try
			{
				Console.WriteLine(assetValue + " founded asset");
				if (!string.IsNullOrEmpty(assetValue))
				{
					if (assetValue.Contains("|"))
					{
						Console.WriteLine(assetValue + " Contains |");
						string[] array = assetValue.Split('|');
						Random random = new Random();
						int num = random.Next(0, array.Length);
						PlayAudioSourceVoice(array[num], audioSource);
					}
					else
					{
						PlayAudioSourceVoice(assetValue, audioSource);
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogException(ex);
			}
		}
	}
	internal class JsonHelper
	{
		public static string GetValue(string key)
		{
			JObject val = JObject.Parse(File.ReadAllText(FileHelper.GetFilePath("VoiceShipControlSettings.json")));
			return ((JToken)val).Value<string>((object)key);
		}

		public static Dictionary<string, string> GetKeyValuePairs(string key)
		{
			JObject val = JObject.Parse(File.ReadAllText(FileHelper.GetFilePath("VoiceShipControlSettings.json")));
			return ((JToken)JObject.FromObject((object)val[key])).ToObject<Dictionary<string, string>>();
		}

		public static void SetKeyValuePair(string key, string subKey, string value)
		{
			string filePath = FileHelper.GetFilePath("VoiceShipControlSettings.json");
			string text = File.ReadAllText(filePath);
			JObject val = JObject.Parse(text);
			if (string.IsNullOrEmpty(subKey))
			{
				val[key] = JToken.op_Implicit(value);
			}
			else
			{
				val[subKey][(object)key] = JToken.op_Implicit(value);
			}
			string contents = ((object)val).ToString();
			File.WriteAllText(filePath, contents);
		}
	}
	internal class Recognizer : MonoBehaviour
	{
		public static Process recognitionProcess;

		public static Recognizer Instance;

		public static bool IsProcessStarted;

		public static bool IsStarted;

		public static void InitRecognizer(bool visible = false, string name = "Recognizer")
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null) && Application.isPlaying)
			{
				GameObject val = new GameObject();
				if (!visible)
				{
					((Object)val).hideFlags = (HideFlags)61;
				}
				Instance = val.AddComponent<Recognizer>();
				Debug.Log((object)"Recognizer object created");
			}
		}

		public void Update()
		{
			if (!((Object)(object)Instance == (Object)null) && !IsStarted)
			{
				IsStarted = true;
				((MonoBehaviour)Instance).StartCoroutine(Execute());
			}
		}

		public static IEnumerator Execute()
		{
			string languageCode = PluginConstants.LanguageDictionary.GetValueOrDefault(PluginConstants.LanguageCode.Value);
			if (!string.IsNullOrEmpty(languageCode))
			{
				IsProcessStarted = true;
			}
			else
			{
				Debug.LogWarning((object)"Recognizer not started Language incorrect!");
				yield return null;
			}
			yield return (object)new WaitForSeconds(0f);
			try
			{
				Debug.Log((object)("Current lang: " + languageCode));
				recognitionProcess = new Process();
				recognitionProcess.StartInfo.FileName = FileHelper.GetFilePath("recognizer.exe");
				recognitionProcess.StartInfo.Arguments = "\"" + languageCode + "\"";
				recognitionProcess.StartInfo.CreateNoWindow = true;
				recognitionProcess.StartInfo.UseShellExecute = false;
				recognitionProcess.Exited += delegate
				{
					Debug.LogWarning((object)"Process exited");
				};
				recognitionProcess.Start();
				Debug.Log((object)"Recognizer started");
			}
			catch (Exception e2)
			{
				Debug.Log((object)e2);
			}
		}

		public static void PythonError(string error, EventArgs e)
		{
			Debug.LogError((object)error);
		}

		public static void PythonSpeechRecognized(string spokenText, EventArgs e)
		{
			if (StartOfRound.Instance.localPlayerController.isPlayerDead && !PluginConstants.IsUserCanUseCommandsWhenDead.Value)
			{
				return;
			}
			Console.WriteLine("Spocken text: " + spokenText);
			if ((!StartOfRound.Instance.localPlayerController.isInHangarShipRoom && !PluginConstants.IsUserCanUseCommandsOutsideTheShip.Value) || (!DetectAndRunStartEndGameVoiceCommand(spokenText) && !DetectAndRunShipDoorVoiceCommand(spokenText) && !DetectAndRunSwitchVoiceCommand(spokenText) && !DetectAndRunTeleporterVoiceCommand(spokenText) && !DetectAndRunMonitorVoiceCommand(spokenText)))
			{
				DetectAndRunVoiceCommand(spokenText);
				if ((StartOfRound.Instance.localPlayerController.isInHangarShipRoom || PluginConstants.IsUserCanUseCommandsOutsideTheShip.Value) && !DetectAndRunBuyCommand(spokenText) && !DetectAndRunTransmitCommand(spokenText) && !DetectAndRunRerouteCommand(spokenText))
				{
					DetectAndRunTerminalCommand(spokenText);
				}
			}
		}

		public static bool DetectAndRunStartEndGameVoiceCommand(string spokenText)
		{
			if (PluginConstants.StartGame.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				StartOfRound.Instance.StartGameServerRpc();
				return true;
			}
			if (PluginConstants.EndGame.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				StartOfRound.Instance.EndGameServerRpc((int)StartOfRound.Instance.localPlayerController.playerClientId);
				return true;
			}
			return false;
		}

		public static bool DetectAndRunShipDoorVoiceCommand(string spokenText)
		{
			if (PluginConstants.CloseDoor.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				HangarShipDoor val = Object.FindFirstObjectByType<HangarShipDoor>();
				if ((Object)(object)val != (Object)null)
				{
					InteractTrigger component = ((Component)((Component)val).transform.Find("HangarDoorButtonPanel/StopButton/Cube (3)")).GetComponent<InteractTrigger>();
					component.Interact(((Component)GameNetworkManager.Instance.localPlayerController).transform);
				}
				return true;
			}
			if (PluginConstants.OpenDoor.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				HangarShipDoor val2 = Object.FindFirstObjectByType<HangarShipDoor>();
				if ((Object)(object)val2 != (Object)null)
				{
					InteractTrigger component2 = ((Component)((Component)val2).transform.Find("HangarDoorButtonPanel/StartButton/Cube (2)")).GetComponent<InteractTrigger>();
					component2.Interact(((Component)GameNetworkManager.Instance.localPlayerController).transform);
				}
				return true;
			}
			return false;
		}

		public static bool DetectAndRunSwitchVoiceCommand(string spokenText)
		{
			ShipLights val = Object.FindObjectOfType<ShipLights>();
			if (PluginConstants.SwitchOn.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				val.SetShipLightsServerRpc(true);
				return true;
			}
			if (PluginConstants.SwitchOff.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				val.SetShipLightsServerRpc(false);
				return true;
			}
			return false;
		}

		public static bool DetectAndRunMonitorVoiceCommand(string spokenText)
		{
			if (PluginConstants.SwitchMonitor.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				InteractTrigger component = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorSwitchButton/Cube (2)").GetComponent<InteractTrigger>();
				if ((Object)(object)component != (Object)null)
				{
					component.Interact(((Component)GameNetworkManager.Instance.localPlayerController).transform);
				}
				return true;
			}
			if (PluginConstants.ToggleMonitor.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				InteractTrigger component2 = GameObject.Find("Environment/HangarShip/ShipModels2b/MonitorWall/Cube.001/CameraMonitorOnButton/Cube (2)").GetComponent<InteractTrigger>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.Interact(((Component)GameNetworkManager.Instance.localPlayerController).transform);
				}
				return true;
			}
			return false;
		}

		public static bool DetectAndRunTeleporterVoiceCommand(string spokenText)
		{
			ShipTeleporter[] source = Object.FindObjectsOfType<ShipTeleporter>();
			ShipTeleporter val = ((IEnumerable<ShipTeleporter>)source).FirstOrDefault((Func<ShipTeleporter, bool>)((ShipTeleporter x) => !x.isInverseTeleporter));
			ShipTeleporter val2 = ((IEnumerable<ShipTeleporter>)source).FirstOrDefault((Func<ShipTeleporter, bool>)((ShipTeleporter x) => x.isInverseTeleporter));
			if (PluginConstants.Teleporter.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				if (((Behaviour)val).isActiveAndEnabled && (val2.buttonTrigger.interactable || PluginConstants.IsUserCanUseTeleportAlways.Value))
				{
					val.PressTeleportButtonOnLocalClient();
				}
				return true;
			}
			if (PluginConstants.InverseTeleporter.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				if (((Behaviour)val2).isActiveAndEnabled && (val2.buttonTrigger.interactable || PluginConstants.IsUserCanUseTeleportAlways.Value))
				{
					val2.PressTeleportButtonOnLocalClient();
					return true;
				}
				return true;
			}
			return false;
		}

		public static bool DetectAndRunVoiceCommand(string spokenText)
		{
			KeyValuePair<string, ConfigEntry<string>> keyValuePair = PluginConstants.VoiceCommands.FirstOrDefault((KeyValuePair<string, ConfigEntry<string>> x) => x.Value.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())));
			if (keyValuePair.Value != null && !string.IsNullOrEmpty(keyValuePair.Value.Value) && !string.IsNullOrEmpty(keyValuePair.Key))
			{
				AudioSource val = ((Component)StartOfRound.Instance.localPlayerController).gameObject.GetComponent<AudioSource>();
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)StartOfRound.Instance.localPlayerController).gameObject.AddComponent<AudioSource>();
				}
				AudioClipHelper.PlayValuePairAudioSourceByKey(keyValuePair.Key, val);
				return true;
			}
			return false;
		}

		public static bool DetectAndRunBuyCommand(string spokenText)
		{
			if (PluginConstants.BuyKeyPhrase.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				KeyValuePair<string, ConfigEntry<string>> keyValuePair = PluginConstants.BuyVoiceCommands.FirstOrDefault((KeyValuePair<string, ConfigEntry<string>> x) => x.Value.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())));
				if (keyValuePair.Value != null && !string.IsNullOrEmpty(keyValuePair.Value.Value) && !string.IsNullOrEmpty(keyValuePair.Key))
				{
					string text = string.Empty;
					KeyValuePair<string, ConfigEntry<string>> keyValuePair2 = PluginConstants.BuyVoiceCountCommands.FirstOrDefault((KeyValuePair<string, ConfigEntry<string>> x) => x.Value.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())));
					if (keyValuePair2.Value != null && !string.IsNullOrEmpty(keyValuePair2.Value.Value) && !string.IsNullOrEmpty(keyValuePair2.Key))
					{
						text = keyValuePair2.Key;
						Console.WriteLine(text + " buy count command");
					}
					ShipCommands.BuyCommand(keyValuePair.Key + " " + text);
					return true;
				}
			}
			return false;
		}

		public static bool DetectAndRunTerminalCommand(string spokenText)
		{
			KeyValuePair<string, ConfigEntry<string>> keyValuePair = PluginConstants.TerminalVoiceCommands.FirstOrDefault((KeyValuePair<string, ConfigEntry<string>> x) => x.Value.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())));
			if (keyValuePair.Value != null && !string.IsNullOrEmpty(keyValuePair.Value.Value) && !string.IsNullOrEmpty(keyValuePair.Key))
			{
				ShipCommands.TerminalCommand(keyValuePair.Key);
				return true;
			}
			return false;
		}

		public static bool DetectAndRunTransmitCommand(string spokenText)
		{
			string value = PluginConstants.TransmitKeyPhrase.Value.Split('|').FirstOrDefault((string y) => spokenText.ToLower().Contains(y.ToLower()));
			if (!string.IsNullOrEmpty(value))
			{
				int startIndex = spokenText.LastIndexOf(value);
				string text = spokenText.Substring(startIndex);
				if (char.IsWhiteSpace(text, 0))
				{
					text.Remove(0);
				}
				else
				{
					int startIndex2 = text.IndexOf(" ");
					text = spokenText.Substring(startIndex2);
				}
				ShipCommands.TerminalCommand("transmit " + text);
				return true;
			}
			return false;
		}

		public static bool DetectAndRunRerouteCommand(string spokenText)
		{
			if (PluginConstants.RerouteKeyPhrase.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())))
			{
				KeyValuePair<string, ConfigEntry<string>> keyValuePair = PluginConstants.ReroutePlanetComands.FirstOrDefault((KeyValuePair<string, ConfigEntry<string>> x) => x.Value.Value.Split('|').Any((string y) => spokenText.ToLower().Contains(y.ToLower())));
				if (keyValuePair.Value != null && !string.IsNullOrEmpty(keyValuePair.Value.Value) && !string.IsNullOrEmpty(keyValuePair.Key))
				{
					ShipCommands.RerouteCommand(keyValuePair.Key);
					return true;
				}
			}
			return false;
		}

		public static void StopRecognizer()
		{
			Debug.Log((object)"Stop recognizer");
			IsProcessStarted = (IsStarted = false);
			recognitionProcess.Kill();
		}

		private void OnDestroy()
		{
			Debug.Log((object)"Destriy recognizer");
			StopRecognizer();
		}

		private void OnApplicationQuit()
		{
			StopRecognizer();
			Object.Destroy((Object)(object)this);
		}
	}
	internal class ShipCommands
	{
		public static void RerouteCommand(string inputText)
		{
			try
			{
				Debug.Log((object)("isInHangarShipRoom: " + StartOfRound.Instance.localPlayerController.isInHangarShipRoom + " for player:" + ((Object)StartOfRound.Instance.localPlayerController).name));
				Terminal val = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)HUDManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)val == (Object)null)
				{
					Console.WriteLine("terminal is null");
					return;
				}
				val.BeginUsingTerminal();
				val.screenText.text = string.Empty;
				val.currentText = string.Empty;
				val.textAdded = 0;
				val.TextChanged(inputText);
				val.screenText.text = inputText;
				val.OnSubmit();
				if (((Object)val.currentNode).name == "CannotAfford")
				{
					val.QuitTerminal();
					AudioClipHelper.PlayAudioSourceByValue(PluginConstants.BuyDeclinedAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
					return;
				}
				val.TextChanged(string.Empty);
				val.screenText.text = string.Empty;
				val.currentText = string.Empty;
				val.textAdded = 0;
				val.TextChanged("confirm");
				val.screenText.text = "confirm";
				val.OnSubmit();
				Debug.Log((object)((Object)val.currentNode).name);
				if (((Object)val.currentNode).name == "CannotAfford")
				{
					val.QuitTerminal();
					AudioClipHelper.PlayAudioSourceByValue(PluginConstants.BuyDeclinedAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
				}
				else
				{
					AudioClipHelper.PlayAudioSourceByValue(PluginConstants.BuySuccessAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
					val.QuitTerminal();
				}
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex);
			}
		}

		public static void TerminalCommand(string inputText)
		{
			try
			{
				Debug.Log((object)("isInHangarShipRoom: " + StartOfRound.Instance.localPlayerController.isInHangarShipRoom + " for player:" + ((Object)StartOfRound.Instance.localPlayerController).name));
				Terminal val = Object.FindObjectOfType<Terminal>();
				if ((Object)(object)HUDManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)val == (Object)null)
				{
					Console.WriteLine("terminal is null");
				}
				else if (StartOfRound.Instance.localPlayerController.inTerminalMenu)
				{
					val.screenText.text = string.Empty;
					val.currentText = string.Empty;
					val.textAdded = 0;
					val.TextChanged(inputText);
					val.screenText.text = inputText;
					val.OnSubmit();
				}
				else
				{
					val.BeginUsingTerminal();
					val.screenText.text = string.Empty;
					val.currentText = string.Empty;
					val.textAdded = 0;
					val.TextChanged(inputText);
					val.screenText.text = inputText;
					val.OnSubmit();
					val.QuitTerminal();
				}
			}
			catch (Exception ex)
			{
				Debug.Log((object)ex);
			}
		}

		public static void BuyCommand(string inputText)
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)HUDManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance == (Object)null || (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null || (Object)(object)val == (Object)null)
			{
				Console.WriteLine("terminal is null");
				return;
			}
			try
			{
				val.terminalInUse = true;
				GameNetworkManager.Instance.localPlayerController.inTerminalMenu = true;
				val.LoadNewNode(val.terminalNodes.specialNodes[13]);
				val.TextChanged(string.Empty);
				val.SetTerminalInUseLocalClient(true);
				val.screenText.text = string.Empty;
				val.currentText = string.Empty;
				val.textAdded = 0;
				val.TextChanged(inputText);
				val.screenText.text = inputText;
				val.OnSubmit();
				if (((Object)val.currentNode).name == "CannotAfford")
				{
					val.QuitTerminal();
					AudioClipHelper.PlayAudioSourceByValue(PluginConstants.BuyDeclinedAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
					return;
				}
				val.TextChanged(string.Empty);
				val.screenText.text = string.Empty;
				val.currentText = string.Empty;
				val.textAdded = 0;
				val.TextChanged("confirm");
				val.screenText.text = "confirm";
				val.OnSubmit();
				if (((Object)val.currentNode).name != "ParserError1")
				{
					AudioClipHelper.PlayAudioSourceByValue(PluginConstants.BuySuccessAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
				}
				val.QuitTerminal();
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.Message + " " + ex.StackTrace);
			}
		}

		public static void ShowAllTerminalData()
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			for (int i = 0; i < val.terminalNodes.allKeywords.Length; i++)
			{
				try
				{
					Console.WriteLine($"allKeywords {i}: " + ((Object)val.terminalNodes.allKeywords[i]).name);
					Console.WriteLine($"allKeywords {i}: " + val.terminalNodes.allKeywords[i].word);
					Console.WriteLine($"allKeywords {i}: " + (object)val.terminalNodes.allKeywords[i].defaultVerb);
					Console.WriteLine($"allKeywords {i}: " + string.Join(",", val.terminalNodes.allKeywords[i].compatibleNouns.Select((CompatibleNoun x) => ((Object)x.result).name)));
				}
				catch (Exception)
				{
					Console.WriteLine("option result not found");
				}
			}
			for (int j = 0; j < val.terminalNodes.specialNodes.Count; j++)
			{
				Console.WriteLine($"specialNodes {j}: " + ((Object)val.terminalNodes.specialNodes[j]).name);
				for (int num = 0; num < val.terminalNodes.specialNodes[j].terminalOptions.Length; j++)
				{
					try
					{
						Console.WriteLine($"terminalOptions {j}: " + ((Object)val.terminalNodes.specialNodes[j].terminalOptions[num].result).name);
					}
					catch (Exception)
					{
						Console.WriteLine("option result not found");
					}
				}
			}
			for (int k = 0; k < val.currentNode.terminalOptions.Length; k++)
			{
				Console.WriteLine($"terminalOptions {k}: " + ((Object)val.currentNode.terminalOptions[k].result).name);
			}
			for (int l = 0; l < val.currentNode.terminalOptions.Length; l++)
			{
				Console.WriteLine($"terminalOptions.noun {l}: " + ((Object)val.currentNode.terminalOptions[l].noun).name);
				Console.WriteLine($"terminalOptions.noun {l}: " + val.currentNode.terminalOptions[l].noun.word);
			}
		}
	}
}
namespace VoiceShipControl.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartOfRoundPatch : NetworkBehaviour
	{
		public static StartOfRound Instance;

		public static bool IsRecognitionEnabled;

		[HarmonyPatch("LateUpdate")]
		[HarmonyPostfix]
		private static void AddSoundRecognition(StartOfRound __instance)
		{
			Instance = __instance;
			if (!((Object)(object)Instance == (Object)null) && ((Component)__instance).gameObject.activeSelf && !IsRecognitionEnabled)
			{
				IsRecognitionEnabled = true;
				EnambleRecognition();
				AssetData<AudioClip> assetData = AssetLoader.Load<AudioClip>(PluginConstants.ShipIntroAudioAssetName.Value);
				if ((Object)(object)assetData.Bundle != (Object)null && (Object)(object)assetData.Result != (Object)null)
				{
					__instance.shipIntroSpeechSFX = assetData.Result;
				}
			}
		}

		private static void EnambleRecognition()
		{
			if ((Object)(object)SocketListener.Instance == (Object)null)
			{
				Debug.Log((object)"SocketListener not founded initializing");
				SocketListener.InitSocketListener();
				SocketListener.OnErrorReceivedEvent += Recognizer.PythonError;
				SocketListener.OnMessageReceivedEvent += Recognizer.PythonSpeechRecognized;
			}
			else
			{
				SocketListener.StartServer();
			}
			if ((Object)(object)Recognizer.Instance == (Object)null)
			{
				Debug.Log((object)"Recognizer not founded initializing");
				Recognizer.InitRecognizer();
			}
			else
			{
				Recognizer.IsStarted = (Recognizer.IsProcessStarted = false);
			}
		}

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void PlayStartGameAudio()
		{
			Terminal val = Object.FindObjectOfType<Terminal>();
			AudioClipHelper.PlayAudioSourceByValue(PluginConstants.StartOfRoundAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
		}

		[HarmonyPatch("EndGameServerRpc")]
		[HarmonyPostfix]
		private static void PlayEndGameAudio()
		{
			AudioClipHelper.PlayAudioSourceByValue(PluginConstants.EndOfRoundAudioAssetName.Value, StartOfRound.Instance.speakerAudioSource);
		}

		[HarmonyPatch("OnDestroy")]
		[HarmonyPrefix]
		private static void OnDestroy()
		{
			Object.Destroy((Object)(object)Recognizer.Instance);
			Object.Destroy((Object)(object)SocketListener.Instance);
			IsRecognitionEnabled = false;
			Debug.Log((object)"recognizer stopped");
		}
	}
}