Decompiled source of darmuhsTerminalStuff v3.9.0

darmuhsTerminalStuff.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CruiserTerminal.Patches;
using FovAdjust;
using GameNetcodeStuff;
using GeneralImprovements;
using HarmonyLib;
using InteractiveTerminalAPI.UI;
using InteractiveTerminalAPI.UI.Application;
using LethalConstellations.PluginCore;
using LethalLevelLoader;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using Microsoft.CodeAnalysis;
using OpenBodyCams;
using OpenLib;
using OpenLib.Common;
using OpenLib.Compat;
using OpenLib.ConfigManager;
using OpenLib.CoreMethods;
using OpenLib.Events;
using OpenLib.InteractiveMenus;
using OpenLib.Menus;
using ShipInventory.Compatibility;
using ShipInventory.Items;
using TMPro;
using TerminalStuff.CommandHandling;
using TerminalStuff.Compatibility;
using TerminalStuff.Configs;
using TerminalStuff.EventSub;
using TerminalStuff.MoonsTweaks;
using TerminalStuff.Networking;
using TerminalStuff.Patching;
using TerminalStuff.SpecialStuff;
using TerminalStuff.StoreTweaks;
using TerminalStuff.Util;
using TerminalStuff.VisualElements;
using TwoRadarMaps;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.TextCore.LowLevel;
using UnityEngine.UI;
using UnityEngine.Video;
using WeatherTweaks;
using darmuhsTerminalStuff.NetcodePatcher;
using suitsTerminal;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("InteractiveTerminalAPI")]
[assembly: IgnoresAccessChecksTo("LethalLevelLoader")]
[assembly: IgnoresAccessChecksTo("WeatherTweaks")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("darmuh")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("3.9.0")]
[assembly: AssemblyInformationalVersion("3.9.0+5beabd7732a68b379805be4da075416d04e1e9cb")]
[assembly: AssemblyProduct("darmuhsTerminalStuff")]
[assembly: AssemblyTitle("darmuhsTerminalStuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.9.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace TutorialNameSpace
{
	internal class Tutorial
	{
		internal static void AddMyCommands()
		{
			AddingThings.AddBasicCommand("command1", "command1", "command 1 text", false, true, "", "");
		}

		internal static void OnTerminalAwake(Terminal instance)
		{
			AddMyCommands();
		}

		internal static void Subscribers()
		{
			EventManager.TerminalAwake.AddListener((ParameterEvent<Terminal>)OnTerminalAwake);
		}
	}
}
namespace TerminalStuff
{
	internal class AdminCommands
	{
		[CompilerGenerated]
		private sealed class <KickYes>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int playerNum;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <KickYes>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (kickEnum)
					{
						return false;
					}
					kickEnum = true;
					Loggers.LogDebug("We made it to the kick event!!");
					Loggers.LogDebug("playerObjIdForTerminal = " + playerNum);
					Plugin.instance.Terminal.QuitTerminal(true);
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					StartOfRound.Instance.KickPlayer(playerNum);
					Loggers.LogDebug("kicked");
					kickEnum = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static PlayerControllerB playerToKick;

		internal static bool kickEnum;

		internal static string KickPlayersAsk()
		{
			TerminalGeneral.CancelConfirmation = true;
			playerToKick = null;
			string afterKeyword = StringStuff.GetAfterKeyword(StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.KickKeywords.Value));
			if (!AmIHost(out string displayText))
			{
				return displayText;
			}
			if (afterKeyword.Length < 1)
			{
				string text = PlayerNameAndIDList();
				return "You must specify a player name or ID to kick them!\n\tKickable Players:\n(id) PlayerName" + text + "\n\n";
			}
			if (ulong.TryParse(afterKeyword, out var result))
			{
				PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val in allPlayerScripts)
				{
					if (val.playerClientId == result && (Object)(object)StartOfRound.Instance.localPlayerController != (Object)(object)val && val.isPlayerControlled)
					{
						TerminalGeneral.CancelConfirmation = false;
						playerToKick = val;
						displayText = "Kick " + val.playerUsername + " from the lobby?\n\n\n\n\n\n\n\n\n\n\nPlease CONFIRM or DENY.\n\n";
						Loggers.LogInfo("valid player to kick from id");
						return displayText;
					}
				}
			}
			else
			{
				Loggers.LogDebug("ulong failed parse");
				string text2 = afterKeyword.ToLower();
				PlayerControllerB[] allPlayerScripts2 = StartOfRound.Instance.allPlayerScripts;
				foreach (PlayerControllerB val2 in allPlayerScripts2)
				{
					if (Misc.CompareStringsInvariant(val2.playerUsername, text2, true))
					{
						TerminalGeneral.CancelConfirmation = false;
						playerToKick = val2;
						return "Kick " + val2.playerUsername + " from the lobby?\n\n\n\n\n\n\n\n\n\n\nPlease CONFIRM or DENY.\n\n";
					}
				}
			}
			return "Unable to find player to kick by name or id - " + afterKeyword + "\n\n";
		}

		private static string PlayerNameAndIDList()
		{
			StringBuilder stringBuilder = new StringBuilder();
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if ((Object)(object)StartOfRound.Instance.localPlayerController != (Object)(object)val && val.isPlayerControlled)
				{
					stringBuilder.Append($"\n({val.playerClientId}) {val.playerUsername}\n");
				}
			}
			return stringBuilder.ToString();
		}

		internal static bool AmIHost(out string displayText)
		{
			displayText = "";
			if (((NetworkBehaviour)GameNetworkManager.Instance.localPlayerController).IsHost)
			{
				return true;
			}
			displayText = "You do not have permission to kick players from this lobby, you are NOT the host.\n\n";
			Plugin.Log.LogWarning((object)"Somehow non-host player could try to kick others, error handled.");
			return false;
		}

		internal static string KickPlayerConfirm()
		{
			int playerToKickID = GetPlayerToKickID(playerToKick);
			((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(KickYes(playerToKickID));
			return "Kick Player Action Confirmed.\n\n\tKicking player: " + playerToKick.playerUsername + "\n\n";
		}

		internal static string KickPlayerDeny()
		{
			string result = "Cancelling kick player action for player:" + playerToKick.playerUsername + "\n\n";
			playerToKick = null;
			return result;
		}

		internal static int GetPlayerToKickID(PlayerControllerB matchingPlayer)
		{
			int result = -1;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				if (StartOfRound.Instance.allPlayerScripts[i].playerUsername == matchingPlayer.playerUsername)
				{
					result = i;
					break;
				}
			}
			return result;
		}

		[IteratorStateMachine(typeof(<KickYes>d__8))]
		internal static IEnumerator KickYes(int playerNum)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <KickYes>d__8(0)
			{
				playerNum = playerNum
			};
		}
	}
	internal class AllTheLootStuff
	{
		internal static string GetLootSimple()
		{
			Loggers.LogDebug("calculating loot value next");
			float num = CalculateLootValue();
			string text;
			if (Plugin.instance.ShipInventory)
			{
				int inventoryValue = ShipInventoryCompat.GetInventoryValue();
				text = $"Total Value on Ship: ${num}\n\nTotal Value in Ship Inventory: ${inventoryValue}";
			}
			else
			{
				text = $"Total Value on Ship: ${num}";
			}
			Loggers.LogDebug("loot calculated");
			return text + "\n\n";
		}

		internal static string DetailedLootCommand()
		{
			OtherPatches.LoadGrabbablesOnShip.LoadAllItems();
			StringBuilder stringBuilder = new StringBuilder();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			int totalCredsWorth = 0;
			foreach (GrabbableObject item in OtherPatches.LoadGrabbablesOnShip.ItemsOnShip)
			{
				string itemName = item.itemProperties.itemName;
				int scrapValue = item.scrapValue;
				if (item.itemProperties.isScrap)
				{
					string text = $"{itemName} ({scrapValue} credits)";
					Loggers.LogDebug(text + "added to output");
					totalCredsWorth += scrapValue;
					dictionary[text] = ((!dictionary.TryGetValue(text, out var value)) ? 1 : (value + 1));
				}
			}
			foreach (KeyValuePair<string, int> item2 in dictionary)
			{
				if (item2.Value > 1)
				{
					stringBuilder.AppendLine($"{item2.Key} [x{item2.Value}]");
				}
				else
				{
					stringBuilder.AppendLine(item2.Key ?? "");
				}
			}
			if (Plugin.instance.ShipInventory)
			{
				ShipInventoryCompat.GetInventoryItems(out List<Item> itemsInventory);
				StringBuilder arg = ShipInventoryItems(itemsInventory, ref totalCredsWorth);
				return $"Scrap on ship (not stored):\n\n{stringBuilder}Scrap stored in Ship Inventory:\n\n{arg}\n\n\tTotal Value: {totalCredsWorth}\n\n";
			}
			return $"Scrap on ship:\n\n{stringBuilder}\n\n\tTotal Value: {totalCredsWorth}\n\n";
		}

		private static StringBuilder ShipInventoryItems(List<Item> inventory, ref int totalCredsWorth)
		{
			StringBuilder stringBuilder = new StringBuilder();
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			foreach (Item item in inventory)
			{
				if (item.isScrap)
				{
					string itemName = item.itemName;
					int creditsWorth = item.creditsWorth;
					string text = $"{itemName} ({creditsWorth} credits)";
					Loggers.LogDebug(text + "added to output");
					totalCredsWorth += creditsWorth;
					dictionary[text] = ((!dictionary.TryGetValue(text, out var value)) ? 1 : (value + 1));
				}
			}
			foreach (KeyValuePair<string, int> item2 in dictionary)
			{
				if (item2.Value > 1)
				{
					stringBuilder.AppendLine($"{item2.Key} [x{item2.Value}]");
				}
				else
				{
					stringBuilder.AppendLine(item2.Key ?? "");
				}
			}
			return stringBuilder;
		}

		private static float CalculateLootValue()
		{
			List<GrabbableObject> list = (from obj in GameObject.Find("/Environment/HangarShip").GetComponentsInChildren<GrabbableObject>()
				where ((Object)obj).name != "ClipboardManual" && ((Object)obj).name != "StickyNoteItem" && ((Object)obj).name != "Key(Clone)"
				select obj).ToList();
			Plugin.Log.LogDebug((object)"Calculating total ship scrap value.");
			CollectionExtensions.Do<GrabbableObject>((IEnumerable<GrabbableObject>)list, (Action<GrabbableObject>)delegate(GrabbableObject scrap)
			{
				Plugin.Log.LogDebug((object)$"{((Object)scrap).name} - ${scrap.scrapValue}");
			});
			return list.Sum((GrabbableObject scrap) => scrap.scrapValue);
		}
	}
	internal class ColorCommands
	{
		internal static Color? CustomFlashColor;

		internal static string flashLightColor = string.Empty;

		internal static bool usingHexCode = false;

		internal static bool RainbowFlash = false;

		private static GameObject _frontlight1 = null;

		private static GameObject _frontlight2 = null;

		private static GameObject _midlight1 = null;

		private static GameObject _midlight2 = null;

		private static GameObject _backlight1 = null;

		private static GameObject _backlight2 = null;

		internal static GameObject FrontLight1
		{
			get
			{
				if ((Object)(object)_frontlight1 == (Object)null)
				{
					_frontlight1 = GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (3)");
				}
				return _frontlight1;
			}
		}

		internal static GameObject FrontLight2
		{
			get
			{
				if ((Object)(object)_frontlight2 == (Object)null)
				{
					_frontlight2 = GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (9)");
				}
				return _frontlight2;
			}
		}

		internal static GameObject MidLight1
		{
			get
			{
				if ((Object)(object)_midlight1 == (Object)null)
				{
					_midlight1 = GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (4)");
				}
				return _midlight1;
			}
		}

		internal static GameObject MidLight2
		{
			get
			{
				if ((Object)(object)_midlight2 == (Object)null)
				{
					_midlight2 = GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (8)");
				}
				return _midlight2;
			}
		}

		internal static GameObject BackLight1
		{
			get
			{
				if ((Object)(object)_backlight1 == (Object)null)
				{
					_backlight1 = GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (5)");
				}
				return _backlight1;
			}
		}

		internal static GameObject BackLight2
		{
			get
			{
				if ((Object)(object)_backlight2 == (Object)null)
				{
					_backlight2 = GameObject.Find("Environment/HangarShip/ShipElectricLights/Area Light (7)");
				}
				return _backlight2;
			}
		}

		internal static void SetLightColors(List<GameObject> objects, Color newColor)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (objects.Count == 0)
			{
				return;
			}
			foreach (GameObject @object in objects)
			{
				if ((Object)(object)@object.GetComponent<Light>() != (Object)null)
				{
					@object.GetComponent<Light>().color = newColor;
				}
			}
		}

		internal static void FlashLightCommandAction(out string displayText)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			RainbowFlash = false;
			Color val = (Color)(((??)CustomFlashColor) ?? Color.white);
			Loggers.LogInfo($"got {flashLightColor} - {val}");
			displayText = "The next time you turn on your flashlight, the color will be set to " + flashLightColor + "!\n\n";
		}

		internal static void SetCustomColor(string colorKeyword, out Color? customColor)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			if (IsHexColorCode(colorKeyword))
			{
				usingHexCode = true;
				customColor = HexToColor("#" + colorKeyword);
				return;
			}
			customColor = colorKeyword.ToLower() switch
			{
				"white" => Color.white, 
				"normal" => Color.white, 
				"default" => Color.white, 
				"red" => Color.red, 
				"blue" => Color.blue, 
				"yellow" => Color.yellow, 
				"cyan" => Color.cyan, 
				"magenta" => Color.magenta, 
				"green" => Color.green, 
				"purple" => Color32.op_Implicit(new Color32((byte)144, (byte)100, (byte)254, (byte)1)), 
				"lime" => Color32.op_Implicit(new Color32((byte)166, (byte)254, (byte)0, (byte)1)), 
				"pink" => Color32.op_Implicit(new Color32((byte)242, (byte)0, (byte)254, (byte)1)), 
				"maroon" => Color32.op_Implicit(new Color32((byte)114, (byte)3, (byte)3, (byte)1)), 
				"orange" => Color32.op_Implicit(new Color32(byte.MaxValue, (byte)117, (byte)24, (byte)1)), 
				"sasstro" => Color32.op_Implicit(new Color32((byte)212, (byte)148, (byte)180, (byte)1)), 
				"samstro" => Color32.op_Implicit(new Color32((byte)180, (byte)203, (byte)240, (byte)1)), 
				_ => null, 
			};
		}

		internal static bool IsHexColorCode(string input)
		{
			return Regex.IsMatch(input, "^(?:[0-9a-fA-F]{3}){1,2}$");
		}

		internal static Color HexToColor(string hex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return Misc.HexToColor(hex);
		}

		internal static string ShipColorBase()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			string afterKeyword = StringStuff.GetAfterKeyword(StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.ScolorKeywords.Value));
			if (afterKeyword.Length < 1)
			{
				string result = ShipColorList();
				Loggers.WARNING("not enough words for the command!");
				return result;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "list", true))
			{
				string result2 = ShipColorList();
				Loggers.LogInfo("list requested");
				return result2;
			}
			string[] words = afterKeyword.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (!ShipColorCommon(words, out string displayText, out string targetColor, out Color newColor))
			{
				return displayText;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "all", true))
			{
				NetHandler.Instance.ShipColorAllRpc(newColor, targetColor);
				return displayText;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "front", true))
			{
				NetHandler.Instance.ShipColorFrontRpc(newColor, targetColor);
				return displayText;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "mid", true))
			{
				NetHandler.Instance.ShipColorMidRpc(newColor, targetColor);
				return displayText;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "back", true))
			{
				NetHandler.Instance.ShipColorBackRpc(newColor, targetColor);
				return displayText;
			}
			Loggers.WARNING("failed to grab specific part of ship lights to change");
			return ShipColorList();
		}

		internal static bool ShipColorCommon(string[] words, out string displayText, out string targetColor, out Color newColor)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (words.Length < 2)
			{
				displayText = ShipColorList();
				Loggers.LogInfo("not enough words for the command, returning list!");
				targetColor = string.Empty;
				newColor = Color.white;
				return false;
			}
			targetColor = words[1];
			Loggers.LogInfo("Attempting to set " + words[0] + " ship light colors to " + targetColor);
			SetCustomColor(targetColor, out var customColor);
			if (customColor.HasValue && targetColor != null)
			{
				newColor = customColor.Value;
				displayText = "Color of " + words[0] + " ship lights set to " + targetColor + "!\n\n";
				return true;
			}
			targetColor = "";
			newColor = Color.white;
			displayText = "Unable to set " + words[0] + " ship light color...\n\tInvalid color [" + targetColor + "] detected!\n\n";
			Loggers.WARNING("invalid color for the color command!");
			return false;
		}

		internal static string ShipColorList()
		{
			string text = StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.ScolorKeywords.Value)[0];
			return "========= Ship Lights Color Options List =========\nColor Name: \"command used\"\n\nDefault: \"" + text + " all normal\" or \"" + text + " all default\"\nRed: \"" + text + " back red\"\nGreen: \"" + text + " mid green\"\nBlue: \"" + text + " front blue\"\nYellow: \"" + text + " middle yellow\"\nCyan: \"" + text + " all cyan\"\nMagenta: \"" + text + " back magenta\"\nPurple: \"" + text + " mid purple\"\nLime: \"" + text + " all lime\"\nPink: \"" + text + " front pink\"\nMaroon: \"" + text + " middle maroon\"\nOrange: \"" + text + " back orange\"\nSasstro's Color: \"" + text + " all sasstro\"\nSamstro's Color: \"" + text + " all samstro\"\nANY HEXCODE: \"" + text + " all FF00FF\"\n\n\n";
		}

		internal static string FlashColorBase()
		{
			string afterKeyword = StringStuff.GetAfterKeyword(StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.FcolorKeywords.Value));
			if (afterKeyword.Length < 1)
			{
				string result = FlashColorList();
				Loggers.WARNING("getting list, not enough words for color command!");
				return result;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "list", true))
			{
				string result = FlashColorList();
				Loggers.LogInfo("displaying flashcolor list");
				return result;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "rainbow", true))
			{
				string result = FlashColorRainbow();
				Loggers.LogInfo("running rainbow command");
				return result;
			}
			if (Misc.StringContainsInvariant(afterKeyword, "normal", true) || Misc.StringContainsInvariant(afterKeyword, "default", true))
			{
				Loggers.LogInfo("Player no longer wants a custom flashlight color!");
				CustomFlashColor = null;
				RainbowFlash = false;
				return "Flashlight color preference set back to default!\n\nFlashlight's with the default color will no longer be updated!\n\n";
			}
			string text = afterKeyword.TrimStart();
			Loggers.LogInfo("Attempting to set flashlight color to " + text);
			SetCustomColor(text, out CustomFlashColor);
			flashLightColor = text;
			if (CustomFlashColor.HasValue)
			{
				Loggers.LogInfo("Using flashlight color: " + text);
				NetHandler.Instance.EndFlashRainbow = true;
				FlashLightCommandAction(out string displayText);
				return displayText;
			}
			string result2 = "Unable to set flashlight color...\n\tInvalid color: [" + text + "] detected!\n\n";
			Loggers.WARNING("invalid color for the color command!");
			return result2;
		}

		internal static string FlashColorList()
		{
			string text = StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.FcolorKeywords.Value)[0];
			return "========= Flashlight Color Options List =========\nColor Name: \"command used\"\n\nDefault: \"" + text + " normal\" or \"" + text + " default\"\nRed: \"" + text + " red\"\nGreen: \"" + text + " green\"\nBlue: \"" + text + " blue\"\nYellow: \"" + text + " yellow\"\nCyan: \"" + text + " cyan\"\nMagenta: \"" + text + " magenta\"\nPurple: \"" + text + " purple\"\nLime: \"" + text + " lime\"\nPink: \"" + text + " pink\"\nMaroon: \"" + text + " maroon\"\nOrange: \"" + text + " orange\"\nSasstro's Color: \"" + text + " sasstro\"\nSamstro's Color: \"" + text + " samstro\"\n\nRainbow Color (animated): \"" + text + " rainbow\"\nANY HEXCODE: \"" + text + " FF00FF\"\n\n";
		}

		internal static string FlashColorRainbow()
		{
			if (DoIhaveFlash(StartOfRound.Instance.localPlayerController))
			{
				NetHandler.Instance.CycleThroughRainbowFlash();
				return "Flashlight color set to Rainbow Mode! (performance may vary)\n\n";
			}
			RainbowFlash = true;
			return "The next flashlight you hold will be set to rainbow mode! (performance may vary)\n\n";
		}

		private static bool DoIhaveFlash(PlayerControllerB player)
		{
			GrabbableObject[] itemSlots = player.ItemSlots;
			foreach (GrabbableObject val in itemSlots)
			{
				if (val is FlashlightItem)
				{
					return true;
				}
			}
			return false;
		}
	}
	internal class CostCommands
	{
		internal static bool vitalsUpgradeEnabled = false;

		internal static bool enemyScanUpgradeEnabled = false;

		internal static List<int> storeCart = new List<int>();

		internal static Dictionary<Item, int> itemsIndexed = new Dictionary<Item, int>();

		internal static bool CheckUnlockableStatus(string itemName)
		{
			foreach (UnlockableItem unlockable in StartOfRound.Instance.unlockablesList.unlockables)
			{
				if (unlockable.unlockableName == itemName && (unlockable.alreadyUnlocked || unlockable.hasBeenUnlockedByPlayer))
				{
					Loggers.LogDebug("Upgrade: " + itemName + " already unlocked. Setting variable to true");
					return true;
				}
			}
			Loggers.LogDebug("Upgrade: " + itemName + " is NOT unlocked already");
			return false;
		}

		internal static bool CheckUnlockableStatus(int itemID)
		{
			if (itemID >= StartOfRound.Instance.unlockablesList.unlockables.Count)
			{
				return false;
			}
			UnlockableItem val = StartOfRound.Instance.unlockablesList.unlockables[itemID];
			if (!val.alreadyUnlocked && !val.hasBeenUnlockedByPlayer)
			{
				Loggers.LogDebug($"Upgrade ID: {itemID} has not been unlocked. Setting variable to true");
				return true;
			}
			return false;
		}

		internal static void UpdateUnlockStatus()
		{
			enemyScanUpgradeEnabled = false;
			vitalsUpgradeEnabled = false;
			foreach (string item in SaveManager.AllUpgradesUnlocked)
			{
				Loggers.LogDebug("Updating upgrade status for " + item);
				if (item == "BioscanPatch")
				{
					enemyScanUpgradeEnabled = true;
				}
				else if (item == "VitalsPatch")
				{
					vitalsUpgradeEnabled = true;
				}
				else
				{
					Loggers.WARNING("Unexpected upgrade unlock name [ " + item + " ]");
				}
			}
		}

		internal static string BioscanCommand()
		{
			if ((Object)(object)RoundManager.Instance != (Object)null)
			{
				int count = RoundManager.Instance.SpawnedEnemies.Count;
				int groupCredits = Plugin.instance.Terminal.groupCredits;
				int value = Commands.BioScanCost.Value;
				string result;
				if (ShouldRunBioscan2(groupCredits, value))
				{
					int newCreds = CalculateNewCredits(groupCredits, value, Plugin.instance.Terminal);
					List<EnemyAI> livingEnemiesList = GetLivingEnemiesList();
					string text = FilterLivingEnemies(livingEnemiesList);
					string bioscanResult = GetBioscanResult(count, value, newCreds, text);
					result = bioscanResult;
					Loggers.LogInfo("Living Enemies(filtered): " + text);
					return result;
				}
				if (groupCredits >= value)
				{
					int newCreds2 = CalculateNewCredits(groupCredits, value, Plugin.instance.Terminal);
					string basicBioscanResult = GetBasicBioscanResult(count, value, newCreds2);
					result = basicBioscanResult;
					Loggers.LogInfo("v1 scanner utilized, only numbers shown");
					return result;
				}
				result = "Not enough credits to run Biomatter Scanner.\n";
				Loggers.LogInfo("brokeboy detected");
				return result;
			}
			return "Cannot scan for Biomatter at this time.\n";
		}

		private static bool ShouldRunBioscan2(int getCreds, int costCreds)
		{
			if (enemyScanUpgradeEnabled)
			{
				return getCreds >= costCreds;
			}
			return false;
		}

		private static string GetBasicBioscanResult(int scannedEnemies, int costCreds, int newCreds)
		{
			return $"Biomatter scanner charged {costCreds} credits and has detected [{scannedEnemies}] non-employee organic objects.\n\nYour new balance is ■{newCreds} Credits.\n";
		}

		private static List<EnemyAI> GetLivingEnemiesList()
		{
			return RoundManager.Instance.SpawnedEnemies.Where((EnemyAI enemy) => !enemy.isEnemyDead).ToList();
		}

		private static string FilterLivingEnemies(List<EnemyAI> livingEnemies)
		{
			string input = string.Join(Environment.NewLine, livingEnemies.Select((EnemyAI enemy) => ((object)enemy).ToString()));
			string pattern = "\\([^)]*\\)";
			return Regex.Replace(input, pattern, string.Empty);
		}

		private static string GetBioscanResult(int scannedEnemies, int costCreds, int newCreds, string filteredLivingEnemiesString)
		{
			string text = $"Biomatter scanner charged {costCreds} credits and has detected [{scannedEnemies}] non-employee organic objects.\n\n";
			if (!string.IsNullOrEmpty(filteredLivingEnemiesString))
			{
				text += $"Your new balance is ■{newCreds} Credits.\n\nDetailed scan has defined these objects as the following in the registry: \n{filteredLivingEnemiesString}\n";
			}
			else
			{
				text += $"Your new balance is ■{newCreds} Credits.\n";
				Loggers.LogInfo("v1 scanner utilized, only numbers shown");
			}
			return text;
		}

		internal static string VitalsCommand()
		{
			PlayerControllerB targetedPlayer = GameStuff.TerminalMapRenderer.targetedPlayer;
			if ((Object)(object)targetedPlayer == (Object)null)
			{
				return "Vitals command malfunctioning...\n\n";
			}
			int groupCredits = Plugin.instance.Terminal.groupCredits;
			int costCreds = GetCostCreds(vitalsUpgradeEnabled);
			string playerUsername = targetedPlayer.playerUsername;
			Loggers.LogInfo("playername: " + playerUsername);
			if (ShouldDisplayVitals(targetedPlayer, groupCredits, costCreds))
			{
				int newCreds = CalculateNewCredits(groupCredits, costCreds, Plugin.instance.Terminal);
				string vitalsInfo = GetVitalsInfo(targetedPlayer);
				string creditsInfo = GetCreditsInfo(newCreds);
				if (!vitalsUpgradeEnabled)
				{
					return $"Charged ■{costCreds} Credits. \n{vitalsInfo}\n{creditsInfo}";
				}
				return vitalsInfo + "\n" + creditsInfo;
			}
			return ConfigSettings.VitalsPoorString.Value + "\n";
		}

		internal static int GetCostCreds(bool upgradeStatus)
		{
			if (!upgradeStatus)
			{
				return Commands.VitalsCost.Value;
			}
			return 0;
		}

		internal static string AskBioscanUpgrade()
		{
			if (!enemyScanUpgradeEnabled)
			{
				return $"Purchase the BioScanner 2.0 Upgrade Patch?\nThis software update is available for {Commands.BioScanUpgradeCost.Value} Credits.\n\n\n\n\n\n\n\n\n\n\nPlease CONFIRM or DENY.\n";
			}
			TerminalGeneral.CancelConfirmation = true;
			return "BioScanner software has already been updated to the latest patch (2.0).\n\n";
		}

		internal static string AskVitalsUpgrade()
		{
			if (!vitalsUpgradeEnabled)
			{
				return $"Purchase the Vitals Scanner 2.0 Patch?\nThis software update is available for {Commands.VitalsUpgradeCost.Value} Credits.\n\n\n\n\n\n\n\n\n\n\nPlease CONFIRM or DENY.\n";
			}
			TerminalGeneral.CancelConfirmation = true;
			return "Vitals Scanner software has already been updated to the latest patch (2.0).\n\n";
		}

		internal static string PerformBioscanUpgrade()
		{
			if (!enemyScanUpgradeEnabled)
			{
				int num = Plugin.instance.Terminal.groupCredits - Commands.BioScanUpgradeCost.Value;
				string result = $"Biomatter Scanner software has been updated to the latest patch (2.0) and now provides more detailed information!\n\nYour new balance is ■{num} Credits\n";
				SaveManager.NewUnlock("BioscanPatch");
				Plugin.instance.Terminal.SyncGroupCreditsServerRpc(num, Plugin.instance.Terminal.numberOfItemsInDropship);
				Plugin.instance.Terminal.PlayTerminalAudioServerRpc(0);
				return result;
			}
			return "BioScanner software has already been updated to the latest patch (2.0).\n\n";
		}

		internal static string GetRefund()
		{
			int numberOfItemsInDropship = Plugin.instance.Terminal.numberOfItemsInDropship;
			Item[] buyables = Plugin.instance.Terminal.buyableItemsList;
			List<string> returnlist = new List<string>();
			int num2 = 0;
			Loggers.LogInfo($"buyables: {buyables.Length}, deliverables: {numberOfItemsInDropship}, storeCart: {storeCart.Count}");
			StoreRefundList.storeRefundItems = new List<StoreRefundItem>();
			if (numberOfItemsInDropship > 0)
			{
				foreach (int num in storeCart)
				{
					if (num <= buyables.Length)
					{
						StoreRefundItem storeRefundItem = StoreRefundList.storeRefundItems.FirstOrDefault((StoreRefundItem i) => (Object)(object)i.item == (Object)(object)buyables[num]);
						if (storeRefundItem != null)
						{
							storeRefundItem.count++;
							Loggers.LogDebug($"Updating refundItem ({storeRefundItem.item.itemName}) count to {storeRefundItem.count}");
						}
						else
						{
							Loggers.LogDebug("Creating refundItem for " + buyables[num].itemName + "!");
							storeRefundItem = new StoreRefundItem(buyables[num], 1);
							storeRefundItem.GetValue(buyables, num);
							StoreRefundList.storeRefundItems.Add(storeRefundItem);
						}
						num2 += storeRefundItem.value;
						Loggers.LogDebug($"Adding {storeRefundItem.item.itemName} ${storeRefundItem.value} to refund list");
					}
					else
					{
						Loggers.WARNING($"Unable to add item at index {num} to refund list! (out of index)");
					}
				}
				CollectionExtensions.Do<StoreRefundItem>((IEnumerable<StoreRefundItem>)StoreRefundList.storeRefundItems, (Action<StoreRefundItem>)delegate(StoreRefundItem x)
				{
					returnlist.Add($"${x.value} {x.item.itemName} x {x.count}\n");
				});
				Loggers.LogDebug($"old creds: {Plugin.instance.Terminal.groupCredits}");
				int num3 = Plugin.instance.Terminal.groupCredits + num2;
				Plugin.instance.Terminal.groupCredits = num3;
				Loggers.LogDebug($"new creds: {num3}");
				Plugin.instance.Terminal.orderedItemsFromTerminal.Clear();
				storeCart.Clear();
				NetHandler.Instance.SyncDropShipRpc(isRefund: true);
				NetHandler.Instance.SyncHostCreditsRpc(num3, 0);
				string arg = ListToStringBuild(returnlist);
				Loggers.LogInfo($"Refund total: ${num2}");
				string result = $"Cancelling order for:\n{arg}\nYou have been refunded ■{num2} Credits!\n";
				Plugin.instance.Terminal.PlayTerminalAudioServerRpc(0);
				return result;
			}
			return "No ordered items detected on the dropship.\n\n";
		}

		private static string ListToStringBuild(List<string> list)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < list.Count; i++)
			{
				stringBuilder.Append(list[i]);
			}
			return stringBuilder.ToString();
		}

		internal static string PerformVitalsUpgrade()
		{
			if (!vitalsUpgradeEnabled)
			{
				int num = Plugin.instance.Terminal.groupCredits - Commands.VitalsUpgradeCost.Value;
				SaveManager.NewUnlock("VitalsPatch");
				string result = $"Vitals Scanner software has been updated to the latest patch (2.0) and no longer requires credits to scan.\n\nYour new balance is ■{num} credits\n";
				Plugin.instance.Terminal.SyncGroupCreditsServerRpc(num, Plugin.instance.Terminal.numberOfItemsInDropship);
				Plugin.instance.Terminal.PlayTerminalAudioServerRpc(0);
				return result;
			}
			return "Update already purchased.\n";
		}

		private static bool ShouldDisplayVitals(PlayerControllerB playerInfo, int getCreds, int costCreds)
		{
			if (!playerInfo.isPlayerDead)
			{
				if (getCreds < costCreds)
				{
					return vitalsUpgradeEnabled;
				}
				return true;
			}
			return false;
		}

		internal static int CalculateNewCredits(int getCreds, int costCreds, Terminal frompatch)
		{
			int num = (frompatch.groupCredits = getCreds - costCreds);
			NetHandler.Instance.SyncHostCreditsRpc(num, frompatch.numberOfItemsInDropship);
			return num;
		}

		private static string GetVitalsInfo(PlayerControllerB playerInfo)
		{
			int health = playerInfo.health;
			float carryWeight = playerInfo.carryWeight;
			float insanityLevel = playerInfo.insanityLevel;
			bool flag = playerInfo.ItemSlots.Any((GrabbableObject item) => item is FlashlightItem);
			float num = Mathf.RoundToInt(Mathf.Clamp(carryWeight - 1f, 0f, 100f) * 105f);
			string text = $"{playerInfo.playerUsername} Vitals:\n\n Health: {health}\n Weight: {num}\n Sanity: {insanityLevel}";
			if (flag)
			{
				float num2 = Mathf.RoundToInt(playerInfo.pocketedFlashlight.insertedBattery.charge * 100f);
				text += $"\n Flashlight Battery Percentage: {num2}%";
			}
			return text;
		}

		private static string GetCreditsInfo(int newCreds)
		{
			return $"Your new balance is ■{newCreds} Credits.\n";
		}
	}
	internal class DynamicCommands
	{
		[CompilerGenerated]
		private sealed class <FovEnum>d__17 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Terminal term;

			public float number;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <FovEnum>d__17(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (fovEnum)
					{
						return false;
					}
					fovEnum = true;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					FovAdjustStuff.FovAdjustFunc(term, number);
					fovEnum = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static bool newParsedValue;

		internal static bool validFovNum;

		internal static bool fovEnum;

		public static int ParsedValue { get; internal set; }

		public static string Linktext { get; internal set; }

		internal static string BindKeyToCommand()
		{
			string[] words = StringStuff.GetWords();
			ShortcutBindings.BindToCommand(words, words.Length, out string displayText);
			return displayText;
		}

		internal static string UnBindKeyToCommand()
		{
			string[] words = StringStuff.GetWords();
			ShortcutBindings.UnbindKey(words, words.Length, out string displayText);
			return displayText;
		}

		internal static string FovPrompt()
		{
			if (!Plugin.instance.FovAdjust)
			{
				validFovNum = false;
				string result = "Unable to change your fov at this time...\n\tRequired mod [FOVAdjust] is not loaded!\n\n";
				Loggers.WARNING("not enough words for the fov command!");
				return result;
			}
			string afterKeyword = StringStuff.GetAfterKeyword(StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.FovKeywords.Value));
			if (afterKeyword.Length < 1)
			{
				validFovNum = false;
				string result2 = "Unable to change your fov at this time...\n\tInvalid input detected, no digits were provided!\n\n";
				Loggers.WARNING("not enough words for the fov command!");
				return result2;
			}
			if (int.TryParse(afterKeyword, out var result3))
			{
				newParsedValue = true;
				validFovNum = true;
				Loggers.LogDebug("))))))))))))))))))Integer Established");
				ParsedValue = result3;
				return $"Set your FOV to {ParsedValue}?\n\n\n\n\n\n\n\n\n\n\n\nPlease CONFIRM or DENY.\n";
			}
			validFovNum = false;
			string result4 = "Unable to change your fov at this time...\n\tInvalid input detected!\n\tInput: " + afterKeyword + "\n\n";
			Loggers.WARNING("there are no digits for the fov command!");
			return result4;
		}

		internal static string FovConfirm()
		{
			if (validFovNum)
			{
				Loggers.LogInfo("Valid fov value detected, returning fov command action");
				FovNodeText(out string displayText);
				return displayText;
			}
			Loggers.LogInfo("attempting to confirm invalid fov. Returning error");
			return Plugin.instance.Terminal.terminalNodes.specialNodes[5].displayText;
		}

		internal static string FovDeny()
		{
			if (validFovNum)
			{
				Loggers.LogInfo("Valid fov value detected, but fov has been canceled");
				return $"Fov change to {ParsedValue} has been canceled.\n\n\n";
			}
			Loggers.LogInfo("attempting to confirm invalid fov. Returning error");
			return Plugin.instance.Terminal.terminalNodes.specialNodes[5].displayText;
		}

		private static void FovNodeText(out string displayText)
		{
			TerminalNode currentNode = Plugin.instance.Terminal.currentNode;
			if (!Plugin.instance.FovAdjust)
			{
				displayText = "FovAdjust mod is not installed, command can not be run.\n";
				return;
			}
			int parsedValue = ParsedValue;
			float num = parsedValue;
			if (num != 0f && num >= 66f && num <= 130f && newParsedValue)
			{
				currentNode.clearPreviousText = true;
				displayText = "Setting FOV to - " + parsedValue + "\n\n";
				((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(FovEnum(Plugin.instance.Terminal, num));
			}
			else
			{
				displayText = "Fov can only be set between 66 and 130\n";
			}
		}

		[IteratorStateMachine(typeof(<FovEnum>d__17))]
		private static IEnumerator FovEnum(Terminal term, float number)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FovEnum>d__17(0)
			{
				term = term,
				number = number
			};
		}
	}
	internal class GambaCommands
	{
		internal static bool validGambleValue;

		internal static string Ask2Gamble()
		{
			Loggers.LogInfo("Ask2Gamble");
			string afterKeyword = StringStuff.GetAfterKeyword(StringStuff.GetKeywordsPerConfigItem(KeywordConfigs.GambleKeywords.Value));
			if (afterKeyword.Length < 1)
			{
				TerminalGeneral.CancelConfirmation = true;
				validGambleValue = false;
				string result = "Unable to gamble at this time...\n\tInvalid input detected, no digits were provided!\n\n";
				Loggers.WARNING("not enough words for the gamble command!");
				return result;
			}
			if (int.TryParse(afterKeyword, out var result2))
			{
				if (result2 < 0 || result2 > 100)
				{
					return BadInputGamble(afterKeyword);
				}
				DynamicCommands.newParsedValue = true;
				validGambleValue = true;
				Loggers.LogInfo("))))))))))))))))))Integer Established");
				DynamicCommands.ParsedValue = result2;
				return $"Gamble {DynamicCommands.ParsedValue}% of your credits?\n\n\n\n\n\n\n\n\n\n\n\nPlease CONFIRM or DENY.\n";
			}
			return BadInputGamble(afterKeyword);
		}

		internal static string BadInputGamble(string val)
		{
			TerminalGeneral.CancelConfirmation = true;
			validGambleValue = false;
			string result = "Unable to gamble at this time...\n\tInvalid input detected!\n\tInput: " + val + "\n\n";
			Loggers.WARNING("there are no digits for the gamble command!");
			return result;
		}

		internal static string GambleConfirm()
		{
			if (validGambleValue)
			{
				Loggers.LogInfo("Valid gamble value detected, returning gamble command action");
				BasicGambleCommand(out string displayText);
				return displayText;
			}
			Loggers.LogInfo("attempting to confirm invalid gamble. Returning error");
			return Plugin.instance.Terminal.terminalNodes.specialNodes[5].displayText;
		}

		internal static string GambleDeny()
		{
			if (validGambleValue)
			{
				Loggers.LogInfo("Valid gamble value detected, but gamble has been canceled");
				return $"Gamble for {DynamicCommands.ParsedValue}% of your credits has been canceled.\n\n\n";
			}
			Loggers.LogInfo("attempting to confirm invalid gamble. Returning error");
			return Plugin.instance.Terminal.terminalNodes.specialNodes[5].displayText;
		}

		internal static void BasicGambleCommand(out string displayText)
		{
			float num = DynamicCommands.ParsedValue;
			if (!DynamicCommands.newParsedValue || num < 0f || num > 100f)
			{
				Loggers.LogInfo("Invalid percentage value. Telling user.");
				displayText = "Invalid gamble percentage, please input a value between 0 and 100.\n\n";
				return;
			}
			if (Plugin.instance.Terminal.groupCredits <= ConfigSettings.GambleMinimum.Value)
			{
				Loggers.LogInfo("Invalid percentage value. Telling user.");
				displayText = ConfigSettings.GamblePoorString.Value + "\n\n";
				return;
			}
			(int, string) tuple = Gamble(Plugin.instance.Terminal.groupCredits, num);
			Plugin.instance.Terminal.groupCredits = tuple.Item1;
			NetHandler.Instance.SyncHostCreditsRpc(tuple.Item1, Plugin.instance.Terminal.numberOfItemsInDropship);
			DynamicCommands.newParsedValue = false;
			displayText = tuple.Item2;
		}

		private static (int newGroupCredits, string displayText) Gamble(int currentGroupCredits, float percentage)
		{
			percentage = Mathf.Clamp(percentage, 0f, 100f);
			int num = (int)((float)currentGroupCredits * (percentage / 100f));
			float value = Random.value;
			float value2 = Random.value;
			if (value < value2)
			{
				string item = $"Congratulations! You won ■{num} credits!\n\nYour new balance is ■{currentGroupCredits + num} Credits.\n";
				return (currentGroupCredits + num, item);
			}
			int num2 = currentGroupCredits - num;
			if (ConfigSettings.GamblePityMode.Value && num2 == 0)
			{
				if (ConfigSettings.GamblePityCredits.Value <= 60)
				{
					string item2 = $"Sorry, you lost ■{num} credits.\n\nHowever, you've received {ConfigSettings.GamblePityCredits.Value} Pity Credits.\n\nYour new balance is ■{ConfigSettings.GamblePityCredits.Value} Credits.\n";
					return (ConfigSettings.GamblePityCredits.Value, item2);
				}
				string item3 = $"Sorry, you lost ■{num} credits.\n\nUnfortunately we're also fresh out of Pity Credits due to malicious actors.\n\nYour new balance is ■{num2} Credits.\n";
				return (currentGroupCredits - num, item3);
			}
			string item4 = $"Sorry, you lost ■{num} credits.\n\nYour new balance is ■{num2} Credits.\n";
			return (currentGroupCredits - num, item4);
		}
	}
	internal class LevelCommands
	{
		internal static List<string> bannedWeather = new List<string>();

		internal static List<string> bannedWeatherConfig = new List<string>();

		internal static string RouteRandomCommand()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.instance.Terminal.groupCredits < ConfigSettings.RouteRandomCost.Value)
			{
				return $"You cannot afford to run the 'route random' command.\n\n\tRoute Random Cost: [{ConfigSettings.RouteRandomCost.Value}]\n\tYour credits: <color=#BD3131>[{Plugin.instance.Terminal.groupCredits}]</color>\n\n\n";
			}
			bannedWeatherConfig = StringStuff.GetKeywordsPerConfigItem(ConfigSettings.RouteRandomBannedWeather.Value);
			bannedWeather = StringStuff.GetListToLower(bannedWeatherConfig);
			List<SelectableLevel> list = new List<SelectableLevel>();
			SelectableLevel[] moonsCatalogueList = Plugin.instance.Terminal.moonsCatalogueList;
			foreach (SelectableLevel val in moonsCatalogueList)
			{
				if (bannedWeather.Contains(((object)(LevelWeatherType)(ref val.currentWeather)).ToString().ToLower()))
				{
					Loggers.LogInfo($"{val.PlanetName} has banned weather: {val.currentWeather}");
				}
				else if (ConfigSettings.RouteOnlyInCurrentConstellation.Value && Plugin.instance.Constellations)
				{
					if (ConstellationsCompat.IsLevelInConstellation(val))
					{
						list.Add(val);
						Loggers.LogInfo("Added " + val.PlanetName + " to valid random planets within the current constellation!");
					}
				}
				else
				{
					list.Add(val);
					Loggers.LogInfo("Added " + val.PlanetName + " to valid random planets");
				}
			}
			if (list.Count < 1)
			{
				return "Route Random was unable to select a valid moon and you have not been charged.\n\nThis may be due to all moons have banned weather attributes...\n\n\n";
			}
			Random random = new Random();
			int index = random.Next(0, list.Count);
			Loggers.LogInfo(list[index].PlanetName + " has been chosen!");
			StartOfRound.Instance.ChangeLevelServerRpc(list[index].levelID, Plugin.instance.Terminal.groupCredits);
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
			int num = CostCommands.CalculateNewCredits(Plugin.instance.Terminal.groupCredits, ConfigSettings.RouteRandomCost.Value, Plugin.instance.Terminal);
			return $"Your new balance is ■{num} Credits.\n\nRoute Random has chosen {list[index].PlanetName}!\n\n\tEnjoy!\n\n";
		}
	}
	internal class SuitCommands
	{
		internal static void GetRandomSuit(out string displayText)
		{
			List<UnlockableSuit> list = new List<UnlockableSuit>();
			List<UnlockableItem> list2 = new List<UnlockableItem>();
			list = Resources.FindObjectsOfTypeAll<UnlockableSuit>().ToList();
			displayText = string.Empty;
			if (list.Count > 1)
			{
				list = list.OrderBy((UnlockableSuit suit) => suit.suitID).ToList();
				list.RemoveAll((UnlockableSuit suit) => suit.syncedSuitID.Value < 0);
				list2 = StartOfRound.Instance.unlockablesList.unlockables;
				Random random = new Random();
				if (list2 != null)
				{
					for (int i = 0; i < list2.Count; i++)
					{
						int index = random.Next(0, list.Count);
						UnlockableSuit val = list[index];
						if ((Object)(object)val != (Object)null && list2[val.syncedSuitID.Value] != null)
						{
							string unlockableName = list2[val.syncedSuitID.Value].unlockableName;
							val.SwitchSuitToThis((PlayerControllerB)null);
							displayText = "Changing suit to " + unlockableName + "!\n";
							return;
						}
					}
					displayText = "A suit could not be found.\n";
					Plugin.Log.LogInfo((object)"Random suit ID was invalid or null");
				}
				else
				{
					displayText = "A suit could not be found.\n";
					Plugin.Log.LogInfo((object)"Unlockables are null");
				}
			}
			else
			{
				displayText = "Not enough suits detected.\n";
				Plugin.Log.LogInfo((object)"allsuits count too low");
			}
		}
	}
	public static class TerminalEvents
	{
		[CompilerGenerated]
		private sealed class <TerminalQuitter>d__17 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Terminal terminal;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TerminalQuitter>d__17(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Expected O, but got Unknown
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (quitTerminalEnum)
					{
						return false;
					}
					if (Plugin.instance.CruiserTerm && CruiserTerm.Status())
					{
						quitTerminalEnum = true;
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 1;
						return true;
					}
					quitTerminalEnum = true;
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 2;
					return true;
				case 1:
					<>1__state = -1;
					CruiserTerm.Quit();
					quitTerminalEnum = false;
					return false;
				case 2:
					<>1__state = -1;
					terminal.QuitTerminal(true);
					quitTerminalEnum = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static string lastText = "";

		internal static string VideoErrorMessage = "";

		public static bool clockDisabledByCommand = false;

		internal static bool quitTerminalEnum = false;

		internal static Color transparent = new Color(0f, 0f, 0f, 0f);

		public static TerminalSettings terminalSettings { get; internal set; } = new TerminalSettings();


		internal static List<CommandManager> PurchasePacks { get; set; } = new List<CommandManager>();


		internal static void CreateStorePacks()
		{
			if (!Commands.TerminalPurchasePacks.Value || ConfigSettings.PurchasePackCommands.Value == "")
			{
				return;
			}
			Dictionary<string, string> keywordAndItemNames = StringStuff.GetKeywordAndItemNames(ConfigSettings.PurchasePackCommands.Value);
			if (keywordAndItemNames.Count == 0)
			{
				return;
			}
			foreach (KeyValuePair<string, string> item in keywordAndItemNames)
			{
				Loggers.LogDebug("setting " + item.Key + " keyword to purchase pack with items: " + item.Value);
				if (PurchasePacks.Count != 0)
				{
					CommandManager val = ((IEnumerable<CommandManager>)PurchasePacks).FirstOrDefault((Func<CommandManager, bool>)((CommandManager p) => p.KeywordList.Contains(item.Key)));
					if (val != null)
					{
						val.RegisterCommand();
						continue;
					}
				}
				CommandManager val2 = Commands.AddLocalCommmandManualWords(item.Key + "_PP", Commands.TerminalPurchasePacks, new List<string>(1) { item.Key }, StorePacks.AskPurchasePack, "Comfort", clearText: true, addAtAwake: false);
				Commands.AddStoreCommand(val2, item.Key ?? "", 0, StorePacks.CompletePurchasePack, () => "You have cancelled the purchase of Purchase Pack [" + item.Key + "].\n\n", 0, alwaysInStock: true);
				val2.RegisterCommand();
				PurchasePacks.Add(val2);
				StorePlus.ExcludedNodesFromAutoGen.Add(val2.terminalNode);
				StorePacks storePacks = StorePacksInfo.AllPacks.FirstOrDefault((StorePacks s) => s.Name == item.Key);
				if (storePacks != null)
				{
					storePacks.UpdateExisting(item.Value, val2);
				}
				else
				{
					storePacks = new StorePacks(item.Key, item.Value, val2);
				}
			}
		}

		internal static TerminalNode GetNodeFromList(string query, Dictionary<string, TerminalNode> nodeListing)
		{
			foreach (KeyValuePair<string, TerminalNode> item in nodeListing)
			{
				if (item.Key == query)
				{
					return item.Value;
				}
			}
			return null;
		}

		internal static string RandomSuit()
		{
			SuitCommands.GetRandomSuit(out string displayText);
			return displayText;
		}

		internal static string QuitTerminalCommand()
		{
			string result = ConfigSettings.QuitString.Value ?? "";
			((MonoBehaviour)Plugin.instance.Terminal).StartCoroutine(TerminalQuitter(Plugin.instance.Terminal));
			return result;
		}

		[IteratorStateMachine(typeof(<TerminalQuitter>d__17))]
		internal static IEnumerator TerminalQuitter(Terminal terminal)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TerminalQuitter>d__17(0)
			{
				terminal = terminal
			};
		}

		internal static string ClockToggle()
		{
			if ((Object)(object)TerminalClockStuff.textComponent == (Object)null)
			{
				return "Unable to find Terminal Clock component!\n\n";
			}
			if (StartOfRound.Instance.inShipPhase)
			{
				return "Unable to determine time zone while in Orbit!\n\n";
			}
			if (!clockDisabledByCommand && TerminalClockStuff.IsClockVisible())
			{
				Loggers.LogDebug("Disabling clock via command!");
				clockDisabledByCommand = true;
				TerminalClockStuff.SetClockVisible(visible: false);
				return "Terminal Clock [DISABLED].\n";
			}
			Loggers.LogDebug("Enabling clock via command!");
			clockDisabledByCommand = false;
			TerminalClockStuff.SetClockVisible(visible: true);
			return "Terminal Clock [ENABLED].\n";
		}

		internal static string GetCleanedScreenText(Terminal __instance)
		{
			string text = __instance.screenText.text;
			int textAdded = __instance.textAdded;
			int length = text.Length;
			int num = length - textAdded;
			string s = text.Substring(num, length - num);
			return RemovePunctuation(s);
		}

		private static string RemovePunctuation(string s)
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (char c in s)
			{
				if (!char.IsPunctuation(c))
				{
					stringBuilder.Append(c);
				}
			}
			return stringBuilder.ToString().ToLower();
		}

		internal static void ShouldLockPlayerCamera(bool value, PlayerControllerB localPlayer)
		{
			if (QoLConfig.LockCameraInTerminal.Value && (Object)(object)localPlayer != (Object)null)
			{
				localPlayer.disableLookInput = !value;
				Loggers.LogInfo($"ShouldLockPlayerCamera set to: {!value}");
			}
		}

		internal static void ShouldDisableTerminalLight(bool value, string setting)
		{
			if (!(setting == "nochange") && ((Behaviour)Plugin.instance.Terminal.terminalLight).enabled == value)
			{
				((Behaviour)Plugin.instance.Terminal.terminalLight).enabled = !value;
				Loggers.LogInfo($"terminalLight set to {!value} for setting: {setting}");
			}
		}

		internal static string RefreshCustomizationCommand()
		{
			string result = "Refreshing TerminalCustomization from config.\n\n";
			TerminalCustomizer.TerminalCustomization();
			return result;
		}

		internal static int PlayerNameToTargetInt(string query, List<TransformAndName> radarTargets)
		{
			query = query.TrimStart();
			if (query.Length <= 2)
			{
				return -1;
			}
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			for (int i = 0; i < radarTargets.Count; i++)
			{
				if (MoreCamStuff.TargetIsValid(radarTargets[i]))
				{
					if (Misc.StringStartsWithInvariant(radarTargets[i].name, query.Substring(0, 2), true))
					{
						int num = Levenshtein.Distance(query, radarTargets[i].name);
						Loggers.LogDebug($"TargetNum {i} has score {num}");
						dictionary.Add(i, num);
						continue;
					}
					Loggers.LogDebug("name [ " + radarTargets[i].name + " ] does not match start of query [ " + query.Substring(0, 2) + " ]");
				}
			}
			if (dictionary.Count == 0)
			{
				return -1;
			}
			return dictionary.OrderBy((KeyValuePair<int, int> x) => x.Value).First().Key;
		}

		internal static string PlayerNameToTargetString(string query, List<TransformAndName> radarTargets)
		{
			query = query.TrimStart();
			if (query.Length <= 2)
			{
				return "";
			}
			Dictionary<string, int> dictionary = new Dictionary<string, int>();
			for (int i = 0; i < radarTargets.Count; i++)
			{
				if (MoreCamStuff.TargetIsValid(radarTargets[i]))
				{
					if (Misc.StringStartsWithInvariant(radarTargets[i].name, query.Substring(0, 2), true))
					{
						int num = Levenshtein.Distance(query, radarTargets[i].name);
						Loggers.LogDebug($"TargetNum {i} has score {num}");
						dictionary.Add(radarTargets[i].name, num);
						continue;
					}
					Loggers.LogDebug("name [ " + radarTargets[i].name + " ] does not match start of query [ " + query.Substring(0, 2) + " ]");
				}
			}
			if (dictionary.Count == 0)
			{
				return "";
			}
			return dictionary.OrderBy((KeyValuePair<string, int> x) => x.Value).First().Key;
		}

		internal static void LoadAndSync(TerminalNode node)
		{
			if (!((Object)(object)node == (Object)null))
			{
				Plugin.instance.Terminal.LoadNewNode(node);
				Loggers.LogDebug("Loading node!");
				if (ConfigSettings.NetworkedNodes.Value && !((Object)(object)NetHandler.Instance == (Object)null))
				{
					Loggers.LogDebug("Syncing with TerminalStuff!");
					TerminalParse.NetSync(node);
				}
			}
		}
	}
	public class TerminalSettings
	{
		public TerminalNode startPage;

		public string startPageValue { get; internal set; } = string.Empty;


		internal void StartPage(string entry)
		{
			startPageValue = entry;
			startPage = null;
			if (!Misc.StringStartsWithInvariant(startPageValue, "none", true) && startPageValue.Length >= 2)
			{
				TerminalKeyword val = default(TerminalKeyword);
				if (DynamicBools.TryGetKeyword(startPageValue, ref val))
				{
					startPage = val.specialKeywordResult;
				}
				else
				{
					Loggers.WARNING("Unable to find matching keyword for start page - " + entry);
				}
			}
		}
	}
	public static class ConfigSettings
	{
		public static ConfigEntry<bool> TerminalCustomization { get; internal set; }

		public static ConfigEntry<LoggingLevel> LogLevel { get; internal set; }

		public static ConfigEntry<bool> CamsUseDetectedMods { get; internal set; }

		public static ConfigEntry<bool> ObcRequireUpgrade { get; internal set; }

		public static ConfigEntry<string> ObcResolutionMirror { get; internal set; }

		public static ConfigEntry<string> ObcResolutionBodyCam { get; internal set; }

		public static ConfigEntry<float> MirrorZoom { get; internal set; }

		public static ConfigEntry<bool> Mirror2DStyle { get; internal set; }

		public static ConfigEntry<bool> ModNetworking { get; internal set; }

		public static ConfigEntry<bool> NetworkedNodes { get; internal set; }

		public static ConfigEntry<bool> CanOpenDoorInSpace { get; internal set; }

		public static ConfigEntry<string> DoorOpenString { get; internal set; }

		public static ConfigEntry<string> DoorCloseString { get; internal set; }

		public static ConfigEntry<string> DoorSpaceString { get; internal set; }

		public static ConfigEntry<string> QuitString { get; internal set; }

		public static ConfigEntry<string> LeverString { get; internal set; }

		public static ConfigEntry<string> VideoStartString { get; internal set; }

		public static ConfigEntry<string> VideoStopString { get; internal set; }

		public static ConfigEntry<string> TpMessageString { get; internal set; }

		public static ConfigEntry<string> ItpMessageString { get; internal set; }

		public static ConfigEntry<string> VitalsPoorString { get; internal set; }

		public static ConfigEntry<string> VitalsUpgradePoor { get; internal set; }

		public static ConfigEntry<string> HealIsFullString { get; internal set; }

		public static ConfigEntry<string> HealString { get; internal set; }

		public static ConfigEntry<string> CamOnString { get; internal set; }

		public static ConfigEntry<string> CamOffString { get; internal set; }

		public static ConfigEntry<string> MapOnString { get; internal set; }

		public static ConfigEntry<string> MapOffString { get; internal set; }

		public static ConfigEntry<string> OverlayOnString { get; internal set; }

		public static ConfigEntry<string> OverlayOffString { get; internal set; }

		public static ConfigEntry<string> MiniMapOnString { get; internal set; }

		public static ConfigEntry<string> MiniMapOffString { get; internal set; }

		public static ConfigEntry<string> MiniCamsOnString { get; internal set; }

		public static ConfigEntry<string> MiniCamsOffString { get; internal set; }

		public static ConfigEntry<int> GambleMinimum { get; internal set; }

		public static ConfigEntry<bool> GamblePityMode { get; internal set; }

		public static ConfigEntry<int> GamblePityCredits { get; internal set; }

		public static ConfigEntry<string> GamblePoorString { get; internal set; }

		public static ConfigEntry<string> VideoFolderPath { get; internal set; }

		public static ConfigEntry<bool> VideoSync { get; internal set; }

		public static ConfigEntry<bool> AlwaysUniqueVideo { get; internal set; }

		public static ConfigEntry<bool> MonitoringNeverHide { get; internal set; }

		public static ConfigEntry<string> MonitoringDefaultView { get; internal set; }

		public static ConfigEntry<int> OverlayOpacity { get; internal set; }

		public static ConfigEntry<string> CustomLink { get; internal set; }

		public static ConfigEntry<string> CustomLink2 { get; internal set; }

		public static ConfigEntry<string> CustomLinkHint { get; internal set; }

		public static ConfigEntry<string> CustomLink2Hint { get; internal set; }

		public static ConfigEntry<string> RouteRandomBannedWeather { get; internal set; }

		public static ConfigEntry<int> RouteRandomCost { get; internal set; }

		public static ConfigEntry<bool> RouteOnlyInCurrentConstellation { get; internal set; }

		public static ConfigEntry<string> PurchasePackCommands { get; internal set; }

		public static ConfigEntry<string> CruiserTerminalFilterType { get; internal set; }

		public static ConfigEntry<string> CruiserKeywordList { get; internal set; }

		public static void BindConfigSettings()
		{
			ModNetworking = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Networking", "ModNetworking", true, "Disable this if you want to disable networking and use this mod as a Client-sided mod");
			NetworkedNodes = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Networking", "NetworkedNodes", true, "Enable networked Always-On Display & displaying synced terminal nodes");
			LogLevel = ConfigSetup.MakeGeneric<LoggingLevel>(((BaseUnityPlugin)Plugin.instance).Config, "Debug", "ExtensiveLogging", (LoggingLevel)8, "Set the logging level for DarmuhsTerminalStuff (this mod).");
			PurchasePackCommands = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Comfort Configuration", "PurchasePackCommands", "Essentials:pro,shov,walkie;PortalPack:teleporter,inverse", "List of purchase pack commands to create. Format is command:item1,item2,etc.;next command:item1,item2");
			Loggers.LogDebug("network configs section done");
			Loggers.LogDebug("keybind configs section done");
			CamsUseDetectedMods = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CamsUseDetectedMods", true, "With this enabled, this mod will detect if another mod that adds player cams is enabled and use the mod's camera for all cams commands. Currently detects the following: Helmet Cameras by Rick Arg, Body Cameras by Solo, OpenBodyCams by Zaggy1024");
			ObcRequireUpgrade = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "ObcRequireUpgrade", true, "With this enabled (and CamsUseDetectedMods), cams views will not be available until the bodycam upgrade from OpenBodyCams has been unlocked.");
			RouteRandomBannedWeather = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "RouteRandomBannedWeather", "Eclipsed;Flooded;Foggy", "This semi-colon separated list will be used to exclude moons from the route random command");
			RouteRandomCost = ConfigSetup.MakeGeneric<int>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "RouteRandomCost", 100, "Flat rate for running the route random command to get a random moon...", 0, 99999);
			RouteOnlyInCurrentConstellation = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "RouteOnlyInCurrentConstellation", true, "When LethalConstellations mod is present, setting this to true will only choose a random moon within the current constellation");
			Loggers.LogDebug("cost configs section done");
			KeywordConfigs.Init();
			DoorOpenString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "DoorOpenString", "Opening door.", "Message returned on door (open) command.");
			DoorCloseString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "DoorCloseString", "Closing door.", "Message returned on door (close) command.");
			DoorSpaceString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "DoorSpaceString", "Can't open doors in space.", "Message returned on door (inSpace) command.");
			CanOpenDoorInSpace = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "CanOpenDoorInSpace", true, "Allow/Disallow for using the terminal to press the button to open the door in space.\nDoes not change whether the door can actually be opened.");
			QuitString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Comfort Configuration", "QuitString", "goodbye!", "Message returned on quit command.");
			LeverString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "LeverString", "PULLING THE LEVER!!!", "Message returned on lever pull command.");
			VideoStartString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "VideoStartString", "lol.", "Message displayed when first playing a video.");
			VideoStopString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "VideoStopString", "No more lol.", "Message displayed if you want to end video playback early.");
			TpMessageString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "TpMessageString", "Teleport Button pressed.", "Message returned when TP command is run.");
			ItpMessageString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Controls Configuration", "ItpMessageString", "Inverse Teleport Button pressed.", "Message returned when ITP command is run.");
			VitalsPoorString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Upgrades", "VitalsPoorString", "You can't afford to run this command.", "Message returned when you don't have enough credits to run the <Vitals> command.");
			VitalsUpgradePoor = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Upgrades", "VitalsUpgradePoor", "You can't afford to upgrade the Vitals Scanner.", "Message returned when you don't have enough credits to unlock the vitals scanner upgrade.");
			HealIsFullString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Comfort Configuration", "HealIsFullString", "You are full health!", "Message returned when heal command is run and player is already full health.");
			HealString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Comfort Configuration", "HealString", "The terminal healed you?!?", "Message returned when heal command is run and player is healed.");
			CamOnString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CamOnString", "(CAMS)", "Message returned when enabling Cams command (cams).");
			CamOffString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CamOffString", "Cameras disabled.", "Message returned when disabling Cams command (cams).");
			MapOnString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MapOnString", "(MAP)", "Message returned when enabling map command (map).");
			MapOffString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MapOffString", "Map View disabled.", "Message returned when disabling map command (map).");
			OverlayOnString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "OverlayOnString", "(Overlay)", "Message returned when enabling Overlay command (overlay).");
			OverlayOffString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "OverlayOffString", "Overlay disabled.", "Message returned when disabling Overlay command (overlay).");
			MiniMapOnString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MiniMapOnString", "(MiniMap)", "Message returned when enabling minimap command (minimap).");
			MiniMapOffString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MiniMapOffString", "MiniMap disabled.", "Message returned when disabling minimap command (minimap).");
			MiniCamsOnString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MiniCamsOnString", "(MiniCams)", "Message returned when enabling minicams command (minicams).");
			MiniCamsOffString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MiniCamsOffString", "MiniCams disabled.", "Message returned when disabling minicams command (minicams).");
			CustomLink = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CustomLink", "https://thunderstore.io/c/lethal-company/p/darmuh/darmuhsTerminalStuff/", "URL to send players to when using the \"link\" command.");
			CustomLinkHint = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CustomLinkHint", "Go to the thunderstore listing for this mod.", "Hint given to players in extras menu for \"link\" command.");
			CustomLink2 = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CustomLink2", "https://github.com/darmuh/TerminalStuff", "URL to send players to when using the second \"link\" command.");
			CustomLink2Hint = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "CustomLink2Hint", "Go to the github for this mod.", "Hint given to players in extras menu for \"link\" command.");
			GambleMinimum = ConfigSetup.MakeGeneric<int>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "GambleMinimum", 0, "Credits needed to start gambling, 0 means you can gamble everything.");
			GamblePityMode = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "GamblePityMode", false, "Enable Gamble Pity Mode, which gives credits back to those who lose everything.");
			GamblePityCredits = ConfigSetup.MakeGeneric<int>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "GamblePityCredits", 10, "If Gamble Pity Mode is enabled, specify how much Pity Credits are given to losers. (Max: 60)", 0, 60);
			GamblePoorString = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "GamblePoorString", "You don't meet the minimum credits requirement to gamble.", "Message returned when your credits is less than the GambleMinimum set.");
			VideoFolderPath = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "VideoFolderPath", "darmuh-darmuhsTerminalVideos", "Folder name where videos will be pulled from, needs to be in BepInEx/plugins");
			VideoSync = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "VideoSync", true, "When networking is enabled, this setting will sync videos being played on the terminal for all players whose terminal screen is on.");
			AlwaysUniqueVideo = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Fun Configuration", "AlwaysUniqueVideo", true, "When enabled, this setting will shuffle all of the videos into a list. Each time a video command is run it will play a video from the list until it reaches the end of the list. Then a new re-shuffled list will be created.");
			ObcResolutionMirror = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "ObcResolutionMirror", "1000; 700", "Set the resolution of the Mirror Camera created with OpenBodyCams for darmuhsTerminalStuff");
			ObcResolutionBodyCam = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "ObcResolutionBodyCam", "1000; 700", "Set the resolution of the Body Camera created with OpenBodyCams for darmuhsTerminalStuff");
			MirrorZoom = ConfigSetup.MakeGeneric<float>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MirrorZoom", 3.4f, "Set the mirror zoom level, the higher the value the more zoomed out the mirror will be.\nThis requires [Mirror2DStyle] to be enabled", 0.2f, 9f);
			Mirror2DStyle = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "Mirror2DStyle", false, "Change whether the mirror will use Orthographic (2D) Styling.\n Old versions of this mod had this enabled by default.");
			MonitoringNeverHide = ConfigSetup.MakeGeneric<bool>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MonitoringNeverHide", false, "Setting this to true will make it so no command will ever auto-hide any monitoring view.");
			MonitoringDefaultView = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "MonitoringDefaultView", "Map", "Set the default monitoring view to use when using the switch/previous commands and there is no active monitoring view.\nSet to \"None\" to not automatically enable any views when switch/previous commands are used.", new AcceptableValueList<string>(new string[6] { "None", "Map", "Cams", "Minicams", "Minimap", "Overlay" }));
			OverlayOpacity = ConfigSetup.MakeGeneric<int>(((BaseUnityPlugin)Plugin.instance).Config, "Extras Configuration", "OverlayOpacity", 10, "Opacity percentage for Overlay View.", 0, 100);
			CruiserTerminalConfigs();
			QoLConfig.Init();
			CustomizeConfig.Init();
			MoonsPlusConfig.Init();
			StorePlusConfig.Init();
			Loggers.LogInfo("end of config setup");
			ConfigSetup.RemoveOrphanedEntries(((BaseUnityPlugin)Plugin.instance).Config);
			Loggers.LogDebug("Main config load COMPLETE");
			Commands.CommandDefinitions();
		}

		public static void CruiserTerminalConfigs()
		{
			CruiserTerminalFilterType = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "CruiserTerminal", "Cruiser Terminal Filter Type", "Deny", "Use this to set whether the Cruiser Keyword List is a list of keywords to permit or deny", new AcceptableValueList<string>(new string[2] { "Deny", "Permit" }));
			CruiserKeywordList = ConfigSetup.MakeGeneric<string>(((BaseUnityPlugin)Plugin.instance).Config, "CruiserTerminal", "Cruiser Terminal Keyword List", "mirror, reflection, show mirror, restart, tp, use teleporter, teleport, itp, use inverse, inverse, door, lights, toggle lights, lol, play video, route random, random moon, refresh colors, paintme, customize, scolor, fcolor, lever, link, link2, fov, restart, reset", "Comma-separated listing of keywords to permit OR deny depending on Cruiser Terminal Filter Type");
		}
	}
	[BepInDependency("darmuh.OpenLib", "0.4.0")]
	[BepInPlugin("darmuh.TerminalStuff", "darmuhsTerminalStuff", "3.9.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin instance = null;

		internal NetworkClass<NetHandler> Networker;

		internal static ManualLogSource Log = null;

		public bool LobbyCompat;

		public bool LateGameUpgrades;

		public bool FovAdjust;

		public bool HelmetCamsMod;

		public bool SolosBodyCamsMod;

		public bool OpenBodyCamsMod;

		public bool TwoRadarMapsMod;

		public bool suitsTerminal;

		public bool TerminalFormatter;

		public bool Constellations;

		public bool ShipInventory;

		public bool CruiserTerm;

		public bool ITAPI;

		public bool WeatherTweaks;

		public bool GenImprovements;

		public bool isOnMirror;

		public bool isOnCamera;

		public bool isOnMap;

		public bool isOnOverlay;

		public bool isOnMiniMap;

		public bool isOnMiniCams;

		public bool activeCam;

		public bool splitViewCreated;

		internal bool removeTab;

		internal Terminal Terminal;

		internal static bool refreshNodes = false;

		private static List<TerminalNode> _allnodescached = new List<TerminalNode>();

		public const string Id = "darmuh.TerminalStuff";

		public bool LethalLevelLoader => Chainloader.PluginInfos.ContainsKey("imabatby.lethallevelloader");

		internal static List<TerminalNode> Allnodes
		{
			get
			{
				if (_allnodescached.Count == 0 || refreshNodes)
				{
					_allnodescached = LogicHandling.GetAllNodes();
				}
				if (refreshNodes)
				{
					refreshNodes = false;
				}
				return _allnodescached;
			}
			set
			{
			}
		}

		public static string Name => "darmuhsTerminalStuff";

		public static string Version => "3.9.0";

		private void Awake()
		{
			instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"darmuhsTerminalStuff is loaded with version 3.9.0!\nThis mod has been compiled for v73 of LethalCompany!");
			ConfigSettings.BindConfigSettings();
			VideoManager.Load();
			Subscribers.Subscribe();
			((BaseUnityPlugin)this).Config.ConfigReloaded += OnConfigReloaded;
			((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Networker = new NetworkClass<NetHandler>("darmuhsTerminalStuff NetHandler", ConfigSettings.ModNetworking);
		}

		internal void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
		{
			Loggers.LogDebug("CONFIG SETTING CHANGE EVENT");
			StuffForLibrary.ConfigSettingChange();
			TerminalStart.InitiateTerminalStuff();
			_ = settingChangedArg.ChangedSetting;
		}

		internal void OnConfigReloaded(object sender, EventArgs e)
		{
			Loggers.LogDebug("Config has been reloaded!");
		}

		internal static void PatchLog(string message)
		{
			Log.LogInfo((object)message);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "darmuhsTerminalStuff";

		public const string PLUGIN_NAME = "darmuhsTerminalStuff";

		public const string PLUGIN_VERSION = "3.9.0";
	}
}
namespace TerminalStuff.VisualElements
{
	internal class AlwaysOnStuff
	{
		[CompilerGenerated]
		private sealed class <DelayScreenOff>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int delay;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayScreenOff>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (delayOff)
					{
						return false;
					}
					delayOff = true;
					<>2__current = (object)new WaitForSeconds((float)delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
					{
						SetScreenPlus(visible: false);
					}
					delayOff = false;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal static bool delayOff;

		internal static ScreenSettings screenSettings;

		internal static void IsPlayerDead()
		{
			if (StartOfRound.Instance.localPlayerController.isPlayerDead && DisableScreenOnDeath() && ((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf)
			{
				((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.SetActive(false);
			}
		}

		internal static void OnSpecateShipCheck()
		{
			if (!DisableScreenOnDeath() && screenSettings.Dynamic)
			{
				Loggers.LogDebug($"Spectated Player detected in ship [ {StartOfRound.Instance.localPlayerController.spectatedPlayerScript.isInHangarShipRoom} ]");
				if (screenSettings.inUse && !((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf && !((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf && StartOfRound.Instance.localPlayerController.spectatedPlayerScript.isInHangarShipRoom && Plugin.instance.Terminal.placeableObject.inUse)
				{
					SetScreenPlus(visible: true);
				}
				if (!((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf && StartOfRound.Instance.localPlayerController.spectatedPlayerScript.isInHangarShipRoom)
				{
					SetScreenPlus(visible: true);
				}
				else if (((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf && !StartOfRound.Instance.localPlayerController.spectatedPlayerScript.isInHangarShipRoom)
				{
					SetScreenPlus(visible: false);
				}
			}
		}

		internal static void SetScreenPlus(bool visible)
		{
			((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.SetActive(visible);
			if (!StartOfRound.Instance.inShipPhase && !TerminalEvents.clockDisabledByCommand)
			{
				TerminalClockStuff.SetClockVisible(visible);
			}
			else
			{
				TerminalClockStuff.SetClockVisible(visible: false);
			}
			if ((ViewCommands.AnyActiveMonitoring() && Plugin.instance.splitViewCreated) || Plugin.instance.isOnMirror)
			{
				Loggers.LogInfo("Adjusting camera views to screen status");
				SplitViewChecks.ShowCameraView(visible);
			}
		}

		internal static void PlayerShipChanged()
		{
			if ((Object)(object)StartOfRound.Instance.localPlayerController == (Object)null || screenSettings == null)
			{
				return;
			}
			Loggers.LogDebug($"Player detected in ship change - {StartOfRound.Instance.localPlayerController.isInHangarShipRoom}");
			if (StartOfRound.Instance.localPlayerController.isPlayerDead && DisableScreenOnDeath() && ((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf)
			{
				SetScreenPlus(visible: false);
			}
			if (StartOfRound.Instance.localPlayerController.isInHangarShipRoom)
			{
				if (screenSettings.Dynamic && !screenSettings.inUse)
				{
					if (!((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf)
					{
						SetScreenPlus(visible: true);
					}
				}
				else if (screenSettings.inUse && TerminalUpdatePatch.inUse && !((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf)
				{
					SetScreenPlus(visible: true);
				}
			}
			else
			{
				if (!screenSettings.Dynamic)
				{
					return;
				}
				Loggers.LogDebug($"disabling screen - screenSetting Dynamic {screenSettings.Dynamic}");
				if (((Component)Plugin.instance.Terminal.terminalUIScreen).gameObject.activeSelf)
				{
					if (QoLConfig.ScreenOffDelay.Value < 1)
					{
						SetScreenPlus(visible: false);
					}
					else
					{
						((MonoBehaviour)Plugin.instance).StartCoroutine(DelayScreenOff(QoLConfig.ScreenOffDelay.Value));
					}
				}
			}
		}

		[IteratorStateMachine(typeof(<DelayScreenOff>d__6))]
		internal static IEnumerator DelayScreenOff(int delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayScreenOff>d__6(0)
			{
				delay = delay
			};
		}

		internal static bool DisableScreenOnDeath()
		{
			if (QoLConfig.ScreenOnWhileDead.Value)
			{
				return false;
			}
			return StartOfRound.Instance.localPlayerController.isPlayerDead;
		}
	}
	internal class ScreenSettings
	{
		internal bool AlwaysOn;

		internal bool Dynamic;

		internal bool inUse;

		internal void Update(string setting)
		{
			if (Misc.CompareStringsInvariant(setting, "alwayson", true))
			{
				AlwaysOn = true;
				Dynamic = false;
				inUse = false;
			}
			else if (Misc.CompareStringsInvariant(setting, "inship", true))
			{
				AlwaysOn = true;
				Dynamic = true;
				inUse = false;
			}
			else if (Misc.CompareStringsInvariant(setting, "inuse", true))
			{
				AlwaysOn = true;
				Dynamic = true;
				inUse = true;
			}
			else
			{
				AlwaysOn = false;
				Dynamic = false;
				inUse = false;
			}
			Loggers.LogDebug("ScreenSettings set to: " + setting);
		}

		internal ScreenSettings(string setting)
		{
			Update(setting);
		}
	}
	public class CamEvents
	{
		internal static CamsClass CamsThings = new CamsClass();

		public static CustomEvent<string> UpdateCamsEvent = new CustomEvent<string>();

		public static CustomEvent<int> UpdateTarget = new CustomEvent<int>();

		internal static void SetTextures(Texture texture, Texture mini = null)
		{
			Plugin.instance.Terminal.terminalImage.texture = texture;
			if ((Object)(object)mini != (Object)null)
			{
				SplitViewChecks.miniScreenImage.texture = mini;
			}
		}

		internal static void UpdateStyle(Texture main, float mainOpacity, Texture mini = null, float miniOpacity = 0f, bool isOverlay = false)
		{
			if ((Object)(object)mini == (Object)null)
			{
				SetTextures(main);
				SetRawImageTransparency(Plugin.instance.Terminal.terminalImage, mainOpacity);
				SetRawImageDimensions(((Graphic)Plugin.instance.Terminal.terminalImage).rectTransform, isFullScreen: true);
			}
			else
			{
				SetTextures(main, mini);
				SetRawImageTransparency(Plugin.instance.Terminal.terminalImage, mainOpacity);
				SetRawImageTransparency(SplitViewChecks.miniScreenImage, miniOpacity);
				SetRawImageDimensions(((Graphic)SplitViewChecks.miniScreenImage).rectTransform, isOverlay);
				SetRawImageDimensions(((Graphic)Plugin.instance.Terminal.terminalImage).rectTransform, isFullScreen: true);
			}
		}

		internal static void OnUpdateCamsEvent(string mode)
		{
			Loggers.LogDebug("UpdateCams Event!");
			CamsThings.Mode = mode;
			switch (mode)
			{
			case "map":
				CamsThings.radarTexture = (Texture)(object)UpdateRadarTexture();
				UpdateStyle(CamsThings.radarTexture, 1f);
				SplitViewChecks.EnableSplitView("map");
				break;
			case "cams":
				ViewCommands.SetAnyCamsTrue();
				CamsThings.camsTexture = UpdateCamsTexture();
				UpdateStyle(CamsThings.camsTexture, 1f);
				break;
			case "minicams":
				ViewCommands.SetAnyCamsTrue();
				CamsThings.radarTexture = (Texture)(object)UpdateRadarTexture();
				CamsThings.camsTexture = UpdateCamsTexture();
				UpdateStyle(CamsThings.radarTexture, 1f, CamsThings.camsTexture, 0.7f);
				SplitViewChecks.EnableSplitView("minicams");
				break;
			case "minimap":
				ViewCommands.SetAnyCamsTrue();
				CamsThings.radarTexture = (Texture)(object)UpdateRadarTexture();
				CamsThings.camsTexture = UpdateCamsTexture();
				UpdateStyle(CamsThings.camsTexture, 1f, CamsThings.radarTexture, 0.7f);
				SplitViewChecks.EnableSplitView("minimap");
				break;
			case "overlay":
				ViewCommands.SetAnyCamsTrue();
				CamsThings.radarTexture = (Texture)(object)UpdateRadarTexture();
				CamsThings.camsTexture = UpdateCamsTexture();
				UpdateStyle(CamsThings.radarTexture, 1f, CamsThings.camsTexture, (float)ConfigSettings.OverlayOpacity.Value / 100f, isOverlay: true);
				SplitViewChecks.EnableSplitView("overlay");
				break;
			case "mirror":
				ViewCommands.SetAnyCamsTrue();
				UpdateStyle(GetMirrorTexture(), 1f);
				SplitViewChecks.EnableSplitView("mirror");
				break;
			default:
				Loggers.WARNING("Unexpected mode - [ " + mode + " ] OnUpdateCamsEvent");
				break;
			}
		}

		private static RenderTexture UpdateRadarTexture()
		{
			return GameStuff.TerminalMapRenderer.cam.targetTexture;
		}

		private static Texture UpdateCamsTexture()
		{
			Loggers.LogDebug("Updating Cams");
			if (MoreCamStuff.IsExternalCamsPresent())
			{
				return MoreCamStuff.GetPlayerCamsFromExternalMod(GameStuff.TerminalMapRenderer.targetTransformIndex);
			}
			return MoreCamStuff.UpdateCamsTarget(GameStuff.TerminalMapRenderer.targetTransformIndex);
		}

		private static void SetRawImageTransparency(RawImage rawImage, float Opacity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			Color color = ((Graphic)rawImage).color;
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(color.r, color.g, color.b, Opacity);
			((Graphic)rawImage).color = color2;
		}

		internal static void SetRawImageDimensions(RectTransform rectTrans, bool isFullScreen)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (isFullScreen)
			{
				rectTrans.sizeDelta = new Vector2(425f, 280f);
				rectTrans.anchoredPosition = new Vector2(0f, -25f);
			}
			else
			{
				rectTrans.sizeDelta = new Vector2(180f, 100f);
				rectTrans.anchoredPosition = new Vector2(123f, 90f);
			}
		}

		internal static Texture GetMirrorTexture()
		{
			if (Plugin.instance.OpenBodyCamsMod && ConfigSettings.CamsUseDetectedMods.Value)
			{
				Loggers.LogDebug("Sending to OBC for camera info");
				OpenBodyCamFuncs.OpenBodyCamsMirrorStatus(true, ConfigSettings.ObcResolutionMirror.Value, ConfigSettings.MirrorZoom.Value, ConfigSettings.Mirror2DStyle.Value, ref CamStuff.ObcCameraHolder);
				return OpenBodyCamFuncs.GetTexture(OpenBodyCamFuncs.TerminalMirrorCam);
			}
			return (Texture)(object)HomebrewMirror();
		}

		private static RenderTexture HomebrewMirror()
		{
			if ((Object)(object)ViewCommands.playerCam == (Object)null)
			{
				Loggers.LogInfo("Creating home-brew PlayerCam");
				ViewCommands.playerCam = CamStuff.HomebrewCam(ref ViewCommands.mycamTexture, ref CamStuff.MyCameraHolder);
			}
			CamStuff.HomebrewCameraState(true, ViewCommands.playerCam);
			CamStuff.CamInitMirror(CamStuff.MyCameraHolder, ViewCommands.playerCam, ConfigSettings.MirrorZoom.Value, ConfigSettings.Mirror2DStyle.Value);
			return ViewCommands.playerCam.targetTexture;
		}

		internal static void SetMirrorState(bool active)
		{
			if (Plugin.instance.OpenBodyCamsMod && ConfigSettings.CamsUseDetectedMods.Value)
			{
				OpenBodyCamFuncs.OpenBodyCamsMirrorStatus(active, ConfigSettings.ObcResolutionMirror.Value, ConfigSettings.MirrorZoom.Value, ConfigSettings.Mirror2DStyle.Value, ref CamStuff.ObcCameraHolder);
			}
			else
			{
				CamStuff.HomebrewCameraState(active, ViewCommands.playerCam);
			}
		}
	}
	public class CamsClass
	{
		public string Mode = "";

		public Texture radarTexture;

		public Texture camsTexture;
	}
	internal class CustomAutoSize : MonoBehaviour
	{
		internal RectTransform rect;

		internal TextMeshProUGUI textMesh;

		internal int cachedLength;

		internal float cachedFontSize;

		internal float fontSizeMultiplier = 1f;

		internal bool initialized;

		internal void SetValues(RectTransform rTrans, ref TextMeshProUGUI textComp, Vector2 anchor, Vector3 size)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			rect = rTrans;
			textMesh = textComp;
			rect.anchoredPosition = anchor;
			rect.sizeDelta = Vector2.op_Implicit(size);
			((Transform)((TMP_Text)textComp).rectTransform).SetParent((Transform)(object)rect);
			Init();
		}

		internal void Init()
		{
			//IL_002c: 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_0056: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			Loggers.LogDebug("Init CustomAutoSize!");
			if (!((Object)(object)textMesh == (Object)null) && !initialized)
			{
				((TMP_Text)textMesh).rectTransform.anchoredPosition = Vector2.zero;
				((TMP_Text)textMesh).rectTransform.anchorMin = Vector2.zero;
				((TMP_Text)textMesh).rectTransform.anchorMax = Vector2.one;
				((TMP_Text)textMesh).rectTransform.sizeDelta = Vector2.zero;
				((TMP_Text)textMesh).margin = new Vector4(-3f, 0f, 1f, 0f);
				((TMP_Text)textMesh).enableAutoSizing = true;
				initialized = true;
			}
		}

		internal void Update()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)textMesh == (Object)null) && ((TMP_Text)textMesh).text != null && initialized && !((Object)(object)rect == (Object)null) && cachedLength != ((TMP_Text)textMesh).text.Length)
			{
				Loggers.LogDebug("Updating rectTransform y value!");
				if (cachedFontSize != ((TMP_Text)textMesh).fontSize)
				{
					fontSizeMultiplier = ((TMP_Text)textMesh).fontSize / 18f;
					cachedFontSize = ((TMP_Text)textMesh).fontSize;
				}
				int num = Mathf.Clamp(((TMP_Text)textMesh).text.Length - 2, 0, 9);
				int num2 = 10 * num;
				int num3 = 200 - 5 * num;
				num3 *= -1;
				rect.sizeDelta = new Vector2((float)(32 + num2), rect.sizeDelta.y);
				rect.anchoredPosition = new Vector2((float)num3, rect.anchoredPosition.y);
				cachedLength = ((TMP_Text)textMesh).text.Length;
			}
		}
	}
	internal class MoreCamStuff
	{
		internal static List<string> excludedNames = new List<string>(35)
		{
			"Fov", "Show Cameras", "Show Map", "Show MiniMap", "Show MiniCams", "Show Overlay", "Show Mirror", "ViewInsideShipCam 1", "Radar Zoom", "Door Button",
			"Lightswitch", "Always-On Toggle", "Use Inverse Teleporter", "Use Teleporter", "Clear", "Danger", "Vitals", "Heal", "Loot", "Random Suit",
			"Clock toggle", "Previous", "SwitchRadarCamPlayer 1", "SwitchedCam", "switchDummy", "EnteredCode", "FlashedRadarBooster", "SendSignalTranslator", "GeneralError", "ParserError1",
			"ParserError2", "ParserError3", "PingedRadarBooster", "SendSignalTranslator", "FinishedRadarBooster"
		};

		internal static void ResetPluginInstanceBools()
		{
			Plugin.instance.isOnMiniMap = false;
			Plugin.instance.isOnMiniCams = false;
			Plugin.instance.isOnMap = false;
			Plugin.instance.isOnCamera = false;
			Plugin.instance.isOnMirror = false;
			Plugi