Decompiled source of GeneralImprovements v1.2.8

GeneralImprovements.dll

Decompiled 2 months 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.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using GeneralImprovements.API;
using GeneralImprovements.Assets;
using GeneralImprovements.Items;
using GeneralImprovements.NetcodePatcher;
using GeneralImprovements.Patches;
using GeneralImprovements.Utilities;
using HarmonyLib;
using Mono.Cecil;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GeneralImprovements")]
[assembly: AssemblyConfiguration("Deploy")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+614330b144d7e27e275c97836b7f9928e1f6c161")]
[assembly: AssemblyProduct("GeneralImprovements")]
[assembly: AssemblyTitle("GeneralImprovements")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace GeneralImprovements
{
	public class Enums
	{
		public enum eAutoLaunchOption
		{
			NONE,
			ONLINE,
			LAN
		}

		public enum eShowHiddenMoons
		{
			Never,
			AfterDiscovery,
			Always
		}

		public enum eMaskedEntityCopyLook
		{
			None,
			Suit,
			SuitAndCosmetics
		}

		public enum eSaveFurniturePlacement
		{
			None,
			StartingFurniture,
			All
		}

		public enum eMonitorNames
		{
			None,
			ProfitQuota,
			Deadline,
			ShipScrap,
			ScrapLeft,
			Time,
			Weather,
			FancyWeather,
			Sales,
			Credits,
			DoorPower,
			TotalDays,
			TotalQuotas,
			TotalDeaths,
			DaysSinceDeath,
			InternalCam,
			ExternalCam
		}

		public enum eValidKeys
		{
			None,
			Space,
			Enter,
			Tab,
			Backquote,
			Quote,
			Semicolon,
			Comma,
			Period,
			Slash,
			Backslash,
			LeftBracket,
			RightBracket,
			Minus,
			Equals,
			A,
			B,
			C,
			D,
			E,
			F,
			G,
			H,
			I,
			J,
			K,
			L,
			M,
			N,
			O,
			P,
			Q,
			R,
			S,
			T,
			U,
			V,
			W,
			X,
			Y,
			Z,
			Digit1,
			Digit2,
			Digit3,
			Digit4,
			Digit5,
			Digit6,
			Digit7,
			Digit8,
			Digit9,
			Digit0,
			LeftShift,
			RightShift,
			LeftAlt,
			AltGr,
			LeftCtrl,
			RightCtrl,
			LeftWindows,
			RightCommand,
			ContextMenu,
			Escape,
			LeftArrow,
			RightArrow,
			UpArrow,
			DownArrow,
			Backspace,
			PageDown,
			PageUp,
			Home,
			End,
			Insert,
			Delete,
			CapsLock,
			NumLock,
			PrintScreen,
			ScrollLock,
			Pause,
			NumpadEnter,
			NumpadDivide,
			NumpadMultiply,
			NumpadPlus,
			NumpadMinus,
			NumpadPeriod,
			NumpadEquals,
			Numpad0,
			Numpad1,
			Numpad2,
			Numpad3,
			Numpad4,
			Numpad5,
			Numpad6,
			Numpad7,
			Numpad8,
			Numpad9,
			F1,
			F2,
			F3,
			F4,
			F5,
			F6,
			F7,
			F8,
			F9,
			F10,
			F11,
			F12,
			MouseLeft,
			MouseRight,
			MouseMiddle,
			MouseBackButton,
			MouseForwardButton
		}

		public enum eItemsToKeep
		{
			None,
			Held,
			NonScrap,
			All
		}

		public static ButtonControl GetMouseButtonMapping(eValidKeys mouseButton)
		{
			if (1 == 0)
			{
			}
			ButtonControl result = (ButtonControl)(mouseButton switch
			{
				eValidKeys.MouseLeft => Mouse.current.leftButton, 
				eValidKeys.MouseRight => Mouse.current.rightButton, 
				eValidKeys.MouseMiddle => Mouse.current.middleButton, 
				eValidKeys.MouseBackButton => Mouse.current.backButton, 
				eValidKeys.MouseForwardButton => Mouse.current.forwardButton, 
				_ => throw new NotImplementedException(), 
			});
			if (1 == 0)
			{
			}
			return result;
		}
	}
	internal static class Metadata
	{
		public const string GUID = "ShaosilGaming.GeneralImprovements";

		public const string PLUGIN_NAME = "GeneralImprovements";

		public const string VERSION = "1.2.8";
	}
	[BepInPlugin("ShaosilGaming.GeneralImprovements", "GeneralImprovements", "1.2.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public class InternalConfigDef
		{
			public readonly string Section;

			public readonly string Description;

			public readonly string Name;

			public readonly string Value;

			public readonly string DefaultValue;

			public InternalConfigDef(string section, string description, string name, string value, string defaultValue)
			{
				Section = section;
				Description = description;
				Name = name;
				Value = value;
				DefaultValue = defaultValue;
			}
		}

		private const string EnemiesSection = "Enemies";

		private const string ExtraMonitorsSection = "ExtraMonitors";

		private const string FixesSection = "Fixes";

		private const string GameLaunchSection = "GameLaunch";

		private const string InventorySection = "Inventory";

		private const string MechanicsSection = "Mechanics";

		private const string ScannerSection = "Scanner";

		private const string ShipSection = "Ship";

		private const string TeleportersSection = "Teleporters";

		private const string TerminalSection = "Terminal";

		private const string ToolsSection = "Tools";

		private const string UISection = "UI";

		public static ManualLogSource MLS { get; private set; }

		public static ConfigEntry<bool> MaskedEntitiesWearMasks { get; private set; }

		public static ConfigEntry<bool> MaskedEntitiesShowPlayerNames { get; private set; }

		public static ConfigEntry<Enums.eMaskedEntityCopyLook> MaskedEntitiesCopyPlayerLooks { get; private set; }

		public static ConfigEntry<bool> MaskedEntitiesSpinOnRadar { get; private set; }

		public static ConfigEntry<bool> MaskedEntitiesReachTowardsPlayer { get; private set; }

		public static ConfigEntry<bool> UseBetterMonitors { get; private set; }

		public static ConfigEntry<bool> AddMoreBetterMonitors { get; private set; }

		public static ConfigEntry<bool> SyncMonitorsFromOtherHost { get; private set; }

		public static ConfigEntry<bool> ShowBlueMonitorBackground { get; private set; }

		public static ConfigEntry<string> MonitorBackgroundColor { get; private set; }

		public static Color MonitorBackgroundColorVal { get; private set; }

		public static ConfigEntry<string> MonitorTextColor { get; private set; }

		public static Color MonitorTextColorVal { get; private set; }

		public static ConfigEntry<bool> ShowBackgroundOnAllScreens { get; private set; }

		public static ConfigEntry<Enums.eMonitorNames>[] ShipMonitorAssignments { get; private set; }

		public static ConfigEntry<bool> SyncExtraMonitorsPower { get; private set; }

		public static ConfigEntry<bool> CenterAlignMonitorText { get; private set; }

		public static ConfigEntry<int> ShipInternalCamSizeMultiplier { get; private set; }

		public static ConfigEntry<int> ShipInternalCamFPS { get; private set; }

		public static ConfigEntry<int> ShipExternalCamSizeMultiplier { get; private set; }

		public static ConfigEntry<int> ShipExternalCamFPS { get; private set; }

		public static ConfigEntry<bool> AlwaysRenderMonitors { get; private set; }

		public static ConfigEntry<bool> FixInternalFireExits { get; private set; }

		public static ConfigEntry<bool> FixItemsFallingThrough { get; private set; }

		public static ConfigEntry<bool> FixItemsLoadingSameRotation { get; private set; }

		public static ConfigEntry<bool> AllowLookDownMore { get; private set; }

		public static ConfigEntry<int> DropShipItemLimit { get; private set; }

		public static ConfigEntry<int> SellCounterItemLimit { get; private set; }

		public static ConfigEntry<bool> SkipStartupScreen { get; private set; }

		public static ConfigEntry<Enums.eAutoLaunchOption> AutoSelectLaunchMode { get; private set; }

		public static ConfigEntry<bool> AlwaysShowNews { get; private set; }

		public static ConfigEntry<bool> AllowPreGameLeverPullAsClient { get; private set; }

		public static ConfigEntry<int> MenuMusicVolume { get; private set; }

		public static ConfigEntry<bool> PickupInOrder { get; private set; }

		public static ConfigEntry<bool> RearrangeOnDrop { get; private set; }

		public static ConfigEntry<bool> TwoHandedInSlotOne { get; private set; }

		public static ConfigEntry<float> ScrollDelay { get; private set; }

		public static ConfigEntry<int> StartingMoneyPerPlayer { get; private set; }

		public static int StartingMoneyPerPlayerVal => Math.Clamp(StartingMoneyPerPlayer.Value, -1, 10000);

		public static ConfigEntry<int> MinimumStartingMoney { get; private set; }

		public static int MinimumStartingMoneyVal => Math.Clamp(MinimumStartingMoney.Value, StartingMoneyPerPlayerVal, 10000);

		public static ConfigEntry<bool> AllowQuotaRollover { get; private set; }

		public static ConfigEntry<bool> AllowOvertimeBonus { get; private set; }

		public static ConfigEntry<bool> AddHealthRechargeStation { get; private set; }

		public static ConfigEntry<bool> ScanCommandUsesExactAmount { get; private set; }

		public static ConfigEntry<bool> UnlockDoorsFromInventory { get; private set; }

		public static ConfigEntry<bool> KeysHaveInfiniteUses { get; private set; }

		public static ConfigEntry<bool> DestroyKeysAfterOrbiting { get; private set; }

		public static ConfigEntry<bool> SavePlayerSuits { get; private set; }

		public static ConfigEntry<bool> FixPersonalScanner { get; private set; }

		public static ConfigEntry<bool> ScanPlayers { get; private set; }

		public static ConfigEntry<bool> ScanHeldPlayerItems { get; private set; }

		public static ConfigEntry<bool> ShowDropshipOnScanner { get; private set; }

		public static ConfigEntry<bool> ShowDoorsOnScanner { get; private set; }

		public static ConfigEntry<bool> HideClipboardAndStickyNote { get; private set; }

		public static ConfigEntry<bool> HideShipCabinetDoors { get; private set; }

		public static ConfigEntry<int> SnapObjectsByDegrees { get; private set; }

		public static ConfigEntry<Enums.eValidKeys> FreeRotateKey { get; private set; }

		public static ConfigEntry<Enums.eValidKeys> CounterClockwiseKey { get; private set; }

		public static ConfigEntry<bool> ShipPlaceablesCollide { get; private set; }

		public static ConfigEntry<Enums.eSaveFurniturePlacement> SaveShipFurniturePlaces { get; private set; }

		public static ConfigEntry<bool> ShipMapCamDueNorth { get; private set; }

		public static ConfigEntry<bool> SpeakerPlaysIntroVoice { get; private set; }

		public static ConfigEntry<bool> LightSwitchScanNode { get; private set; }

		public static ConfigEntry<bool> DisableShipCamPostProcessing { get; private set; }

		public static ConfigEntry<int> RegularTeleporterCooldown { get; private set; }

		public static ConfigEntry<int> InverseTeleporterCooldown { get; private set; }

		public static ConfigEntry<Enums.eItemsToKeep> KeepItemsDuringTeleport { get; private set; }

		public static ConfigEntry<Enums.eItemsToKeep> KeepItemsDuringInverse { get; private set; }

		public static ConfigEntry<int> TerminalHistoryItemCount { get; private set; }

		public static ConfigEntry<bool> TerminalFastCamSwitch { get; private set; }

		public static ConfigEntry<bool> LockCameraAtTerminal { get; private set; }

		public static ConfigEntry<bool> ShowMoonPricesInTerminal { get; private set; }

		public static ConfigEntry<bool> ShowBlanksDuringViewMonitor { get; private set; }

		public static ConfigEntry<Enums.eShowHiddenMoons> ShowHiddenMoonsInCatalog { get; private set; }

		public static ConfigEntry<bool> OnlyAllowOneActiveFlashlight { get; private set; }

		public static ConfigEntry<bool> TreatLasersAsFlashlights { get; private set; }

		public static ConfigEntry<Enums.eValidKeys> FlashlightToggleShortcut { get; private set; }

		public static ConfigEntry<string> ScannableTools { get; private set; }

		public static List<Type> ScannableToolVals { get; private set; } = new List<Type>();


		public static ConfigEntry<bool> ToolsDoNotAttractLightning { get; private set; }

		public static ConfigEntry<bool> AutoChargeOnOrbit { get; private set; }

		public static ConfigEntry<bool> ShowUIReticle { get; private set; }

		public static ConfigEntry<bool> HideEmptySubtextOfScanNodes { get; private set; }

		public static ConfigEntry<bool> ShowHitPoints { get; private set; }

		public static ConfigEntry<bool> ShowLightningWarnings { get; private set; }

		public static ConfigEntry<bool> HidePlayerNames { get; private set; }

		public static ConfigEntry<bool> TwentyFourHourClock { get; private set; }

		public static ConfigEntry<bool> AlwaysShowClock { get; private set; }

		public static ConfigEntry<bool> DisplayKgInsteadOfLb { get; private set; }

		private void Awake()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			MLS = ((BaseUnityPlugin)this).Logger;
			OtherModHelper.Initialize();
			AssetBundleHelper.Initialize();
			BindConfigs();
			MigrateOldConfigValues();
			MLS.LogInfo((object)"Configuration Initialized.");
			Harmony val = new Harmony("ShaosilGaming.GeneralImprovements");
			val.PatchAll(typeof(AutoParentToShipPatch));
			MLS.LogInfo((object)"AutoParentToShip patched.");
			val.PatchAll(typeof(DepositItemsDeskPatch));
			MLS.LogInfo((object)"DepositItemsDesk patched.");
			val.PatchAll(typeof(DoorLockPatch));
			MLS.LogInfo((object)"DoorLock patched.");
			val.PatchAll(typeof(EntranceTeleportPatch));
			MLS.LogInfo((object)"EntranceTeleport patched.");
			if (!OtherModHelper.FlashlightFixActive)
			{
				val.PatchAll(typeof(FlashlightItemPatch));
				MLS.LogInfo((object)"FlashlightItem patched.");
			}
			else
			{
				MLS.LogWarning((object)"Outdated version of FlashlightFix detected - please update your mods.");
			}
			val.PatchAll(typeof(GameNetworkManagerPatch));
			MLS.LogInfo((object)"GameNetworkManager patched.");
			val.PatchAll(typeof(GrabbableObjectsPatch));
			MLS.LogInfo((object)"GrabbableObjects patched.");
			val.PatchAll(typeof(HangarShipDoorPatch));
			MLS.LogInfo((object)"HangarShipDoor patched.");
			val.PatchAll(typeof(HUDManagerPatch));
			MLS.LogInfo((object)"HUDManager patched.");
			val.PatchAll(typeof(ItemDropshipPatch));
			MLS.LogInfo((object)"ItemDropship patched.");
			val.PatchAll(typeof(LandminePatch));
			MLS.LogInfo((object)"Landmine patched.");
			val.PatchAll(typeof(ManualCameraRendererPatch));
			MLS.LogInfo((object)"ManualCameraRenderer patched.");
			val.PatchAll(typeof(MaskedPlayerEnemyPatch));
			MLS.LogInfo((object)"MaskedPlayerEnemy patched.");
			val.PatchAll(typeof(MenuPatches));
			MLS.LogInfo((object)"Menus patched.");
			val.PatchAll(typeof(PlayerControllerBPatch));
			MLS.LogInfo((object)"PlayerControllerB patched.");
			val.PatchAll(typeof(RoundManagerPatch));
			MLS.LogInfo((object)"RoundManager patched.");
			val.PatchAll(typeof(ShipBuildModeManagerPatch));
			MLS.LogInfo((object)"ShipBuildModeManager patched.");
			val.PatchAll(typeof(ShipTeleporterPatch));
			MLS.LogInfo((object)"ShipTeleporter patched.");
			val.PatchAll(typeof(SprayPaintItemPatch));
			MLS.LogInfo((object)"SprayPaintItem patched.");
			val.PatchAll(typeof(StartMatchLeverPatch));
			MLS.LogInfo((object)"StartMatchLever patched.");
			val.PatchAll(typeof(StartOfRoundPatch));
			MLS.LogInfo((object)"StartOfRound patched.");
			val.PatchAll(typeof(StormyWeatherPatch));
			MLS.LogInfo((object)"StormyWeather patched.");
			val.PatchAll(typeof(TerminalAccessibleObjectPatch));
			MLS.LogInfo((object)"TerminalAccessibleObject patched.");
			val.PatchAll(typeof(TerminalPatch));
			MLS.LogInfo((object)"Terminal patched.");
			val.PatchAll(typeof(TimeOfDayPatch));
			MLS.LogInfo((object)"TimeOfDay patched.");
			val.PatchAll(typeof(UnlockableSuitPatch));
			MLS.LogInfo((object)"UnlockableSuit patched.");
			GameNetworkManagerPatch.PatchNetcode();
			MLS.LogInfo((object)"GeneralImprovements v1.2.8 fully loaded.");
		}

		public void BindConfigs()
		{
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Expected O, but got Unknown
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Expected O, but got Unknown
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Expected O, but got Unknown
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Expected O, but got Unknown
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Expected O, but got Unknown
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Expected O, but got Unknown
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Expected O, but got Unknown
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Expected O, but got Unknown
			//IL_09a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09af: Expected O, but got Unknown
			//IL_0ae6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af0: Expected O, but got Unknown
			//IL_0b20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b2a: Expected O, but got Unknown
			//IL_0b96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba0: Expected O, but got Unknown
			//IL_0eed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2a: Unknown result type (might be due to invalid IL or missing references)
			int[] array = (from n in Enumerable.Range(0, 24)
				select n * 15 into n
				where n == 0 || 360 % n == 0
				select n).ToArray();
			List<Type> list = new List<Type>();
			list.Add(typeof(BoomboxItem));
			list.Add(typeof(ExtensionLadderItem));
			list.Add(typeof(FlashlightItem));
			list.Add(typeof(JetpackItem));
			list.Add(typeof(LockPicker));
			list.Add(typeof(RadarBoosterItem));
			list.Add(typeof(KnifeItem));
			list.Add(typeof(Shovel));
			list.Add(typeof(SprayPaintItem));
			list.Add(typeof(StunGrenadeItem));
			list.Add(typeof(TetraChemicalItem));
			list.Add(typeof(WalkieTalkie));
			list.Add(typeof(PatcherTool));
			List<Type> list2 = list;
			string text = string.Join(", ", new string[1] { "All" }.Concat(list2.Select((Type t) => t.Name)));
			MaskedEntitiesWearMasks = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "MaskedEntitiesWearMasks", true, "If set to true, masked entities will wear their default masks.");
			MaskedEntitiesShowPlayerNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "MaskedEntitiesShowPlayerNames", false, "If set to true, masked entities will display their targeted player's name above their head, as well as be scannable if ScanPlayers = True.");
			MaskedEntitiesCopyPlayerLooks = ((BaseUnityPlugin)this).Config.Bind<Enums.eMaskedEntityCopyLook>("Enemies", "MaskedEntitiesCopyPlayerLooks", Enums.eMaskedEntityCopyLook.None, "How much masked entities should look like a targeted player.");
			MaskedEntitiesSpinOnRadar = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "MaskedEntitiesSpinOnRadar", true, "If set to true, masked entities' radar dots will spin randomly, slightly giving away their identity.");
			MaskedEntitiesReachTowardsPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Enemies", "MaskedEntitiesReachTowardsPlayer", true, "If set to true, masked entities will reach towards the player they are chasing in a zombie-like way.");
			UseBetterMonitors = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "UseBetterMonitors", false, "If set to true, upgrades the vanilla monitors with integrated and more customizable overlays.");
			AddMoreBetterMonitors = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "AddMoreBetterMonitors", true, "If set to true and paired with UseBetterMonitors (required), adds 4 more small and 1 large monitor to the left of the main ship monitor group.");
			SyncMonitorsFromOtherHost = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "SyncMonitorsFromOtherHost", false, "If set to true, all monitor placements will be synced from the host when joining a game, if the host is also using this mod. Settings such as color, FPS, etc will not be synced.");
			ShowBlueMonitorBackground = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "ShowBlueMonitorBackground", true, "If set to true and NOT using UseBetterMonitors, keeps the vanilla blue backgrounds on the extra monitors. Set to false to hide.");
			MonitorBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<string>("ExtraMonitors", "MonitorBackgroundColor", "160959", "The hex color code of what the backgrounds of the monitors should be. A recommended value close to black is 050505.");
			MonitorTextColor = ((BaseUnityPlugin)this).Config.Bind<string>("ExtraMonitors", "MonitorTextColor", "00FF2C", "The hex color code of what the text on the monitors should be.");
			ShowBackgroundOnAllScreens = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "ShowBackgroundOnAllScreens", false, "If set to true, will show the MonitorBackgroundColor on ALL monitors when they are on, not just used ones.");
			ShipMonitorAssignments = new ConfigEntry<Enums.eMonitorNames>[14];
			for (int i = 0; i < ShipMonitorAssignments.Length; i++)
			{
				if (1 == 0)
				{
				}
				Enums.eMonitorNames eMonitorNames = i switch
				{
					4 => Enums.eMonitorNames.ProfitQuota, 
					5 => Enums.eMonitorNames.Deadline, 
					11 => Enums.eMonitorNames.InternalCam, 
					14 => Enums.eMonitorNames.ExternalCam, 
					_ => Enums.eMonitorNames.None, 
				};
				if (1 == 0)
				{
				}
				Enums.eMonitorNames eMonitorNames2 = eMonitorNames;
				ShipMonitorAssignments[i] = ((BaseUnityPlugin)this).Config.Bind<Enums.eMonitorNames>("ExtraMonitors", $"ShipMonitor{i + 1}", eMonitorNames2, $"What to display on the ship monitor at position {i + 1}, if anything.");
			}
			SyncExtraMonitorsPower = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "SyncExtraMonitorsPower", true, "If set to true, The smaller monitors above the map screen will turn off and on when the map screen power is toggled.");
			CenterAlignMonitorText = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "CenterAlignMonitorText", true, "If set to true, all small monitors in the ship will have their text center aligned, instead of left.");
			ShipInternalCamSizeMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("ExtraMonitors", "ShipInternalCamSizeMultiplier", 1, new ConfigDescription("How many times to double the internal ship cam's resolution.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			ShipInternalCamFPS = ((BaseUnityPlugin)this).Config.Bind<int>("ExtraMonitors", "ShipInternalCamFPS", 0, new ConfigDescription("Limits the FPS of the internal ship cam for performance. 0 = Unrestricted.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 30), Array.Empty<object>()));
			ShipExternalCamSizeMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("ExtraMonitors", "ShipExternalCamSizeMultiplier", 1, new ConfigDescription("How many times to double the external ship cam's resolution.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			ShipExternalCamFPS = ((BaseUnityPlugin)this).Config.Bind<int>("ExtraMonitors", "ShipExternalCamFPS", 0, new ConfigDescription("Limits the FPS of the external ship cam for performance. 0 = Unrestricted.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 30), Array.Empty<object>()));
			AlwaysRenderMonitors = ((BaseUnityPlugin)this).Config.Bind<bool>("ExtraMonitors", "AlwaysRenderMonitors", false, "If using better monitors and set to true, text-based monitors will render updates even when you are not in the ship. May slightly affect performance.");
			FixInternalFireExits = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "FixInternalFireExits", true, "If set to true, the player will face the interior of the facility when entering through a fire entrance.");
			FixItemsFallingThrough = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "FixItemsFallingThrough", true, "Fixes items falling through furniture on the ship when loading the game.");
			FixItemsLoadingSameRotation = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "FixItemsLoadingSameRotation", true, "Fixes items all facing the same way when loading a save file. Now they will store their rotations as well.");
			AllowLookDownMore = ((BaseUnityPlugin)this).Config.Bind<bool>("Fixes", "AllowLookDownMore", true, "If set to true, you will be able to look down at a steeper angle than vanilla.");
			DropShipItemLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Fixes", "DropShipItemLimit", 24, new ConfigDescription("Sets the max amount of items a single dropship delivery will allow. Vanilla = 12.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(12, 100), Array.Empty<object>()));
			SellCounterItemLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Fixes", "SellCounterItemLimit", 24, new ConfigDescription("Sets the max amount of items the company selling counter will hold at one time. Vanilla = 12.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(12, 100), Array.Empty<object>()));
			SkipStartupScreen = ((BaseUnityPlugin)this).Config.Bind<bool>("GameLaunch", "SkipStartupScreen", true, "Skips the main menu loading screen bootup animation.");
			AutoSelectLaunchMode = ((BaseUnityPlugin)this).Config.Bind<Enums.eAutoLaunchOption>("GameLaunch", "AutoSelectLaunchMode", Enums.eAutoLaunchOption.NONE, "If set to 'ONLINE' or 'LAN', will automatically launch the correct mode, saving you from having to click the menu option when the game loads.");
			AlwaysShowNews = ((BaseUnityPlugin)this).Config.Bind<bool>("GameLaunch", "AlwaysShowNews", false, "If set to true, will always display the news popup when starting the game.");
			AllowPreGameLeverPullAsClient = ((BaseUnityPlugin)this).Config.Bind<bool>("GameLaunch", "AllowPreGameLeverPullAsClient", true, "If set to true, you will be able to pull the ship lever to start the game as a connected player.");
			MenuMusicVolume = ((BaseUnityPlugin)this).Config.Bind<int>("GameLaunch", "MenuMusicVolume", 100, new ConfigDescription("Controls the volume of the menu music, from 0-100.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			PickupInOrder = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "PickupInOrder", false, "When picking up items, will always put them in left - right order.");
			RearrangeOnDrop = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "RearrangeOnDrop", false, "When dropping items, will rearrange other inventory items to ensure slots are filled left - right.");
			TwoHandedInSlotOne = ((BaseUnityPlugin)this).Config.Bind<bool>("Inventory", "TwoHandedInSlotOne", false, "When picking up a two handed item, it will always place it in slot 1 and shift things to the right if needed. Makes selling quicker when paired with RearrangeOnDrop.");
			ScrollDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Inventory", "ScrollDelay", 0.1f, new ConfigDescription("The minimum time you must wait to scroll to another item in your inventory. Vanilla: 0.3.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 0.3f), Array.Empty<object>()));
			StartingMoneyPerPlayer = ((BaseUnityPlugin)this).Config.Bind<int>("Mechanics", "StartingMoneyPerPlayer", -1, "[Host Only] How much starting money the group gets per player. Set to -1 to disable. Adjusts money as players join and leave, until the game starts. Internally capped at 10k.");
			MinimumStartingMoney = ((BaseUnityPlugin)this).Config.Bind<int>("Mechanics", "MinimumStartingMoney", 30, "[Host Only] When paired with StartingMoneyPerPlayer, will ensure a group always starts with at least this much money. Must be at least the value of StartingMoneyPerPlayer. Internally capped at 10k.");
			AllowQuotaRollover = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "AllowQuotaRollover", false, "[Host Required] If set to true, will keep the surplus money remaining after selling things to the company, and roll it over to the next quota. If clients do not set this, they will see visual desyncs.");
			AllowOvertimeBonus = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "AllowOvertimeBonus", true, "[Host Only] If set to false, will prevent the vanilla overtime bonus from being applied after the end of a quota.");
			AddHealthRechargeStation = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "AddHealthRechargeStation", false, "[Host Only] If set to true, a medical charging station will be above the ship's battery charger, and can be used to heal to full. **WARNING:** THIS WILL PREVENT YOU FROM CONNECTING TO ANY OTHER PLAYERS THAT DO NOT ALSO HAVE IT ENABLED!");
			ScanCommandUsesExactAmount = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "ScanCommandUsesExactAmount", false, "If set to true, the terminal's scan command (and ScrapLeft monitor) will use display the exact scrap value remaining instead of approximate.");
			UnlockDoorsFromInventory = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "UnlockDoorsFromInventory", false, "If set to true, keys in your inventory do not have to be held when unlocking facility doors.");
			KeysHaveInfiniteUses = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "KeysHaveInfiniteUses", false, "If set to true, keys will not despawn when they are used.");
			DestroyKeysAfterOrbiting = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "DestroyKeysAfterOrbiting", false, "If set to true, all keys in YOUR inventory (and IF HOSTING, the ship) will be destroyed after orbiting. Works well to nerf KeysHaveInfiniteUses. Players who do not have this enabled will keep keys currently in their inventory.");
			SavePlayerSuits = ((BaseUnityPlugin)this).Config.Bind<bool>("Mechanics", "SavePlayerSuits", true, "If set to true, the host will keep track of every player's last used suit, and will persist between loads and ship resets for each save file. Only works in Online mode.");
			FixPersonalScanner = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "FixPersonalScanner", false, "If set to true, will tweak the behavior of the scan action and more reliably ping items closer to you, and the ship/main entrance.");
			ScanPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "ScanPlayers", false, "If set to true, players (and sneaky masked entities) will be scannable.");
			ScanHeldPlayerItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "ScanHeldPlayerItems", false, "If this and FixPersonalScanner are set to true, the scanner will also ping items in other players' hands.");
			ShowDropshipOnScanner = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "ShowDropshipOnScanner", false, "If set to true, the item drop ship will be scannable.");
			ShowDoorsOnScanner = ((BaseUnityPlugin)this).Config.Bind<bool>("Scanner", "ShowDoorsOnScanner", false, "If set to true, all fire entrances and facility exits will be scannable. Compatible with mimics mod (they show up as an exit as well).");
			HideClipboardAndStickyNote = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "HideClipboardAndStickyNote", false, "If set to true, the game will not show the clipboard or sticky note when the game loads.");
			HideShipCabinetDoors = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "HideShipCabinetDoors", false, "If set to true, the storage shelves in the ship will not have doors.");
			SnapObjectsByDegrees = ((BaseUnityPlugin)this).Config.Bind<int>("Ship", "SnapObjectsByDegrees", 45, new ConfigDescription("Build mode will switch to snap turning (press instead of hold) by this many degrees at a time. Setting it to 0 uses vanilla behavior.", (AcceptableValueBase)(object)new AcceptableValueList<int>(array), Array.Empty<object>()));
			FreeRotateKey = ((BaseUnityPlugin)this).Config.Bind<Enums.eValidKeys>("Ship", "FreeRotateKey", Enums.eValidKeys.LeftAlt, "If SnapObjectsByDegrees > 0, configures which modifer key activates free rotation.");
			CounterClockwiseKey = ((BaseUnityPlugin)this).Config.Bind<Enums.eValidKeys>("Ship", "CounterClockwiseKey", Enums.eValidKeys.LeftShift, "If SnapObjectsByDegrees > 0, configures which modifier key spins it CCW.");
			ShipPlaceablesCollide = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "ShipPlaceablesCollide", true, "If set to true, placeable ship objects will check for collisions with each other during placement.");
			SaveShipFurniturePlaces = ((BaseUnityPlugin)this).Config.Bind<Enums.eSaveFurniturePlacement>("Ship", "SaveShipFurniturePlaces", Enums.eSaveFurniturePlacement.StartingFurniture, "Determines what ship furniture positions and storage states will not be reset after being fired.");
			ShipMapCamDueNorth = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "ShipMapCamDueNorth", false, "If set to true, the ship's map camera will rotate so that it faces north evenly, instead of showing everything at an angle.");
			SpeakerPlaysIntroVoice = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "SpeakerPlaysIntroVoice", true, "If set to true, the ship's speaker will play the introductory welcome audio on the first day.");
			LightSwitchScanNode = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "LightSwitchScanNode", true, "If set to true, the light switch will have a scan node attached.");
			DisableShipCamPostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("Ship", "DisableShipCamPostProcessing", false, "If set to true, the internal and external ship cameras will no longer use post processing. This may improve performance with higher resolution camera settings.");
			RegularTeleporterCooldown = ((BaseUnityPlugin)this).Config.Bind<int>("Teleporters", "RegularTeleporterCooldown", 10, new ConfigDescription("How many seconds to wait in between button presses for the REGULAR teleporter. Vanilla = 10. If using the vanilla value, the teleporter code will not be modified.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 300), Array.Empty<object>()));
			InverseTeleporterCooldown = ((BaseUnityPlugin)this).Config.Bind<int>("Teleporters", "InverseTeleporterCooldown", 210, new ConfigDescription("How many seconds to wait in between button presses for the INVERSE teleporter. Vanilla = 210. If using the vanilla value, the teleporter code will not be modified.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 300), Array.Empty<object>()));
			KeepItemsDuringTeleport = ((BaseUnityPlugin)this).Config.Bind<Enums.eItemsToKeep>("Teleporters", "KeepItemsDuringTeleport", Enums.eItemsToKeep.None, "Whether to keep Held, Non Scrap, or All items in inventory when using the regular teleporter. *WARNING:* THIS WILL CAUSE INVENTORY DESYNCS IF OTHER PLAYERS DO NOT SHARE YOUR SETTING!");
			KeepItemsDuringInverse = ((BaseUnityPlugin)this).Config.Bind<Enums.eItemsToKeep>("Teleporters", "KeepItemsDuringInverse", Enums.eItemsToKeep.None, "Whether to keep Held, Non Scrap, or All items in inventory when using the inverse teleporter. *WARNING:* THIS WILL CAUSE INVENTORY DESYNCS IF OTHER PLAYERS DO NOT SHARE YOUR SETTING!");
			TerminalHistoryItemCount = ((BaseUnityPlugin)this).Config.Bind<int>("Terminal", "TerminalHistoryItemCount", 20, new ConfigDescription("How many items to keep in your terminal's command history. Previous terminal commands may be navigated by using the up/down arrow keys.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			TerminalFastCamSwitch = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "TerminalFastCamSwitch", true, "If set to true, will allow use of the left/right arrow keys to quickly cycle through radar cameras while using the terminal.");
			LockCameraAtTerminal = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "LockCameraAtTerminal", true, "If set to true, the camera will no longer move around when moving your mouse/controller while at the terminal.");
			ShowMoonPricesInTerminal = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "ShowMoonPricesInTerminal", false, "If set to true, the moons will also display the cost to fly to them next to their name and weather.");
			ShowBlanksDuringViewMonitor = ((BaseUnityPlugin)this).Config.Bind<bool>("Terminal", "ShowBlanksDuringViewMonitor", true, "If set to true, typing commands while View Monitor is active requires you to scroll down to see the result.");
			ShowHiddenMoonsInCatalog = ((BaseUnityPlugin)this).Config.Bind<Enums.eShowHiddenMoons>("Terminal", "ShowHiddenMoonsInCatalog", Enums.eShowHiddenMoons.AfterDiscovery, "When to show any hidden moons in the terminal's moon catalog. AfterDiscovery is per save file.");
			OnlyAllowOneActiveFlashlight = ((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "OnlyAllowOneActiveFlashlight", true, "When turning on any flashlight, will turn off any others in your inventory that are still active.");
			TreatLasersAsFlashlights = ((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "TreatLasersAsFlashlights", false, "If set to true, laser pointers will be like flashlights and automatically toggle off and on when switching to them, etc.");
			FlashlightToggleShortcut = ((BaseUnityPlugin)this).Config.Bind<Enums.eValidKeys>("Tools", "FlashlightToggleShortcut", Enums.eValidKeys.None, "A shortcut key to allow toggling a flashlight at any time.");
			ScannableTools = ((BaseUnityPlugin)this).Config.Bind<string>("Tools", "ScannableTools", string.Empty, "A comma separated list of which tools, if any, should be scannable. Accepted values: " + text);
			ToolsDoNotAttractLightning = ((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "ToolsDoNotAttractLightning", false, "[Host Only] If set to true, all useful tools (ladders, jetpacks, keys, radar boosters, shovels & signs, tzp inhalant, knives, and zap guns) will no longer attract lighning.");
			AutoChargeOnOrbit = ((BaseUnityPlugin)this).Config.Bind<bool>("Tools", "AutoChargeOnOrbit", false, "If set to true, all owned* battery-using items will be automatically charged every time the ship goes into orbit. *You are considered to 'own' an item if you are the last person to have held it.");
			HideEmptySubtextOfScanNodes = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "HideEmptySubtextOfScanNodes", true, "If set to true, will hide the subtext section of scannables that do not have subtext or scrap value.");
			ShowUIReticle = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowUIReticle", false, "If set to true, the HUD will display a small dot so you can see exactly where you are pointing at all times.");
			ShowHitPoints = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowHitPoints", true, "If set to true, the HUD will display your current remaining hitpoints.");
			ShowLightningWarnings = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "ShowLightningWarnings", true, "If set to true, the inventory slots will flash electrically when an item in the slot is being targeted by lightning.");
			HidePlayerNames = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "HidePlayerNames", false, "If set to true, player names will no longer show above players.");
			TwentyFourHourClock = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "TwentyFourHourClock", false, "If set to true, the clock will be 24 hours instead of 12.");
			AlwaysShowClock = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "AlwaysShowClock", false, "If set to true, the clock will always be displayed on the HUD when landed on a moon.");
			DisplayKgInsteadOfLb = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "DisplayKgInsteadOfLb", false, "If set to true, your carry weight will be converted from lb to kg.");
			string text2 = Regex.Match(MonitorBackgroundColor.Value, "([a-fA-F0-9]{6})").Groups[1].Value.ToUpper();
			string text3 = Regex.Match(MonitorTextColor.Value, "([a-fA-F0-9]{6})").Groups[1].Value.ToUpper();
			if (text2.Length != 6)
			{
				MLS.LogWarning((object)"Invalid hex code used for monitor background color! Reverting to default.");
			}
			if (text3.Length != 6)
			{
				MLS.LogWarning((object)"Invalid hex code used for monitor text color! Reverting to default.");
			}
			MonitorBackgroundColor.Value = ((text2.Length == 6) ? text2 : ((ConfigEntryBase)MonitorBackgroundColor).DefaultValue.ToString());
			MonitorBackgroundColorVal = HexToColor(MonitorBackgroundColor.Value);
			MonitorTextColor.Value = ((text3.Length == 6) ? text3 : ((ConfigEntryBase)MonitorTextColor).DefaultValue.ToString());
			MonitorTextColorVal = HexToColor(MonitorTextColor.Value);
			if (MinimumStartingMoney.Value < StartingMoneyPerPlayer.Value)
			{
				MinimumStartingMoney.Value = StartingMoneyPerPlayer.Value;
			}
			List<string> list3 = new List<string>();
			string[] source = ScannableTools.Value.Replace(" ", "").Split(',');
			if (source.Any((string s) => s.ToUpper() == "ALL"))
			{
				ScannableToolVals = list2;
				return;
			}
			string[] array2 = ScannableTools.Value.Replace(" ", "").Split(',');
			foreach (string scannableTool in array2)
			{
				Type type = list2.FirstOrDefault((Type g) => g.Name.ToUpper().Contains(scannableTool.ToUpper()));
				if (type == null)
				{
					MLS.LogWarning((object)("Could not find item type " + scannableTool + " when trying to add a scan node! Check your spelling and the acceptable values."));
					continue;
				}
				ScannableToolVals.Add(type);
				list3.Add(scannableTool);
			}
			ScannableTools.Value = string.Join(',', list3.ToArray());
		}

		private static Color HexToColor(string hex)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)int.Parse(hex.Substring(0, 2), NumberStyles.HexNumber) / 255f;
			float num2 = (float)int.Parse(hex.Substring(2, 2), NumberStyles.HexNumber) / 255f;
			float num3 = (float)int.Parse(hex.Substring(4, 2), NumberStyles.HexNumber) / 255f;
			return new Color(num, num2, num3);
		}

		public static Dictionary<string, List<InternalConfigDef>> GetConfigSectionsAndItems(string filePath)
		{
			string[] source = File.ReadAllLines(filePath);
			Dictionary<string, List<InternalConfigDef>> dictionary = new Dictionary<string, List<InternalConfigDef>> { 
			{
				string.Empty,
				new List<InternalConfigDef>()
			} };
			string text = string.Empty;
			string description = string.Empty;
			string defaultValue = string.Empty;
			foreach (string item in source.Select((string l) => l.Trim()))
			{
				if (item.StartsWith('#'))
				{
					if (item.StartsWith("##"))
					{
						description = item.Substring(2);
						continue;
					}
					Match match = Regex.Match(item, "# Default value: (.+)");
					if (match.Groups[1].Success)
					{
						defaultValue = match.Groups[1].Value;
					}
				}
				else if (item.StartsWith('[') && item.EndsWith(']'))
				{
					text = item.Substring(1, item.Length - 2);
					dictionary.TryAdd(text, new List<InternalConfigDef>());
				}
				else
				{
					string[] array = item.Split('=');
					if (array.Length == 2)
					{
						dictionary[text].Add(new InternalConfigDef(text, description, array[0].Trim(), array[1].Trim(), defaultValue));
						description = string.Empty;
						defaultValue = string.Empty;
					}
				}
			}
			return dictionary;
		}

		private void MigrateOldConfigValues()
		{
			try
			{
				Dictionary<string, List<InternalConfigDef>> configSectionsAndItems = GetConfigSectionsAndItems(((BaseUnityPlugin)this).Config.ConfigFilePath);
				bool flag = false;
				foreach (string section in configSectionsAndItems.Keys)
				{
					foreach (InternalConfigDef entry in configSectionsAndItems[section])
					{
						if (!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)((BaseUnityPlugin)this).Config).Any((KeyValuePair<ConfigDefinition, ConfigEntryBase> k) => k.Key.Section == section && entry.Name == k.Value.Definition.Key))
						{
							MigrateSpecificValue(entry);
							flag = true;
						}
					}
				}
				if (flag)
				{
					Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)(((object)((BaseUnityPlugin)this).Config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(((BaseUnityPlugin)this).Config));
					if (dictionary != null)
					{
						dictionary.Clear();
						((BaseUnityPlugin)this).Config.Save();
					}
					else
					{
						MLS.LogWarning((object)"Could not clear orphaned config values when migrating old config values.");
					}
				}
			}
			catch (Exception arg)
			{
				MLS.LogError((object)$"Error encountered while migrating old config values! This will not affect gameplay, but please verify your config file to ensure the settings are as you expect.\n\n{arg}");
			}
		}

		private void MigrateSpecificValue(InternalConfigDef entry)
		{
			MLS.LogMessage((object)("Found unused config value: " + entry.Name + ". Migrating and removing if possible..."));
			Action<Enums.eMonitorNames> action = delegate(Enums.eMonitorNames s)
			{
				if (int.TryParse(entry.Value, out var result2) && result2 >= 1 && result2 <= ShipMonitorAssignments.Length)
				{
					MLS.LogInfo((object)$"Migrating {s} to monitor position {result2}.");
					ShipMonitorAssignments[result2 - 1].Value = s;
				}
			};
			bool result;
			switch (entry.Name)
			{
			case "ShipProfitQuotaMonitorNum":
				action(Enums.eMonitorNames.ProfitQuota);
				break;
			case "ShipDeadlineMonitorNum":
				action(Enums.eMonitorNames.Deadline);
				break;
			case "ShipTotalMonitorNum":
				action(Enums.eMonitorNames.ShipScrap);
				break;
			case "ShipTimeMonitorNum":
				action(Enums.eMonitorNames.Time);
				break;
			case "ShipWeatherMonitorNum":
				action(Enums.eMonitorNames.Weather);
				break;
			case "FancyWeatherMonitor":
			{
				ConfigEntry<Enums.eMonitorNames> val = ((IEnumerable<ConfigEntry<Enums.eMonitorNames>>)ShipMonitorAssignments).FirstOrDefault((Func<ConfigEntry<Enums.eMonitorNames>, bool>)((ConfigEntry<Enums.eMonitorNames> a) => a.Value == Enums.eMonitorNames.Weather));
				if (entry.Value.ToUpper() == "TRUE" && val != null)
				{
					MLS.LogInfo((object)"Migrating fancy weather to override weather monitor.");
					val.Value = Enums.eMonitorNames.FancyWeather;
				}
				break;
			}
			case "ShipSalesMonitorNum":
				action(Enums.eMonitorNames.Sales);
				break;
			case "ShipInternalCamMonitorNum":
				action(Enums.eMonitorNames.InternalCam);
				break;
			case "ShipExternalCamMonitorNum":
				action(Enums.eMonitorNames.ExternalCam);
				break;
			case "FixPersonalScanner":
				FixPersonalScanner.Value = entry.Value.ToUpper() == "TRUE";
				break;
			case "ScanHeldPlayerItems":
				ScanHeldPlayerItems.Value = entry.Value.ToUpper() == "TRUE";
				break;
			case "MaskedLookLikePlayers":
			{
				bool flag = bool.TryParse(entry.Value, out result);
				MaskedEntitiesWearMasks.Value = !flag;
				MaskedEntitiesShowPlayerNames.Value = flag;
				MaskedEntitiesCopyPlayerLooks.Value = (flag ? Enums.eMaskedEntityCopyLook.SuitAndCosmetics : Enums.eMaskedEntityCopyLook.None);
				MaskedEntitiesSpinOnRadar.Value = !flag;
				MaskedEntitiesReachTowardsPlayer.Value = !flag;
				break;
			}
			case "MaskedEntityBlendLevel":
			{
				string text = entry.Value.ToUpper();
				MaskedEntitiesWearMasks.Value = new string[3] { "NONE", "JUSTCOPYSUIT", "JUSTCOPYSUITANDCOSMETICS" }.Contains(text);
				MaskedEntitiesShowPlayerNames.Value = text == "FULL";
				switch (text)
				{
				case "JUSTCOPYSUIT":
				case "NOMASKANDCOPYSUIT":
					MaskedEntitiesCopyPlayerLooks.Value = Enums.eMaskedEntityCopyLook.Suit;
					break;
				case "JUSTCOPYSUITANDCOSMETICS":
				case "FULL":
					MaskedEntitiesCopyPlayerLooks.Value = Enums.eMaskedEntityCopyLook.SuitAndCosmetics;
					break;
				default:
					MaskedEntitiesCopyPlayerLooks.Value = Enums.eMaskedEntityCopyLook.None;
					break;
				}
				MaskedEntitiesSpinOnRadar.Value = text != "FULL";
				MaskedEntitiesReachTowardsPlayer.Value = text != "FULL";
				break;
			}
			case "SaveShipFurniturePlaces":
				SaveShipFurniturePlaces.Value = (bool.TryParse(entry.Value, out result) ? Enums.eSaveFurniturePlacement.All : Enums.eSaveFurniturePlacement.None);
				break;
			default:
				MLS.LogDebug((object)"No matching migration");
				break;
			}
		}
	}
}
namespace GeneralImprovements.Utilities
{
	internal static class AssetBundleHelper
	{
		private static AssetBundle _bundle;

		public static GameObject MonitorsPrefab { get; private set; }

		public static Sprite Reticle { get; private set; }

		public static GameObject MedStationPrefab { get; private set; }

		public static GameObject LightningOverlay { get; private set; }

		public static void Initialize()
		{
			if ((Object)(object)_bundle == (Object)null)
			{
				string text = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, "GeneralImprovementsAssets");
				if (!new FileInfo(text).Exists)
				{
					Plugin.MLS.LogError((object)"Could not find asset bundle!");
					return;
				}
				_bundle = AssetBundle.LoadFromFile(text, 1134919927u);
				Plugin.MLS.LogInfo((object)"Loading assets...");
				MonitorsPrefab = _bundle.LoadAsset<GameObject>("MonitorGroup.prefab");
				Reticle = _bundle.LoadAsset<Sprite>("reticle.png");
				MedStationPrefab = _bundle.LoadAsset<GameObject>("MedStation.prefab");
				LightningOverlay = _bundle.LoadAsset<GameObject>("LightningOverlay.prefab");
			}
		}
	}
	public static class MonitorsHelper
	{
		private static Vector3 _originalProfitQuotaLocation = Vector3.zero;

		private static Vector3 _originalProfitQuotaRotation = Vector3.zero;

		private static Image _originalProfitQuotaBG;

		private static TextMeshProUGUI _originalProfitQuotaText;

		private static Image _originalDeadlineBG;

		private static TextMeshProUGUI _originalDeadlineText;

		private static float _originalFontSize;

		private static List<Image> _profitQuotaBGs = new List<Image>();

		private static List<TextMeshProUGUI> _profitQuotaTexts = new List<TextMeshProUGUI>();

		private static List<Image> _deadlineBGs = new List<Image>();

		private static List<TextMeshProUGUI> _deadlineTexts = new List<TextMeshProUGUI>();

		private static List<Image> _shipScrapMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _shipScrapMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _scrapLeftMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _scrapLeftMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _timeMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _timeMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _weatherMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _weatherMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _fancyWeatherMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _fancyWeatherMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _salesMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _salesMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _creditsMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _creditsMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _doorPowerMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _doorPowerMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _totalDaysMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _totalDaysMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _totalQuotasMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _totalQuotasMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _totalDeathsMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _totalDeathsMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _daysSinceDeathMonitorBGs = new List<Image>();

		private static List<TextMeshProUGUI> _daysSinceDeathMonitorTexts = new List<TextMeshProUGUI>();

		private static List<Image> _extraBackgrounds = new List<Image>();

		private static bool _usingAnyMonitorTweaks = false;

		private static int _lastUpdatedCredits = -1;

		private static float _lastUpdatedDoorPower = -1f;

		private static float _updateDoorPowerTimer = 0f;

		private static Monitors _newMonitors;

		private static Dictionary<TextMeshProUGUI, Action> _queuedMonitorRefreshes = new Dictionary<TextMeshProUGUI, Action>();

		private static float _curTimeMonitorTimer = 1f;

		private static float _timeMonitorCycleTime = 1f;

		private static int _curWeatherAnimIndex = 0;

		private static int _curWeatherOverlayIndex = 0;

		private static string[] _curWeatherAnimations = new string[0];

		private static string[] _curWeatherOverlays = new string[0];

		private static float _weatherAnimTimer = 0f;

		private static float _weatherAnimCycle = 0.25f;

		private static bool _weatherHasOverlays = false;

		private static float _weatherOverlayTimer = 0f;

		private static bool _weatherShowingOverlay = false;

		private static float _weatherOverlayCycle;

		private static int _curSalesAnimIndex = 0;

		private static List<string> _curSalesAnimations = new List<string>();

		private static float _salesAnimTimer = 0f;

		private static float _salesAnimCycle = 2f;

		private static float _curCreditsUpdateCounter = 0f;

		private static Transform _oldMonitorsObject;

		private static Transform _oldBigMonitors;

		private static Transform _UIContainer;

		private static ScanNodeProperties _profitQuotaScanNode;

		public static void InitializeMonitors(Enums.eMonitorNames[] monitorAssignments, bool includeCamSetup)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			_originalProfitQuotaBG = StartOfRound.Instance.profitQuotaMonitorBGImage;
			_originalProfitQuotaText = StartOfRound.Instance.profitQuotaMonitorText;
			_originalDeadlineBG = StartOfRound.Instance.deadlineMonitorBGImage;
			_originalDeadlineText = StartOfRound.Instance.deadlineMonitorText;
			_originalFontSize = ((TMP_Text)_originalProfitQuotaText).fontSize;
			Image originalProfitQuotaBG = _originalProfitQuotaBG;
			_UIContainer = ((originalProfitQuotaBG != null) ? ((Component)originalProfitQuotaBG).transform.parent : null);
			if (Plugin.CenterAlignMonitorText.Value)
			{
				((TMP_Text)_originalProfitQuotaText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_originalDeadlineText).alignment = (TextAlignmentOptions)514;
			}
			Transform obj = StartOfRound.Instance.elevatorTransform.Find("Cameras/ShipCamera");
			Camera val = ((obj != null) ? ((Component)obj).GetComponent<Camera>() : null);
			Transform obj2 = StartOfRound.Instance.elevatorTransform.Find("Cameras/FrontDoorSecurityCam/SecurityCamera");
			Camera val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<Camera>() : null);
			if (Plugin.DisableShipCamPostProcessing.Value)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).GetComponent<HDAdditionalCameraData>().volumeLayerMask = LayerMask.op_Implicit(0);
				}
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).GetComponent<HDAdditionalCameraData>().volumeLayerMask = LayerMask.op_Implicit(0);
				}
			}
			if (!Plugin.UseBetterMonitors.Value && Plugin.ShowBlueMonitorBackground.Value && !Plugin.ShowBackgroundOnAllScreens.Value && !Plugin.SyncMonitorsFromOtherHost.Value && !(Plugin.MonitorBackgroundColor.Value != ((ConfigEntryBase)Plugin.MonitorBackgroundColor).DefaultValue.ToString()) && !(Plugin.MonitorTextColor.Value != ((ConfigEntryBase)Plugin.MonitorTextColor).DefaultValue.ToString()) && Plugin.ShipInternalCamFPS.Value == (int)((ConfigEntryBase)Plugin.ShipInternalCamFPS).DefaultValue && Plugin.ShipInternalCamSizeMultiplier.Value == (int)((ConfigEntryBase)Plugin.ShipInternalCamSizeMultiplier).DefaultValue && Plugin.ShipExternalCamFPS.Value == (int)((ConfigEntryBase)Plugin.ShipExternalCamFPS).DefaultValue && Plugin.ShipExternalCamSizeMultiplier.Value == (int)((ConfigEntryBase)Plugin.ShipExternalCamSizeMultiplier).DefaultValue && !Plugin.ShipMonitorAssignments.Any((ConfigEntry<Enums.eMonitorNames> m) => m.Value != (Enums.eMonitorNames?)((ConfigEntryBase)m).DefaultValue))
			{
				return;
			}
			_usingAnyMonitorTweaks = true;
			_lastUpdatedCredits = -1;
			_lastUpdatedDoorPower = -1f;
			RemoveExistingMonitors();
			((Graphic)_originalProfitQuotaBG).color = Plugin.MonitorBackgroundColorVal;
			((Graphic)_originalProfitQuotaText).color = Plugin.MonitorTextColorVal;
			((Graphic)_originalDeadlineBG).color = Plugin.MonitorBackgroundColorVal;
			((Graphic)_originalDeadlineText).color = Plugin.MonitorTextColorVal;
			((TMP_Text)_originalProfitQuotaText).rectTransform.sizeDelta = ((Graphic)_originalProfitQuotaBG).rectTransform.sizeDelta;
			((TMP_Text)_originalProfitQuotaText).transform.position = ((Component)_originalProfitQuotaBG).transform.TransformPoint(Vector3.back);
			((TMP_Text)_originalProfitQuotaText).fontSize = _originalFontSize * 0.9f;
			((TMP_Text)_originalProfitQuotaText).margin = Vector4.one * 5f;
			((TMP_Text)_originalDeadlineText).rectTransform.sizeDelta = ((Graphic)_originalDeadlineBG).rectTransform.sizeDelta;
			((TMP_Text)_originalDeadlineText).transform.position = ((Component)_originalDeadlineBG).transform.TransformPoint(Vector3.back);
			((TMP_Text)_originalDeadlineText).fontSize = _originalFontSize * 0.9f;
			((TMP_Text)_originalDeadlineText).margin = Vector4.one * 5f;
			_oldMonitorsObject = _UIContainer.parent.parent;
			_oldBigMonitors = ((Component)((Component)_oldMonitorsObject.parent).GetComponentInChildren<ManualCameraRenderer>()).transform.parent;
			_profitQuotaScanNode = ((IEnumerable<ScanNodeProperties>)((Component)StartOfRound.Instance.elevatorTransform).GetComponentsInChildren<ScanNodeProperties>()).FirstOrDefault((Func<ScanNodeProperties, bool>)((ScanNodeProperties s) => s.headerText == "Quota"));
			if (includeCamSetup)
			{
				if (Plugin.ShipInternalCamFPS.Value != (int)((ConfigEntryBase)Plugin.ShipInternalCamFPS).DefaultValue || Plugin.ShipInternalCamSizeMultiplier.Value != (int)((ConfigEntryBase)Plugin.ShipInternalCamSizeMultiplier).DefaultValue)
				{
					UpdateSecurityCamFPSAndResolution(val, Plugin.ShipInternalCamFPS.Value, Plugin.ShipInternalCamSizeMultiplier.Value);
				}
				if (Plugin.ShipExternalCamFPS.Value != (int)((ConfigEntryBase)Plugin.ShipExternalCamFPS).DefaultValue || Plugin.ShipExternalCamSizeMultiplier.Value != (int)((ConfigEntryBase)Plugin.ShipExternalCamSizeMultiplier).DefaultValue)
				{
					UpdateSecurityCamFPSAndResolution(val2, Plugin.ShipExternalCamFPS.Value, Plugin.ShipExternalCamSizeMultiplier.Value);
				}
				((Renderer)((Component)_oldMonitorsObject).GetComponent<MeshRenderer>()).sharedMaterials[2].mainTexture = (Texture)(object)val.targetTexture;
				((Renderer)((Component)_oldBigMonitors).GetComponent<MeshRenderer>()).sharedMaterials[2].mainTexture = (Texture)(object)val2.targetTexture;
			}
			if (Plugin.UseBetterMonitors.Value)
			{
				CreateNewStyleMonitors(monitorAssignments);
			}
			else
			{
				CreateOldStyleMonitors(monitorAssignments);
			}
			CopyProfitQuotaAndDeadlineTexts();
			UpdateShipScrapMonitors();
			UpdateScrapLeftMonitors();
			UpdateTimeMonitors();
			UpdateWeatherMonitors();
			UpdateDoorPowerMonitors();
			if ((Object)(object)_profitQuotaScanNode != (Object)null && !monitorAssignments.Any((Enums.eMonitorNames a) => a == Enums.eMonitorNames.ProfitQuota))
			{
				Object.Destroy((Object)(object)((Component)_profitQuotaScanNode).gameObject);
			}
		}

		private static void UpdateSecurityCamFPSAndResolution(Camera cam, int fps, int resMultiplier)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			ManualCameraRenderer component = ((Component)cam).GetComponent<ManualCameraRenderer>();
			component.renderAtLowerFramerate = fps > 0;
			component.fps = fps;
			if (resMultiplier > 1)
			{
				int num = ((Texture)cam.targetTexture).width * (2 * resMultiplier);
				int num2 = ((Texture)cam.targetTexture).height * (2 * resMultiplier);
				RenderTexture targetTexture = cam.targetTexture;
				RenderTexture targetTexture2 = new RenderTexture(num, num2, cam.targetTexture.depth, cam.targetTexture.format);
				cam.targetTexture = targetTexture2;
				Object.Destroy((Object)(object)targetTexture);
			}
		}

		private static void RemoveExistingMonitors()
		{
			if (!Plugin.UseBetterMonitors.Value)
			{
				_profitQuotaBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_profitQuotaTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_deadlineBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_deadlineTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_shipScrapMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_shipScrapMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_scrapLeftMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_scrapLeftMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_timeMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_timeMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_weatherMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_weatherMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_fancyWeatherMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_fancyWeatherMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_salesMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_salesMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_creditsMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_creditsMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_doorPowerMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_doorPowerMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_totalDaysMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_totalDaysMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_totalQuotasMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_totalQuotasMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_totalDeathsMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_totalDeathsMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_daysSinceDeathMonitorBGs.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
				_daysSinceDeathMonitorTexts.ForEach(delegate(TextMeshProUGUI g)
				{
					Object.Destroy((Object)(object)g);
				});
				_extraBackgrounds.ForEach(delegate(Image g)
				{
					Object.Destroy((Object)(object)g);
				});
			}
			else if ((Object)(object)_newMonitors != (Object)null)
			{
				foreach (KeyValuePair<int, MonitorsAPI.MonitorInfo> item in MonitorsAPI.AllMonitors.Where((KeyValuePair<int, MonitorsAPI.MonitorInfo> m) => (Object)(object)((Renderer)m.Value.MeshRenderer).sharedMaterial != (Object)(object)m.Value.TargetMaterial))
				{
					Plugin.MLS.LogInfo((object)$"Detected overwritten material on monitor {item.Key + 1} ({((Object)((Renderer)item.Value.MeshRenderer).sharedMaterial).name}). Saving before recreating monitors.");
					item.Value.OverwrittenMaterial = ((Renderer)item.Value.MeshRenderer).sharedMaterial;
				}
				Object.Destroy((Object)(object)((Component)_newMonitors).gameObject);
			}
			_profitQuotaBGs = new List<Image>();
			_profitQuotaTexts = new List<TextMeshProUGUI>();
			_deadlineBGs = new List<Image>();
			_deadlineTexts = new List<TextMeshProUGUI>();
			_shipScrapMonitorBGs = new List<Image>();
			_shipScrapMonitorTexts = new List<TextMeshProUGUI>();
			_scrapLeftMonitorBGs = new List<Image>();
			_scrapLeftMonitorTexts = new List<TextMeshProUGUI>();
			_timeMonitorBGs = new List<Image>();
			_timeMonitorTexts = new List<TextMeshProUGUI>();
			_weatherMonitorBGs = new List<Image>();
			_weatherMonitorTexts = new List<TextMeshProUGUI>();
			_fancyWeatherMonitorBGs = new List<Image>();
			_fancyWeatherMonitorTexts = new List<TextMeshProUGUI>();
			_salesMonitorBGs = new List<Image>();
			_salesMonitorTexts = new List<TextMeshProUGUI>();
			_creditsMonitorBGs = new List<Image>();
			_creditsMonitorTexts = new List<TextMeshProUGUI>();
			_doorPowerMonitorBGs = new List<Image>();
			_doorPowerMonitorTexts = new List<TextMeshProUGUI>();
			_totalDaysMonitorBGs = new List<Image>();
			_totalDaysMonitorTexts = new List<TextMeshProUGUI>();
			_totalQuotasMonitorBGs = new List<Image>();
			_totalQuotasMonitorTexts = new List<TextMeshProUGUI>();
			_totalDeathsMonitorBGs = new List<Image>();
			_totalDeathsMonitorTexts = new List<TextMeshProUGUI>();
			_daysSinceDeathMonitorBGs = new List<Image>();
			_daysSinceDeathMonitorTexts = new List<TextMeshProUGUI>();
			_extraBackgrounds = new List<Image>();
		}

		private static void CreateOldStyleMonitors(Enums.eMonitorNames[] monitorAssignments)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			Plugin.MLS.LogInfo((object)"Creating old style monitor overlays.");
			if (_originalProfitQuotaLocation == Vector3.zero)
			{
				_originalProfitQuotaLocation = ((Component)_originalProfitQuotaBG).transform.localPosition;
			}
			if (_originalProfitQuotaRotation == Vector3.zero)
			{
				_originalProfitQuotaRotation = ((Component)_originalProfitQuotaBG).transform.localEulerAngles;
			}
			((Behaviour)_originalProfitQuotaBG).enabled = false;
			((Behaviour)_originalProfitQuotaText).enabled = false;
			((Behaviour)_originalDeadlineBG).enabled = false;
			((Behaviour)_originalDeadlineText).enabled = false;
			((Component)_originalDeadlineBG).transform.localPosition = _originalProfitQuotaLocation;
			((Component)_originalDeadlineBG).transform.localEulerAngles = _originalProfitQuotaRotation;
			((TMP_Text)_originalDeadlineText).transform.localPosition = _originalProfitQuotaLocation;
			((TMP_Text)_originalDeadlineText).transform.localEulerAngles = _originalProfitQuotaRotation;
			List<KeyValuePair<Vector3, Vector3>> list = new List<KeyValuePair<Vector3, Vector3>>
			{
				new KeyValuePair<Vector3, Vector3>(new Vector3(0f, 465f, -22f), new Vector3(-18f, 0f, 0f)),
				new KeyValuePair<Vector3, Vector3>(new Vector3(470f, 465f, -22f), new Vector3(-18f, 0f, 0f)),
				new KeyValuePair<Vector3, Vector3>(new Vector3(970f, 485f, -128f), new Vector3(-18f, 25f, 5f)),
				new KeyValuePair<Vector3, Vector3>(new Vector3(1390f, 525f, -329f), new Vector3(-18f, 25f, 5f)),
				new KeyValuePair<Vector3, Vector3>(Vector3.zero, Vector3.zero),
				new KeyValuePair<Vector3, Vector3>(new Vector3(470f, 0f, 0f), Vector3.zero),
				new KeyValuePair<Vector3, Vector3>(new Vector3(1025f, 30f, -115f), new Vector3(-1f, 25f, 5f)),
				new KeyValuePair<Vector3, Vector3>(new Vector3(1445f, 72f, -320f), new Vector3(-1f, 27f, 5f))
			};
			for (int i = 0; i < list.Count; i++)
			{
				Enums.eMonitorNames eMonitorNames = monitorAssignments[i];
				List<Image> list2 = null;
				List<TextMeshProUGUI> list3 = null;
				switch (eMonitorNames)
				{
				case Enums.eMonitorNames.ProfitQuota:
					list2 = _profitQuotaBGs;
					list3 = _profitQuotaTexts;
					break;
				case Enums.eMonitorNames.Deadline:
					list2 = _deadlineBGs;
					list3 = _deadlineTexts;
					break;
				case Enums.eMonitorNames.ShipScrap:
					list2 = _shipScrapMonitorBGs;
					list3 = _shipScrapMonitorTexts;
					break;
				case Enums.eMonitorNames.ScrapLeft:
					list2 = _scrapLeftMonitorBGs;
					list3 = _scrapLeftMonitorTexts;
					break;
				case Enums.eMonitorNames.Time:
					list2 = _timeMonitorBGs;
					list3 = _timeMonitorTexts;
					break;
				case Enums.eMonitorNames.Weather:
					list2 = _weatherMonitorBGs;
					list3 = _weatherMonitorTexts;
					break;
				case Enums.eMonitorNames.FancyWeather:
					list2 = _fancyWeatherMonitorBGs;
					list3 = _fancyWeatherMonitorTexts;
					break;
				case Enums.eMonitorNames.Sales:
					list2 = _salesMonitorBGs;
					list3 = _salesMonitorTexts;
					break;
				case Enums.eMonitorNames.Credits:
					list2 = _creditsMonitorBGs;
					list3 = _creditsMonitorTexts;
					break;
				case Enums.eMonitorNames.DoorPower:
					list2 = _doorPowerMonitorBGs;
					list3 = _doorPowerMonitorTexts;
					break;
				case Enums.eMonitorNames.TotalDays:
					list2 = _totalDaysMonitorBGs;
					list3 = _totalDaysMonitorTexts;
					break;
				case Enums.eMonitorNames.TotalQuotas:
					list2 = _totalQuotasMonitorBGs;
					list3 = _totalQuotasMonitorTexts;
					break;
				case Enums.eMonitorNames.TotalDeaths:
					list2 = _totalDeathsMonitorBGs;
					list3 = _totalDeathsMonitorTexts;
					break;
				case Enums.eMonitorNames.DaysSinceDeath:
					list2 = _daysSinceDeathMonitorBGs;
					list3 = _daysSinceDeathMonitorTexts;
					break;
				}
				if ((list2 == null || list3 == null) && Plugin.ShowBlueMonitorBackground.Value && Plugin.ShowBackgroundOnAllScreens.Value)
				{
					list2 = _extraBackgrounds;
				}
				else if (list3 == null && eMonitorNames != 0)
				{
					Plugin.MLS.LogError((object)$"Could not find '{eMonitorNames}' for monitor assignment! Please check your config is using acceptable values.");
				}
				Vector3 key = list[i].Key;
				Vector3 value = list[i].Value;
				if (list2 != null && Plugin.ShowBlueMonitorBackground.Value)
				{
					Image val = Object.Instantiate<Image>(_originalProfitQuotaBG, ((Component)_originalProfitQuotaBG).transform.parent);
					((Behaviour)val).enabled = true;
					((Object)val).name = string.Format("{0}BG{1}", (eMonitorNames == Enums.eMonitorNames.None) ? "ExtraBackground" : eMonitorNames.ToString(), i + 1);
					((Component)val).transform.localPosition = _originalProfitQuotaLocation + key;
					((Component)val).transform.localEulerAngles = _originalProfitQuotaRotation + value;
					list2.Add(val);
				}
				if (list3 != null)
				{
					Plugin.MLS.LogInfo((object)$"Creating {eMonitorNames} monitor at position {i + 1}");
					TextMeshProUGUI val2 = Object.Instantiate<TextMeshProUGUI>(_originalProfitQuotaText, ((TMP_Text)_originalProfitQuotaText).transform.parent);
					((Behaviour)val2).enabled = true;
					((Object)val2).name = $"{eMonitorNames}Text{i + 1}";
					((TMP_Text)val2).transform.localPosition = _originalProfitQuotaLocation + key + new Vector3(0f, 0f, -1f);
					((TMP_Text)val2).transform.localEulerAngles = _originalProfitQuotaRotation + value + new Vector3(1f, 0f, 0f);
					list3.Add(val2);
					if (eMonitorNames == Enums.eMonitorNames.ProfitQuota && (Object)(object)_profitQuotaScanNode != (Object)null)
					{
						((Component)_profitQuotaScanNode).transform.parent = ((TMP_Text)_profitQuotaTexts[0]).transform;
						((Component)_profitQuotaScanNode).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
					}
				}
			}
			foreach (TextMeshProUGUI salesMonitorText in _salesMonitorTexts)
			{
				((TMP_Text)salesMonitorText).overflowMode = (TextOverflowModes)1;
			}
			foreach (TextMeshProUGUI fancyWeatherMonitorText in _fancyWeatherMonitorTexts)
			{
				((TMP_Text)fancyWeatherMonitorText).alignment = (TextAlignmentOptions)4097;
				Transform transform = ((TMP_Text)fancyWeatherMonitorText).transform;
				transform.localPosition += new Vector3(25f, 0f, -10f);
				Transform transform2 = ((TMP_Text)fancyWeatherMonitorText).transform;
				transform2.localEulerAngles += new Vector3(-2f, 1f, 0f);
			}
		}

		private static void CreateNewStyleMonitors(Enums.eMonitorNames[] monitorAssignments)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			Plugin.MLS.LogInfo((object)$"Creating new style monitors (additional monitors: {Plugin.AddMoreBetterMonitors.Value}).");
			GameObject val = Object.Instantiate<GameObject>(AssetBundleHelper.MonitorsPrefab, ((Component)_oldMonitorsObject).transform.parent);
			val.transform.SetLocalPositionAndRotation(_oldMonitorsObject.localPosition, Quaternion.identity);
			_newMonitors = val.AddComponent<Monitors>();
			MeshRenderer component = ((Component)_oldMonitorsObject).GetComponent<MeshRenderer>();
			MeshRenderer component2 = ((Component)_oldBigMonitors).GetComponent<MeshRenderer>();
			_newMonitors.Initialize(((Renderer)component).sharedMaterials[0], ((Renderer)component2).sharedMaterials[1], ((Renderer)component).sharedMaterials[1]);
			Material val2 = ((IEnumerable<Material>)((Renderer)component).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name.StartsWith("ShipScreen")));
			Material externalCamMat = ((IEnumerable<Material>)((Renderer)component2).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => ((Object)m).name.StartsWith("ShipScreen")));
			for (int i = 0; i < (Plugin.AddMoreBetterMonitors.Value ? 14 : 9) && i < monitorAssignments.Length; i++)
			{
				Enums.eMonitorNames eMonitorNames = monitorAssignments[i];
				Plugin.MLS.LogInfo((object)$"Creating {eMonitorNames} monitor at position {i + 1}");
				MonitorsAPI.MonitorInfo monitorInfo = MonitorsAPI.AllMonitors[i];
				switch (eMonitorNames)
				{
				case Enums.eMonitorNames.ProfitQuota:
					_profitQuotaTexts.Add(monitorInfo.TextCanvas);
					if ((Object)(object)_profitQuotaScanNode != (Object)null)
					{
						((Component)_profitQuotaScanNode).transform.parent = ((Component)monitorInfo.MeshRenderer).transform;
						((Component)_profitQuotaScanNode).transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
					}
					CopyProfitQuotaAndDeadlineTexts();
					break;
				case Enums.eMonitorNames.Deadline:
					_deadlineTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.ShipScrap:
					_shipScrapMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.ScrapLeft:
					_scrapLeftMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.Time:
					_timeMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.Weather:
					_weatherMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.FancyWeather:
					if (Plugin.CenterAlignMonitorText.Value)
					{
						((TMP_Text)monitorInfo.TextCanvas).alignment = (TextAlignmentOptions)4097;
						TextMeshProUGUI textCanvas = monitorInfo.TextCanvas;
						((TMP_Text)textCanvas).margin = ((TMP_Text)textCanvas).margin + new Vector4(20f, 10f, 0f, 0f);
					}
					else
					{
						((TMP_Text)monitorInfo.TextCanvas).alignment = (TextAlignmentOptions)257;
						TextMeshProUGUI textCanvas2 = monitorInfo.TextCanvas;
						((TMP_Text)textCanvas2).margin = ((TMP_Text)textCanvas2).margin + new Vector4(10f, 10f, 0f, 0f);
					}
					_fancyWeatherMonitorTexts.Add(monitorInfo.TextCanvas);
					UpdateWeatherMonitors();
					break;
				case Enums.eMonitorNames.Sales:
					((TMP_Text)monitorInfo.TextCanvas).overflowMode = (TextOverflowModes)1;
					_salesMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.Credits:
					_creditsMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.DoorPower:
					_doorPowerMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.TotalDays:
					_totalDaysMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.TotalQuotas:
					_totalQuotasMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.TotalDeaths:
					_totalDeathsMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.DaysSinceDeath:
					_daysSinceDeathMonitorTexts.Add(monitorInfo.TextCanvas);
					break;
				case Enums.eMonitorNames.InternalCam:
					monitorInfo.AssignedMaterial = val2;
					((Renderer)monitorInfo.MeshRenderer).sharedMaterial = val2;
					((Component)StartOfRound.Instance.elevatorTransform.Find("Cameras/ShipCamera")).GetComponent<ManualCameraRenderer>().mesh = monitorInfo.MeshRenderer;
					break;
				case Enums.eMonitorNames.ExternalCam:
					monitorInfo.AssignedMaterial = externalCamMat;
					((Renderer)monitorInfo.MeshRenderer).sharedMaterial = externalCamMat;
					((Component)StartOfRound.Instance.elevatorTransform.Find("Cameras/FrontDoorSecurityCam/SecurityCamera")).GetComponent<ManualCameraRenderer>().mesh = monitorInfo.MeshRenderer;
					break;
				}
			}
			Transform val3 = val.transform.Find("Monitors/TopGroupL");
			Transform val4 = val.transform.Find("Monitors/BigLeft");
			if ((Object)(object)val3 != (Object)null)
			{
				((Component)val3).gameObject.SetActive(Plugin.AddMoreBetterMonitors.Value);
			}
			if ((Object)(object)val4 != (Object)null)
			{
				((Component)val4).gameObject.SetActive(Plugin.AddMoreBetterMonitors.Value);
			}
			MeshRenderer component3 = ((Component)val.transform.Find("Monitors/BigMiddle")).GetComponent<MeshRenderer>();
			StartOfRound.Instance.mapScreen.mesh = component3;
			Transform obj = StartOfRound.Instance.elevatorTransform.Find("ShipModels2b/MonitorWall/SingleScreen");
			MeshRenderer val5 = ((obj != null) ? ((Component)obj).GetComponent<MeshRenderer>() : null);
			if (!MonitorsAPI.AllMonitors.Values.Any((MonitorsAPI.MonitorInfo m) => (Object)(object)m.AssignedMaterial == (Object)(object)externalCamMat) && (Object)(object)val5 != (Object)null && ((Renderer)val5).sharedMaterials.Any((Material m) => ((Object)m).name.StartsWith("ShipScreen2")))
			{
				((Component)StartOfRound.Instance.elevatorTransform.Find("Cameras/FrontDoorSecurityCam/SecurityCamera")).GetComponent<ManualCameraRenderer>().mesh = val5;
			}
		}

		public static void HideOldMonitors()
		{
			Plugin.MLS.LogInfo((object)"Hiding old monitors");
			if (!((Object)(object)_oldBigMonitors != (Object)null) || !((Object)(object)_oldMonitorsObject != (Object)null) || !((Object)(object)_UIContainer != (Object)null))
			{
				return;
			}
			((Renderer)((Component)_oldBigMonitors).GetComponent<MeshRenderer>()).enabled = false;
			((Component)_oldBigMonitors).GetComponent<Collider>().enabled = false;
			((Renderer)((Component)_oldMonitorsObject).GetComponent<MeshRenderer>()).enabled = false;
			((Component)_oldMonitorsObject).GetComponent<Collider>().enabled = false;
			for (int i = 0; i < _UIContainer.childCount; i++)
			{
				Image component = ((Component)_UIContainer.GetChild(i)).GetComponent<Image>();
				if (component != null)
				{
					((Behaviour)component).enabled = false;
					continue;
				}
				TextMeshProUGUI component2 = ((Component)_UIContainer.GetChild(i)).GetComponent<TextMeshProUGUI>();
				if (component2 != null)
				{
					((Behaviour)component2).enabled = false;
				}
			}
		}

		public static void CopyProfitQuotaAndDeadlineTexts()
		{
			if (_profitQuotaTexts.Count > 0 || _deadlineTexts.Count > 0)
			{
				List<TextMeshProUGUI> profitQuotaTexts = _profitQuotaTexts;
				TextMeshProUGUI profitQuotaMonitorText = StartOfRound.Instance.profitQuotaMonitorText;
				bool num = UpdateGenericTextList(profitQuotaTexts, (profitQuotaMonitorText != null) ? ((TMP_Text)profitQuotaMonitorText).text : null);
				List<TextMeshProUGUI> deadlineTexts = _deadlineTexts;
				TextMeshProUGUI deadlineMonitorText = StartOfRound.Instance.deadlineMonitorText;
				if (num & UpdateGenericTextList(deadlineTexts, (deadlineMonitorText != null) ? ((TMP_Text)deadlineMonitorText).text : null))
				{
					Plugin.MLS.LogInfo((object)"Updated profit quota and deadline monitors");
				}
			}
		}

		public static void UpdateShipScrapMonitors()
		{
			if (_shipScrapMonitorTexts.Count == 0)
			{
				return;
			}
			List<GrabbableObject> list = Object.FindObjectsOfType<GrabbableObject>().Where(delegate(GrabbableObject o)
			{
				int result;
				if (o.itemProperties.isScrap && o.isInShipRoom && o.isInElevator && !o.isHeld && !(o is RagdollGrabbableObject))
				{
					StunGrenadeItem val = (StunGrenadeItem)(object)((o is StunGrenadeItem) ? o : null);
					result = ((val == null || !val.hasExploded || !val.DestroyGrenade) ? 1 : 0);
				}
				else
				{
					result = 0;
				}
				return (byte)result != 0;
			}).ToList();
			int num = list.Sum((GrabbableObject o) => o.scrapValue);
			if (UpdateGenericTextList(_shipScrapMonitorTexts, $"SCRAP IN SHIP:\n${num}"))
			{
				Plugin.MLS.LogInfo((object)$"Set ship scrap total to ${num} ({list.Count} items).");
			}
		}

		public static void UpdateScrapLeftMonitors()
		{
			if (_scrapLeftMonitorTexts.Count > 0)
			{
				KeyValuePair<int, int> outsideScrap = GrabbableObjectsPatch.GetOutsideScrap(!Plugin.ScanCommandUsesExactAmount.Value);
				bool flag = false;
				if ((outsideScrap.Key <= 0) ? UpdateGenericTextList(_scrapLeftMonitorTexts, "NO EXTERNAL SCRAP DETECTED") : UpdateGenericTextList(_scrapLeftMonitorTexts, $"SCRAP LEFT:\n{outsideScrap.Key} ITEMS\n${outsideScrap.Value}"))
				{
					Plugin.MLS.LogInfo((object)"Updated remaining scrap display.");
				}
			}
		}

		public static void UpdateTimeMonitors(bool force = false)
		{
			if ((Object)(object)HUDManager.Instance?.clockNumber != (Object)null && _timeMonitorTexts.Count > 0 && (force || !(_curTimeMonitorTimer < _timeMonitorCycleTime)))
			{
				_curTimeMonitorTimer = 0f;
				if (UpdateGenericTextList(text: (!TimeOfDay.Instance.movingGlobalTimeForward) ? "TIME:\nPENDING" : ("TIME:\n" + ((TMP_Text)HUDManager.Instance.clockNumber).text.Replace('\n', ' ')), textList: _timeMonitorTexts))
				{
					Plugin.MLS.LogDebug((object)"Updated time display.");
				}
			}
		}

		public static void UpdateWeatherMonitors()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected I4, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Invalid comparison between Unknown and I4
			if (_weatherMonitorTexts.Count <= 0 && _fancyWeatherMonitorTexts.Count <= 0)
			{
				return;
			}
			if (_weatherMonitorTexts.Count > 0)
			{
				List<TextMeshProUGUI> weatherMonitorTexts = _weatherMonitorTexts;
				SelectableLevel currentLevel = StartOfRound.Instance.currentLevel;
				if (UpdateGenericTextList(weatherMonitorTexts, "WEATHER:\n" + (((currentLevel != null) ? ((object)(LevelWeatherType)(ref currentLevel.currentWeather)).ToString() : null) ?? string.Empty)))
				{
					Plugin.MLS.LogInfo((object)"Updated basic weather monitors");
				}
			}
			if (_fancyWeatherMonitorTexts.Count > 0)
			{
				LevelWeatherType? val = StartOfRound.Instance.currentLevel?.currentWeather;
				if (1 == 0)
				{
				}
				string[] curWeatherAnimations = val switch
				{
					0L => WeatherASCIIArt.ClearAnimations, 
					2L => WeatherASCIIArt.RainAnimations, 
					3L => WeatherASCIIArt.RainAnimations, 
					4L => WeatherASCIIArt.FoggyAnimations, 
					5L => WeatherASCIIArt.FloodedAnimations, 
					6L => WeatherASCIIArt.EclipsedAnimations, 
					_ => new string[1] { string.Empty }, 
				};
				if (1 == 0)
				{
				}
				_curWeatherAnimations = curWeatherAnimations;
				SelectableLevel currentLevel2 = StartOfRound.Instance.currentLevel;
				_weatherHasOverlays = currentLevel2 != null && (int)currentLevel2.currentWeather == 2;
				if (_weatherHasOverlays)
				{
					_weatherOverlayTimer = 0f;
					_weatherOverlayCycle = Random.Range(0.1f, 3f);
					_curWeatherOverlays = WeatherASCIIArt.LightningOverlays;
					_curWeatherOverlayIndex = Random.Range(0, _curWeatherOverlays.Length);
				}
				_weatherShowingOverlay = false;
				_curWeatherAnimIndex = 0;
				_weatherAnimTimer = 0f;
				if (UpdateGenericTextList(_fancyWeatherMonitorTexts, _curWeatherAnimations[_curWeatherAnimIndex]))
				{
					Plugin.MLS.LogInfo((object)"Updated fancy weather monitors");
				}
			}
		}

		public static void AnimateSpecialMonitors()
		{
			if (_fancyWeatherMonitorTexts.Count > 0 && _curWeatherAnimations.Length >= 2)
			{
				Action action = delegate
				{
					StringBuilder stringBuilder = new StringBuilder();
					string[] array = _curWeatherAnimations[_curWeatherAnimIndex].Split(Environment.NewLine);
					string[] source = (_weatherShowingOverlay ? _curWeatherOverlays[_curWeatherOverlayIndex] : string.Empty).Split(Environment.NewLine);
					for (int i = 0; i < array.Length; i++)
					{
						string text2 = array[i];
						string text3 = source.ElementAtOrDefault(i);
						for (int j = 0; j < text2.Length; j++)
						{
							bool flag = !string.IsNullOrWhiteSpace(text3) && text3.Length > j && text3[j] != ' ';
							stringBuilder.Append(flag ? $"<color=#ffe100>{text3[j]}</color>" : $"{text2[j]}");
						}
						stringBuilder.AppendLine();
					}
					UpdateGenericTextList(_fancyWeatherMonitorTexts, stringBuilder.ToString());
				};
				_weatherAnimTimer += Time.deltaTime;
				if (_weatherAnimTimer >= _weatherAnimCycle)
				{
					_curWeatherAnimIndex = (_curWeatherAnimIndex + 1) % _curWeatherAnimations.Length;
					_weatherAnimTimer = 0f;
					action();
				}
				if (_weatherHasOverlays)
				{
					_weatherOverlayTimer += Time.deltaTime;
					if (_weatherOverlayTimer >= (_weatherShowingOverlay ? 0.5f : _weatherOverlayCycle))
					{
						_weatherOverlayTimer = 0f;
						_weatherShowingOverlay = !_weatherShowingOverlay;
						if (!_weatherShowingOverlay)
						{
							_weatherOverlayCycle = Random.Range(0.1f, 3f);
							_curWeatherOverlayIndex = Random.Range(0, _curWeatherOverlays.Length);
						}
						action();
					}
				}
			}
			if (_salesMonitorTexts.Count > 0 && _curSalesAnimations.Count >= 2)
			{
				_salesAnimTimer += Time.deltaTime;
				if (_salesAnimTimer >= _salesAnimCycle)
				{
					_salesAnimTimer = 0f;
					_curSalesAnimIndex = (1 + _curSalesAnimIndex) % _curSalesAnimations.Count;
					string text = ((TMP_Text)_salesMonitorTexts.First()).text.Split('\n')[0];
					UpdateGenericTextList(_salesMonitorTexts, text + "\n" + _curSalesAnimations[_curSalesAnimIndex]);
				}
			}
			if (_timeMonitorTexts.Count > 0)
			{
				_curTimeMonitorTimer += Time.deltaTime;
			}
		}

		public static void UpdateSalesMonitors()
		{
			if (_salesMonitorTexts.Count <= 0 || !((Object)(object)TerminalPatch.Instance != (Object)null))
			{
				return;
			}
			Terminal instance = TerminalPatch.Instance;
			int num = instance.itemSalesPercentages.Count((int s) => s < 100);
			_curSalesAnimIndex = 0;
			_curSalesAnimations = new List<string>();
			if (num > 0)
			{
				for (int i = 0; i < instance.itemSalesPercentages.Length; i++)
				{
					if (instance.itemSalesPercentages[i] < 100 && instance.buyableItemsList.Length > i)
					{
						string arg = instance.buyableItemsList[i]?.itemName ?? "???";
						_curSalesAnimations.Add($"{100 - instance.itemSalesPercentages[i]}% OFF {arg}");
					}
				}
			}
			bool flag = false;
			if ((num > 0) ? UpdateGenericTextList(_salesMonitorTexts, string.Format("{0} SALE{1}:\n{2}", num, (num == 1) ? string.Empty : "S", _curSalesAnimations[0])) : UpdateGenericTextList(_salesMonitorTexts, "NO SALES TODAY"))
			{
				Plugin.MLS.LogInfo((object)"Updated sales display.");
			}
		}

		public static void UpdateCreditsMonitors(bool force = false)
		{
			_curCreditsUpdateCounter += Time.deltaTime;
			if (!force && !(_curCreditsUpdateCounter >= 0.25f))
			{
				return;
			}
			_curCreditsUpdateCounter = 0f;
			int num = TerminalPatch.Instance?.groupCredits ?? (-1);
			if (_creditsMonitorTexts.Count > 0 && (force || num != _lastUpdatedCredits))
			{
				_lastUpdatedCredits = num;
				if (UpdateGenericTextList(_creditsMonitorTexts, $"CREDITS:\n${_lastUpdatedCredits}"))
				{
					Plugin.MLS.LogInfo((object)"Updated credits display.");
				}
			}
		}

		public static void UpdateDoorPowerMonitors(bool force = false)
		{
			if (_updateDoorPowerTimer > 0f)
			{
				_updateDoorPowerTimer -= Time.deltaTime;
			}
			float num = HangarShipDoorPatch.Instance?.doorPower ?? 1f;
			if (_doorPowerMonitorTexts.Count > 0 && (force || (_lastUpdatedDoorPower != num && _updateDoorPowerTimer <= 0f)))
			{
				_lastUpdatedDoorPower = num;
				UpdateGenericTextList(_doorPowerMonitorTexts, $"DOOR POWER:\n{Mathf.RoundToInt(_lastUpdatedDoorPower * 100f)}%");
				_updateDoorPowerTimer = 0.1f;
			}
		}

		public static void UpdateTotalDaysMonitors()
		{
			if (_totalDaysMonitorTexts.Count > 0 && StartOfRound.Instance.gameStats != null && UpdateGenericTextList(_totalDaysMonitorTexts, $"DAY {StartOfRound.Instance.gameStats.daysSpent + 1}"))
			{
				Plugin.MLS.LogInfo((object)"Updated total days display.");
			}
		}

		public static void UpdateTotalQuotasMonitors()
		{
			if (_totalQuotasMonitorTexts.Count > 0 && (Object)(object)TimeOfDay.Instance != (Object)null && UpdateGenericTextList(_totalQuotasMonitorTexts, $"QUOTA {TimeOfDay.Instance.timesFulfilledQuota + 1}"))
			{
				Plugin.MLS.LogInfo((object)"Updated total quotas display.");
			}
		}

		public static void UpdateDeathMonitors(bool? playersDied = null)
		{
			if (_totalDeathsMonitorTexts.Count > 0 && StartOfRound.Instance?.gameStats != null && UpdateGenericTextList(_totalDeathsMonitorTexts, $"DEATHS:\n{StartOfRound.Instance.gameStats.deaths}"))
			{
				Plugin.MLS.LogInfo((object)"Updated total deaths display.");
			}
			if (_daysSinceDeathMonitorTexts.Count <= 0 || !((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			if (playersDied.HasValue)
			{
				if (playersDied.GetValueOrDefault())
				{
					StartOfRoundPatch.DaysSinceLastDeath = 0;
				}
				else if (StartOfRoundPatch.DaysSinceLastDeath >= 0)
				{
					StartOfRoundPatch.DaysSinceLastDeath++;
				}
			}
			bool flag = false;
			if ((StartOfRoundPatch.DaysSinceLastDeath < 0) ? UpdateGenericTextList(_daysSinceDeathMonitorTexts, "ZERO DEATHS (YET)") : UpdateGenericTextList(_daysSinceDeathMonitorTexts, string.Format("{0} DAY{1} WITHOUT DEATHS", StartOfRoundPatch.DaysSinceLastDeath, (StartOfRoundPatch.DaysSinceLastDeath == 1) ? string.Empty : "S")))
			{
				Plugin.MLS.LogInfo((object)"Updated days since death display.");
			}
		}

		private static bool UpdateGenericTextList(List<TextMeshProUGUI> textList, string text)
		{
			bool result = (Object)(object)_newMonitors == (Object)null;
			foreach (TextMeshProUGUI t in textList)
			{
				((TMP_Text)t).text = text;
				if (!((Object)(object)_newMonitors != (Object)null))
				{
					continue;
				}
				MonitorsAPI.MonitorInfo monitor = MonitorsAPI.AllMonitors.FirstOrDefault((KeyValuePair<int, MonitorsAPI.MonitorInfo> m) => (Object)(object)m.Value.TextCanvas == (Object)(object)t).Value;
				if (monitor == null)
				{
					continue;
				}
				bool flag = (StartOfRound.Instance.localPlayerController?.spectatedPlayerScript ?? StartOfRound.Instance.localPlayerController)?.isInElevator ?? false;
				if (StartOfRound.Instance.inShipPhase || Plugin.AlwaysRenderMonitors.Value || flag)
				{
					if (_newMonitors.RefreshMonitorAfterTextChange(monitor))
					{
						result = true;
					}
				}
				else
				{
					_queuedMonitorRefreshes[t] = delegate
					{
						_newMonitors.RefreshMonitorAfterTextChange(monitor);
					};
				}
			}
			return result;
		}

		public static void RefreshQueuedMonitorChanges()
		{
			foreach (TextMeshProUGUI key in _queuedMonitorRefreshes.Keys)
			{
				_queuedMonitorRefreshes[key]();
			}
			if (_queuedMonitorRefreshes.Count > 0)
			{
				Plugin.MLS.LogInfo((object)$"Applied {_queuedMonitorRefreshes.Count} queued monitor changes.");
				_queuedMonitorRefreshes.Clear();
			}
		}

		public static void ToggleExtraMonitorsPower(bool on)
		{
			if (!Plugin.SyncExtraMonitorsPower.Value)
			{
				return;
			}
			if (Plugin.UseBetterMonitors.Value)
			{
				if ((Object)(object)_newMonitors != (Object)null)
				{
					_newMonitors.TogglePower(on);
				}
			}
			else if (!_usingAnyMonitorTweaks)
			{
				if ((Object)(object)_originalProfitQuotaBG != (Object)null)
				{
					((Behaviour)_originalProfitQuotaBG).enabled = on;
				}
				if ((Object)(object)_originalProfitQuotaText != (Object)null)
				{
					((Behaviour)_originalProfitQuotaText).enabled = on;
				}
				if ((Object)(object)_originalDeadlineBG != (Object)null)
				{
					((Behaviour)_originalDeadlineBG).enabled = on;
				}
				if ((Object)(object)_originalDeadlineText != (Object)null)
				{
					((Behaviour)_originalDeadlineText).enabled = on;
				}
			}
			else
			{
				if (!((Object)(object)_UIContainer != (Object)null))
				{
					return;
				}
				if (Plugin.ShowBlueMonitorBackground.Value)
				{
					Image[] componentsInChildren = ((Component)_UIContainer).GetComponentsInChildren<Image>(on);
					foreach (Image val in componentsInChildren)
					{
						((Component)val).gameObject.SetActive(on);
					}
				}
				TextMeshProUGUI[] componentsInChildren2 = ((Component)_UIContainer).GetComponentsInChildren<TextMeshProUGUI>(on);
				foreach (TextMeshProUGUI val2 in componentsInChildren2)
				{
					((Component)val2).gameObject.SetActive(on);
				}
			}
		}

		public static void UpdateMapMaterial(Material newMaterial)
		{
			if ((Object)(object)_newMonitors != (Object)null)
			{
				_newMonitors.UpdateMapMaterial(newMaterial);
			}
		}
	}
	internal class NetworkHelper : NetworkBehaviour
	{
		public static NetworkHelper Instance { get; private set; }

		private void Start()
		{
			Instance = this;
		}

		[Cl