Decompiled source of DailyQuota v2.6.0

DailyQuota.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterShipScreens;
using DailyQuota.NetcodePatcher;
using Friskzips.Compatibility;
using Friskzips.patch;
using GameNetcodeStuff;
using GeneralImprovements;
using GeneralImprovements.API;
using GeneralImprovements.Assets;
using GeneralImprovements.Utilities;
using HarmonyLib;
using LethalConfig;
using LethalConfig.ConfigItems;
using LethalConfig.ConfigItems.Options;
using LethalFixes;
using LethalNetworkAPI;
using LethalNetworkAPI.Utils;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("BetterShipScreens")]
[assembly: IgnoresAccessChecksTo("GeneralImprovements")]
[assembly: IgnoresAccessChecksTo("uk.1a3.lethalfixes")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: AssemblyCompany("DailyQuota")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3-alpha.0.2+8b2da66df728d4504593eb40d1802a75a0321995")]
[assembly: AssemblyProduct("DailyQuota")]
[assembly: AssemblyTitle("DailyQuota")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Friskzips
{
	public class Config
	{
		private static ConfigFile file;

		public static ConfigEntry<int> PercentageOfQuotaToReach;

		public static ConfigEntry<int> PercentageOfQuotaForPenalty;

		public static ConfigEntry<bool> ScalingQuota;

		public static ConfigEntry<int> PercentageOfQuotaToScale;

		public static ConfigEntry<bool> GI_CreateMonitor;

		public static ConfigEntry<int> GI_MonitorIndex;

		public static ConfigEntry<bool> BetterPlayerCheck;

		public static ConfigEntry<bool> BetterScrapFlag;

		public static void CreateConfig()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Plugin.Log.LogDebug((object)"Creating config");
			file = new ConfigFile(Path.Combine(Paths.ConfigPath, "Friskzips.DailyQuota.cfg"), true);
			Plugin.Log.LogDebug((object)"Created the file");
			if (file == null)
			{
				Plugin.Log.LogError((object)"Created the file");
				return;
			}
			PercentageOfQuotaToReach = file.Bind<int>("Quota", "DailyQuota to reach", 20, "The daily quota that you need to reach in percentage of scrap in the planet\nRange 0 to 100");
			PercentageOfQuotaForPenalty = file.Bind<int>("Quota", "DailyQuota penalty percentage", 25, "The daily quota penalty to add in percentage of the quota\nRange 0 to 1000");
			ScalingQuota = file.Bind<bool>("Quota scaling", "DailyQuota scaling", true, "Makes the quota scale based on player amount(the quota start scaling after the second player)");
			PercentageOfQuotaToScale = file.Bind<int>("Quota scaling", "DailyQuota scaling percentage", 5, "The daily quota to add in percentage of the quota depending on the amount of players\nRange 0 to 30");
			GI_CreateMonitor = file.Bind<bool>("GeneralImprovements compat", "Create a custom monitor", true, "This config create a custom monitor for general improvements(the compatibility still works but it's gonna normally hook to the quota monitor) you can choose the monitor with the index");
			GI_MonitorIndex = file.Bind<int>("GeneralImprovements compat", "Monitor index", 1, "Choose where the monitor should be(8 is the limit when not using AddMoreBetterMonitors config but when using the BetterMonitors config 9 is the limit)\nRange 1 to 14");
			BetterPlayerCheck = file.Bind<bool>("Experimental", "Alive player check", false, "This should fix sometimes the game softlocking after everyone dies because the game thinks that there are more players alive(this can cause problems if for some reason a player stays dead at the start of a round)");
			BetterScrapFlag = file.Bind<bool>("Experimental", "Persistent scrap check", false, "This makes sure that the scraps gets properly flagged as persistent scrap");
		}

		internal static void LoadConfig()
		{
			if (PercentageOfQuotaForPenalty.Value > 1000 || PercentageOfQuotaForPenalty.Value < 0)
			{
				Plugin.Log.LogWarning((object)"Config DailyQuota penalty is broken using normal values");
				PercentageOfQuotaForPenalty.Value = 25;
			}
			if (PercentageOfQuotaToReach.Value > 100 || PercentageOfQuotaToReach.Value < 0)
			{
				Plugin.Log.LogWarning((object)"Config DailyQuota to reach is broken using normal values");
				PercentageOfQuotaToReach.Value = 20;
			}
			if (PercentageOfQuotaToScale.Value > 30 || PercentageOfQuotaToScale.Value < 0)
			{
				Plugin.Log.LogWarning((object)"Config DailyQuota to reach is broken using normal values");
				PercentageOfQuotaToScale.Value = 5;
			}
			Penalty.penaltyPercentage = PercentageOfQuotaForPenalty.Value;
			if (LNetworkUtils.IsConnected)
			{
				Game.quotaPenaltyMessage.SendClients((int)Penalty.penaltyPercentage);
				Plugin.Log.LogDebug((object)"Sent config to clients");
			}
			Plugin.Log.LogDebug((object)("QuotaPenalty: " + Penalty.penaltyPercentage));
			Plugin.Log.LogDebug((object)"Config loaded server");
		}
	}
	internal class DailyQuotaUI : MonoBehaviour
	{
		public static AssetBundle DailyQuotaAssets;

		private static bool loaded;

		internal static bool error;

		internal float startValue = 0f;

		internal float duration = 3f;

		private float elapsedTime = 0f;

		private float timeToReach = 0f;

		internal static Image spriteRenderer;

		internal static Color spriteColor;

		internal static TextMeshProUGUI spriteText;

		internal static bool showUI;

		internal static DailyQuotaUI Instance { get; set; }

		internal static bool LoadUI()
		{
			if (loaded)
			{
				return false;
			}
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			DailyQuotaAssets = AssetBundle.LoadFromFile(Path.Combine(directoryName, "dailyquotaui"));
			if ((Object)(object)DailyQuotaAssets == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Failed to load AssetBundle!");
				return false;
			}
			Plugin.Log.LogInfo((object)"AsssetBundle loaded!");
			loaded = true;
			return true;
		}

		[HarmonyPatch(typeof(HUDManager), "Awake")]
		[HarmonyPostfix]
		internal static void InitializaUI()
		{
			Plugin.Log.LogInfo((object)"Initializing UI...");
			if (loaded && !error)
			{
				Transform transform = HUDManager.Instance.HUDContainer.transform;
				Plugin.Log.LogDebug((object)("Attaching DailyQuotaUI to :" + (object)transform));
				string[] allAssetNames = DailyQuotaAssets.GetAllAssetNames();
				for (int i = 0; i < allAssetNames.Length; i++)
				{
					Plugin.Log.LogDebug((object)("Asset: " + allAssetNames[i]));
				}
				GameObject val = DailyQuotaAssets.LoadAsset<GameObject>("assets/dailyquotaui.prefab");
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Log.LogWarning((object)"Couldn't initialize the UI");
					error = true;
					return;
				}
				GameObject val2 = Object.Instantiate<GameObject>(val);
				GameObject val3 = Object.Instantiate<GameObject>(val2, transform);
				DailyQuotaUI dailyQuotaUI = val3.AddComponent<DailyQuotaUI>();
				Object.Destroy((Object)(object)val2);
				Plugin.Log.LogInfo((object)"UI initialized");
			}
		}

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Log.LogInfo((object)"UI awaked");
			Instance = this;
			RectTransform component = ((Component)this).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			((Component)this).gameObject.transform.localPosition = new Vector3(777f, 0f, 0f);
			spriteRenderer = ((Component)this).GetComponentInChildren<Image>();
			if ((Object)(object)spriteRenderer == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Couldn't find the sprite render");
				error = true;
				return;
			}
			spriteColor = ((Graphic)spriteRenderer).color;
			spriteColor.a = 0.5f;
			((Graphic)spriteRenderer).color = spriteColor;
			((Component)this).gameObject.SetActive(false);
			TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren<TextMeshProUGUI>();
			if (componentsInChildren == null)
			{
				Plugin.Log.LogWarning((object)"Couldn't find the sprite text");
				error = true;
				return;
			}
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (((Object)componentsInChildren[i]).name == "CreditText (TMP)")
				{
					spriteText = componentsInChildren[i];
				}
			}
			((TMP_Text)spriteText).font = ((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).font;
		}

		private void Update()
		{
			float num = 0f;
			float num2 = 0f;
			if (showUI)
			{
				((Component)this).gameObject.SetActive(true);
				elapsedTime += Time.deltaTime;
				if (elapsedTime >= 1f)
				{
					num = Mathf.Clamp01((elapsedTime - 1f) / duration);
					num2 = Mathf.Lerp(startValue, (float)Game.scrapQuota, num);
					Plugin.Log.LogDebug((object)("QuotaUI Current value: " + num2));
					((TMP_Text)spriteText).text = "$" + MathF.Round(num2);
				}
				else
				{
					((TMP_Text)spriteText).text = "$0";
					((Component)this).gameObject.SetActive(true);
				}
			}
			if (num2 >= (float)Game.scrapQuota && timeToReach == 0f)
			{
				timeToReach = elapsedTime + 2f;
			}
			if (elapsedTime >= timeToReach && timeToReach != 0f)
			{
				showUI = false;
				((Component)this).gameObject.SetActive(false);
				elapsedTime = 0f;
				timeToReach = 0f;
			}
		}

		internal static void ShowUI()
		{
			((Component)Instance).gameObject.SetActive(true);
			showUI = true;
		}
	}
	public static class ModInfo
	{
		public const string GUID = "Friskzips.DailyQuota";

		public const string NAME = "DailyQuota";

		public const string VERSION = "2.6.0";
	}
	[BepInPlugin("Friskzips.DailyQuota", "DailyQuota", "2.6.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal readonly Harmony _harmony = new Harmony("Friskzips.DailyQuota");

		public static Plugin Instance { get; set; }

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		public Plugin()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Instance = this;
		}

		private void Awake()
		{
			try
			{
				Config.CreateConfig();
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Error during config creation: " + ex.Message));
			}
			if (Config.PercentageOfQuotaForPenalty == null)
			{
				Log.LogError((object)"Error while accessing a config entry");
			}
			Log.LogDebug((object)"Checking for Lethal fixes...");
			if (LethalFixes_Compatibility.Enabled)
			{
				Log.LogInfo((object)"LethalFixes found!");
				_harmony.PatchAll(typeof(LethalFixes_Compatibility));
			}
			Log.LogDebug((object)"Checking for LethalConfig...");
			if (LethalConfig_Compatibility.Enabled)
			{
				Log.LogInfo((object)"LethalConfig found!");
				LethalConfig_Compatibility.CreateConfig();
			}
			Log.LogDebug((object)"Checking for BetterShipScreens...");
			if (BetterShipScreens_Compatibility.Enabled)
			{
				Log.LogInfo((object)"BetterShipScreens found!");
				Monitor.useDefaultMonitor = false;
				_harmony.PatchAll(typeof(BetterShipScreens_Compatibility));
			}
			Log.LogInfo((object)"Applying patches...");
			ApplyPluginPatch();
			Log.LogInfo((object)"Patches applied");
		}

		private void ApplyPluginPatch()
		{
			_harmony.PatchAll(typeof(Game));
			_harmony.PatchAll(typeof(Monitor));
			_harmony.PatchAll(typeof(ResetStuff));
			_harmony.PatchAll(typeof(Penalty));
			_harmony.PatchAll(typeof(LeverAlert));
			_harmony.PatchAll(typeof(DailyQuotaUI));
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "DailyQuota";

		public const string PLUGIN_NAME = "DailyQuota";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace Friskzips.patch
{
	public class Game
	{
		public static LNetworkMessage<int> quotaToReachMessage = LNetworkMessage<int>.Connect("scrapQuota", (Action<int, ulong>)null, (Action<int>)ClientQuotaToReachEvent, (Action<int, ulong>)null);

		public static LNetworkMessage<int> quotaPenaltyMessage = LNetworkMessage<int>.Connect("penaltyPercentage", (Action<int, ulong>)null, (Action<int>)ClientQuotaPenaltyEvent, (Action<int, ulong>)null);

		public static LNetworkMessage<int> scrapInShipMessage = LNetworkMessage<int>.Connect("scrapInShip", (Action<int, ulong>)null, (Action<int>)ClientScrapInShipEvent, (Action<int, ulong>)null);

		public static LNetworkMessage<int> betterPlayerCheck = LNetworkMessage<int>.Connect("scrapInShip", (Action<int, ulong>)null, (Action<int>)ClientBetterPlayerCheckEvent, (Action<int, ulong>)null);

		internal static PlayerControllerB player = null;

		internal static bool challengeFile = false;

		internal static int curLevel = 0;

		internal static int scrapValue;

		internal static int scrapQuota;

		internal static int scrapInShip;

		internal static bool noScrapFound = false;

		internal static bool started;

		internal static bool startedClient;

		internal static float showQuotaReachedText = 3f;

		internal static CanvasGroup quotaReachedCanvas;

		[HarmonyPatch(typeof(PlayerControllerB))]
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void getPlayer(PlayerControllerB __instance)
		{
			LethalConfig_Compatibility.canModifyMainMenu = false;
			player = __instance;
			Plugin.Log.LogDebug((object)"getPlayer runned");
		}

		[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
		[HarmonyPostfix]
		internal static void CheckForShipScrapAtTheStartOfGame()
		{
			if (!LNetworkUtils.IsHostOrServer || !Config.BetterScrapFlag.Value)
			{
				return;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			for (int i = 0; i < array.Length; i++)
			{
				Plugin.Log.LogDebug((object)(((Object)array[i]).name + " is ship: " + array[i].scrapPersistedThroughRounds));
				if (!array[i].scrapPersistedThroughRounds)
				{
					Plugin.Log.LogWarning((object)"Scrap isn't properly flagged as persistent");
					array[i].scrapPersistedThroughRounds = true;
				}
			}
		}

		[HarmonyPriority(0)]
		[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
		[HarmonyPrefix]
		internal static void GetRoundScrapValue(ref StartOfRound __instance)
		{
			LethalConfig_Compatibility.canModify = false;
			Monitor.defaultMonitorText = ((TMP_Text)__instance.profitQuotaMonitorText).text;
			scrapValue = 0;
			started = false;
			curLevel = __instance.currentLevel.levelID;
			if (LNetworkUtils.IsHostOrServer)
			{
				Config.LoadConfig();
			}
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == "ProfitQuotaMet")
				{
					Plugin.Log.LogDebug((object)("Found object: " + ((Object)val).name));
					quotaReachedCanvas = val.GetComponent<CanvasGroup>();
					break;
				}
			}
			if ((Object)(object)quotaReachedCanvas == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Couldn't find the quotaReachedCanvas!");
			}
			if (curLevel == 3 || challengeFile)
			{
				return;
			}
			if (LNetworkUtils.IsHostOrServer)
			{
				GrabbableObject[] array3 = Object.FindObjectsOfType<GrabbableObject>();
				if (Config.BetterPlayerCheck.Value)
				{
					__instance.livingPlayers = GameNetworkManager.Instance.connectedPlayers;
					Plugin.Log.LogDebug((object)("Living players: " + __instance.livingPlayers));
					ClientBetterPlayerCheckEvent(__instance.livingPlayers);
				}
				for (int j = 0; j < array3.Length; j++)
				{
					if (array3[j].itemProperties.isScrap && !array3[j].isInShipRoom && !array3[j].isInElevator)
					{
						scrapValue += array3[j].scrapValue;
					}
				}
				Plugin.Log.LogDebug((object)("Total scrap value: " + scrapValue));
				scrapQuota = (int)((float)scrapValue * ((float)Config.PercentageOfQuotaToReach.Value / 100f));
				if (Config.ScalingQuota.Value)
				{
					Plugin.Log.LogDebug((object)("Calculating DailyQuota based on players: " + GameNetworkManager.Instance.connectedPlayers));
					Plugin.Log.LogDebug((object)("Scrap value to reach normal: " + scrapQuota));
					scrapQuota += (int)((float)scrapValue * ((float)Config.PercentageOfQuotaToScale.Value / 100f)) * (GameNetworkManager.Instance.connectedPlayers - 1);
				}
				if (scrapQuota > scrapValue)
				{
					Plugin.Log.LogInfo((object)"Scrap quota is more than the scrap on the level, updating ScrapQuota");
					scrapQuota = scrapValue;
				}
				if (LNetworkUtils.IsConnected)
				{
					quotaToReachMessage.SendClients(scrapQuota);
				}
				Plugin.Log.LogDebug((object)("Scrap value to reach: " + scrapQuota));
				if (scrapQuota <= 0)
				{
					noScrapFound = true;
					return;
				}
				started = true;
				DailyQuotaUI.ShowUI();
			}
			else
			{
				startedClient = true;
			}
		}

		internal static void ClientQuotaToReachEvent(int value)
		{
			if (!((NetworkBehaviour)player).IsHost)
			{
				Plugin.Log.LogDebug((object)"Sent QuotaToReach event values from host: ");
				Plugin.Log.LogDebug((object)("Value1: " + value));
				if (startedClient)
				{
					startedClient = false;
					started = true;
					scrapQuota = value;
					Plugin.Log.LogWarning((object)"Value updated");
					DailyQuotaUI.ShowUI();
				}
			}
		}

		internal static void ClientScrapInShipEvent(int value)
		{
			if (!LNetworkUtils.IsHostOrServer)
			{
				Plugin.Log.LogDebug((object)"Sent scrapInShip event values from host: ");
				Plugin.Log.LogDebug((object)("Value1: " + value));
				scrapInShip = value;
				Plugin.Log.LogWarning((object)"Value updated");
			}
		}

		internal static void ClientQuotaPenaltyEvent(int value)
		{
			if (!((NetworkBehaviour)player).IsHost)
			{
				Plugin.Log.LogDebug((object)"Sent quotaPenalty event values from host: ");
				Plugin.Log.LogDebug((object)("Value1: " + value));
				Penalty.penaltyPercentage = value;
				Plugin.Log.LogWarning((object)"Value updated");
			}
		}

		internal static void ClientBetterPlayerCheckEvent(int value)
		{
			if (!((NetworkBehaviour)player).IsHost)
			{
				Plugin.Log.LogDebug((object)"Sent livingPlayers event values from host: ");
				Plugin.Log.LogDebug((object)("Value1: " + value));
				StartOfRound.Instance.livingPlayers = value;
				Plugin.Log.LogWarning((object)"Value updated");
			}
		}

		[HarmonyPatch(typeof(HUDManager))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void MainModUpdateMethod(ref HUDManager __instance)
		{
			if (((NetworkBehaviour)player).IsHost && LNetworkUtils.IsConnected)
			{
				int num = scrapInShip;
				scrapInShip = StartOfRound.Instance.GetValueOfAllScrap(true, true);
				if (scrapInShip != num)
				{
					scrapInShipMessage.SendClients(scrapInShip);
				}
			}
			if (noScrapFound)
			{
				Plugin.Log.LogWarning((object)"Throwing an alert because it's impossible to calculate the DailyQuota for the current planet/moon whatever you call them");
				noScrapFound = false;
				__instance.DisplayTip("Warning!", "The company couldn't calculate a DailyQuota for this moon.", false, false, "LC_Tip1");
			}
			if (showQuotaReachedText > 0f)
			{
				showQuotaReachedText -= 1f * Time.deltaTime;
			}
			if (scrapInShip >= scrapQuota && started)
			{
				started = false;
				__instance.reachedProfitQuotaAnimator.SetBool("display", true);
				__instance.UIAudio.PlayOneShot(__instance.reachedQuotaSFX);
				((TMP_Text)__instance.reachedProfitQuotaBonusText).text = "";
				showQuotaReachedText = 5f;
			}
			else if (showQuotaReachedText < 2f && showQuotaReachedText > 1f)
			{
				__instance.reachedProfitQuotaAnimator.SetBool("display", false);
				if ((Object)(object)quotaReachedCanvas == (Object)null)
				{
					Plugin.Log.LogWarning((object)"Couldn't find the quotaReachedCanvas!");
				}
				else
				{
					quotaReachedCanvas.alpha = 0f;
				}
			}
			else if (showQuotaReachedText < 1f && showQuotaReachedText > 0f)
			{
				Monitor.defaultMonitor = true;
				if ((Object)(object)quotaReachedCanvas == (Object)null)
				{
					Plugin.Log.LogWarning((object)"Couldn't find the quotaReachedCanvas!");
				}
				else
				{
					quotaReachedCanvas.alpha = 0.65f;
				}
			}
		}
	}
	internal class LeverAlert
	{
		internal static bool showAlert;

		private static bool triggerLeverReset;

		[HarmonyPatch(typeof(StartMatchLever))]
		[HarmonyPatch("BeginHoldingInteractOnLever")]
		[HarmonyPostfix]
		private static void CheckForLever(ref StartMatchLever __instance)
		{
			if (Game.started)
			{
				Plugin.Log.LogDebug((object)"You still need to met the quota");
				__instance.triggerScript.timeToHold = 4f;
				showAlert = true;
			}
		}

		[HarmonyPatch(typeof(HUDManager))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void ShowAlert(ref HUDManager __instance)
		{
			if (showAlert && !triggerLeverReset)
			{
				Plugin.Log.LogDebug((object)"Throwing an alert");
				triggerLeverReset = true;
				showAlert = false;
				__instance.DisplayTip("HALT!", "You haven't met the daily quota! If you attempt to take off you will face a penalty!", true, false, "LC_Tip1");
			}
		}

		[HarmonyPatch(typeof(StartMatchLever))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void ResetLeverTime(ref StartMatchLever __instance)
		{
			if (triggerLeverReset && !Game.started)
			{
				Plugin.Log.LogDebug((object)"The lever time to hold is resetted");
				__instance.triggerScript.timeToHold = 0.7f;
				triggerLeverReset = false;
				showAlert = false;
			}
		}
	}
	internal class Monitor
	{
		internal static bool useDefaultMonitor = true;

		internal static int quotaText = 0;

		internal static float timer;

		internal static bool defaultMonitor = false;

		internal static string defaultMonitorText;

		internal static bool triggeredOnce = false;

		[HarmonyPatch(typeof(StartOfRound))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdateMonitor(ref StartOfRound __instance)
		{
			if (GeneralImprovements_Compatibility.Enabled && Config.GI_CreateMonitor.Value)
			{
				GeneralImprovements_Compatibility.UpdateMonitor();
			}
			Game.challengeFile = __instance.isChallengeFile;
			if (defaultMonitor && useDefaultMonitor)
			{
				defaultMonitor = false;
				if (GeneralImprovements_Compatibility.Enabled)
				{
					GeneralImprovements_Compatibility.UpdateProfitQuotaMonitor();
					return;
				}
				((TMP_Text)__instance.profitQuotaMonitorText).text = "PROFIT QUOTA:\n$" + TimeOfDay.Instance.quotaFulfilled + "/$" + TimeOfDay.Instance.profitQuota;
			}
			if (Game.started && !Game.challengeFile)
			{
				timer += 1f * Time.deltaTime;
				if (timer > 5f)
				{
					timer = 0f;
					if (GeneralImprovements_Compatibility.Enabled && quotaText == 2 && GeneralImprovements_Compatibility.customMonitors)
					{
						defaultMonitorText = ((TMP_Text)__instance.profitQuotaMonitorText).text;
					}
					quotaText++;
				}
				if (quotaText != 0 && quotaText != 2 && triggeredOnce)
				{
					return;
				}
				if (GeneralImprovements_Compatibility.Enabled && GeneralImprovements_Compatibility.customMonitors)
				{
					GeneralImprovements_Compatibility.UpdateMonitor();
					return;
				}
				switch (quotaText)
				{
				case 0:
					((TMP_Text)__instance.profitQuotaMonitorText).text = "DAILY QUOTA:\n$" + Game.scrapInShip + "/$" + Game.scrapQuota;
					triggeredOnce = false;
					break;
				case 1:
					((TMP_Text)__instance.profitQuotaMonitorText).text = defaultMonitorText;
					triggeredOnce = true;
					break;
				case 2:
					quotaText = 0;
					break;
				}
			}
			else
			{
				timer = 0f;
				quotaText = 0;
			}
		}
	}
	internal class Penalty
	{
		internal static bool triggerOnce;

		internal static bool failed;

		internal static bool penalty;

		internal static bool penaltyScreen;

		internal static float penaltyPercentage;

		internal static int quota;

		internal static int oldQuota;

		private static int stateField;

		internal static void CheckForFailure()
		{
			if (Game.scrapInShip < Game.scrapQuota && !Game.challengeFile && Game.curLevel != 3)
			{
				failed = true;
				Plugin.Log.LogDebug((object)"Daily quota failed");
			}
		}

		private static bool getFailed()
		{
			Plugin.Log.LogDebug((object)"Getting the failed var");
			return failed;
		}

		private static bool getBack()
		{
			if (triggerOnce)
			{
				triggerOnce = false;
				Plugin.Log.LogDebug((object)"Going back");
				return true;
			}
			Plugin.Log.LogDebug((object)"not going back");
			return false;
		}

		private static int getStateField()
		{
			return stateField;
		}

		private static void setStateField(int a)
		{
			stateField = a;
		}

		private static void TriggerFailure()
		{
			Plugin.Log.LogDebug((object)"Triggering penality");
			penalty = true;
			failed = false;
			triggerOnce = true;
			StartOfRound.Instance.livingPlayers = 0;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(StartOfRound))]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static IEnumerable<CodeInstruction> PenaltyScreenTranspiler(IEnumerable<CodeInstruction> instructions, ILGenerator il)
		{
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Expected O, but got Unknown
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Expected O, but got Unknown
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Expected O, but got Unknown
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Expected O, but got Unknown
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Expected O, but got Unknown
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Expected O, but got Unknown
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Expected O, but got Unknown
			Plugin.Log.LogDebug((object)"Penalty screen transpiler is running...");
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			Plugin.Log.LogDebug((object)("instructions count: " + list.Count));
			MethodInfo methodInfo = AccessTools.Method(typeof(Penalty), "TriggerFailure", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Penalty), "getFailed", (Type[])null, (Type[])null);
			MethodInfo methodInfo3 = AccessTools.Method(typeof(Penalty), "getBack", (Type[])null, (Type[])null);
			MethodInfo methodInfo4 = AccessTools.Method(typeof(Penalty), "getStateField", (Type[])null, (Type[])null);
			MethodInfo methodInfo5 = AccessTools.Method(typeof(Penalty), "setStateField", (Type[])null, (Type[])null);
			FieldInfo field = typeof(StartOfRound).GetField("isChallengeFile", BindingFlags.Instance | BindingFlags.Public);
			ConstructorInfo constructorInfo = AccessTools.Constructor(typeof(WaitForSeconds), new Type[1] { typeof(float) }, false);
			if (methodInfo == null)
			{
				Plugin.Log.LogWarning((object)"The method TriggerFailure wasn't found.");
				return list;
			}
			if (methodInfo2 == null)
			{
				Plugin.Log.LogWarning((object)"The method getFailed wasn't found.");
				return list;
			}
			if (methodInfo3 == null)
			{
				Plugin.Log.LogWarning((object)"The method getBack wasn't found.");
				return list;
			}
			if (field == null)
			{
				Plugin.Log.LogWarning((object)"The variable isChallengeFile wasn't found.");
				return list;
			}
			if (constructorInfo == null)
			{
				Plugin.Log.LogWarning((object)"The constructor waitForSecondsCtor wasn't found.");
				return list;
			}
			if (methodInfo4 == null)
			{
				Plugin.Log.LogWarning((object)"The method getStateFieldMethod wasn't found.");
				return list;
			}
			if (methodInfo5 == null)
			{
				Plugin.Log.LogWarning((object)"The method setStateFieldMethod wasn't found.");
				return list;
			}
			Plugin.Log.LogDebug((object)("Stuff to find, opcode=" + OpCodes.Ldfld.ToString() + ", operand=" + "System.Boolean isChallengeFile"));
			int num = 0;
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].opcode == OpCodes.Ldfld && (FieldInfo)list[i].operand == field)
				{
					num++;
					if (num >= 6)
					{
						Plugin.Log.LogDebug((object)"Stuff found");
						Label label = il.DefineLabel();
						Label label2 = il.DefineLabel();
						list[i - 7].labels.Add(label);
						list[i + 12 + 1].labels.Add(label2);
						CodeInstruction val = new CodeInstruction(list[i + 15].opcode, list[i + 15].operand);
						CodeInstruction val2 = new CodeInstruction(list[i + 18].opcode, list[i + 18].operand);
						list.Insert(i - 7, new CodeInstruction(OpCodes.Call, (object)methodInfo2));
						list.Insert(i + 1 - 7, new CodeInstruction(OpCodes.Brfalse_S, (object)label));
						list.Insert(i + 2 - 7, new CodeInstruction(OpCodes.Call, (object)methodInfo));
						list.Insert(i + 3 - 7, new CodeInstruction(OpCodes.Br, (object)label2));
						list.Insert(i + 4 + 12 + 12, new CodeInstruction(OpCodes.Call, (object)methodInfo3));
						list.Insert(i + 5 + 12 + 12, new CodeInstruction(OpCodes.Brtrue_S, (object)label));
						return list.AsEnumerable();
					}
				}
			}
			Plugin.Log.LogWarning((object)"Penalty screen transpiler failed: couldn't find the needed instruction");
			return list.AsEnumerable();
		}

		[HarmonyPatch(typeof(HUDManager))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void ShowPenality(ref HUDManager __instance)
		{
			if (penaltyScreen)
			{
				__instance.endgameStatsAnimator.SetTrigger("displayPenalty");
				((TMP_Text)__instance.statsUIElements.penaltyAddition).text = "You haven't met the daily quota";
				((TMP_Text)__instance.statsUIElements.penaltyTotal).text = "Quota penalty:\n$" + oldQuota + "->$" + quota;
				penaltyScreen = false;
				Plugin.Log.LogDebug((object)"Penality screen");
			}
		}

		[HarmonyPatch(typeof(TimeOfDay))]
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void SetQuota(ref TimeOfDay __instance)
		{
			if (penalty)
			{
				oldQuota = __instance.profitQuota;
				quota = oldQuota + (int)((float)oldQuota * (penaltyPercentage / 100f));
				penalty = false;
				penaltyScreen = true;
				__instance.profitQuota = quota;
				Plugin.Log.LogDebug((object)"Changed quota");
				Monitor.defaultMonitor = true;
			}
		}
	}
	internal class ResetStuff
	{
		[HarmonyPatch(typeof(MenuManager))]
		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void MainMenu()
		{
			Plugin.Log.LogDebug((object)"Special Check for GeneralImprovements...");
			if (GeneralImprovements_Compatibility.Enabled && !GeneralImprovements_Compatibility.GM_Enabled)
			{
				Plugin.Log.LogInfo((object)"GeneralImprovements found!");
				GeneralImprovements_Compatibility.checkForCustomMonitor();
				if (LethalConfig_Compatibility.Enabled)
				{
					LethalConfig_Compatibility.CreateGMConfig();
				}
				GeneralImprovements_Patches.PatchClass();
				GeneralImprovements_Compatibility.GM_Enabled = true;
			}
			Plugin.Log.LogInfo((object)"Loading assets...");
			if (DailyQuotaUI.LoadUI())
			{
			}
			if (GeneralImprovements_Compatibility.Enabled)
			{
				GeneralImprovements_Patches.Reset();
			}
			LethalConfig_Compatibility.canModify = true;
			LethalConfig_Compatibility.canModifyMainMenu = true;
			Game.scrapInShip = 0;
			Game.player = null;
			Penalty.failed = false;
			Penalty.penalty = false;
			Penalty.penaltyScreen = false;
			Penalty.triggerOnce = false;
			Reset();
		}

		[HarmonyPatch(typeof(StartOfRound))]
		[HarmonyPatch("EndOfGame")]
		[HarmonyPrefix]
		private static void EndOfGame()
		{
			Penalty.CheckForFailure();
			Reset();
		}

		private static void Reset()
		{
			Game.showQuotaReachedText = 0f;
			Game.scrapQuota = 0;
			Game.started = false;
			LeverAlert.showAlert = false;
			Game.startedClient = false;
		}

		[HarmonyPatch(typeof(TimeOfDay))]
		[HarmonyPatch("OnDayChanged")]
		[HarmonyPrefix]
		private static void LateReset()
		{
			if (LethalConfig_Compatibility.Enabled)
			{
				LethalConfig_Compatibility.canModify = true;
			}
			if (!LNetworkUtils.IsHostOrServer || !Config.BetterScrapFlag.Value)
			{
				return;
			}
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			for (int i = 0; i < array.Length; i++)
			{
				Plugin.Log.LogDebug((object)(((Object)array[i]).name + " is ship: " + array[i].scrapPersistedThroughRounds));
				if (!array[i].scrapPersistedThroughRounds)
				{
					Plugin.Log.LogWarning((object)"Scrap isn't properly flagged as persistent");
					array[i].scrapPersistedThroughRounds = true;
				}
			}
		}
	}
}
namespace Friskzips.Compatibility
{
	internal class BetterShipScreens_Compatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("Swaggies.BetterShipScreens");
				}
				return _enabled.Value;
			}
		}

		[HarmonyPatch(typeof(Plugin))]
		[HarmonyPatch("UpdateShipScreens")]
		[HarmonyPrefix]
		internal static bool Fix_Monitor()
		{
			if (Monitor.quotaText == 0 && Game.started)
			{
				return false;
			}
			return true;
		}
	}
	internal class GeneralImprovements_Compatibility : MonoBehaviour
	{
		internal static bool? _enabled;

		internal static bool GM_Enabled = false;

		internal static int oldScrapInShip;

		internal static bool customMonitors = false;

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

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("ShaosilGaming.GeneralImprovements");
				}
				return _enabled.Value;
			}
		}

		internal static void checkForCustomMonitor()
		{
			customMonitors = true;
		}

		internal static void UpdateMonitor()
		{
			if (Config.GI_CreateMonitor.Value && GeneralImprovements_Patches.GM_monitorEnabled)
			{
				if (Penalty.failed && GeneralImprovements_Patches.GM_updateMonitor)
				{
					GeneralImprovements_Patches.GM_updateMonitor = false;
				}
				if ((Game.started || GeneralImprovements_Patches.GM_updateMonitor) && !Penalty.failed)
				{
					((TMP_Text)GeneralImprovements_Patches.GM_dailyQuotaText).text = "DAILY QUOTA:\n$" + Game.scrapInShip + "/$" + Game.scrapQuota;
					if (Plugin.UseBetterMonitors.Value && oldScrapInShip != Game.scrapInShip)
					{
						GeneralImprovements_MonitorVar.initializeClassInstance._queuedMonitorTextUpdates.Enqueue(GeneralImprovements_MonitorVar.GM_monitor);
						oldScrapInShip = Game.scrapInShip;
					}
					if (Game.started && !GeneralImprovements_Patches.GM_updateMonitor)
					{
						GeneralImprovements_Patches.GM_updateMonitor = true;
					}
					if (!Game.started)
					{
						GeneralImprovements_Patches.GM_updateMonitor = false;
						GeneralImprovements_Patches.GM_defaultMonitor = true;
					}
				}
				else if (GeneralImprovements_Patches.GM_defaultMonitor && !Game.started)
				{
					((TMP_Text)GeneralImprovements_Patches.GM_dailyQuotaText).text = "DAILY QUOTA:\nCurrently none";
					if (Plugin.UseBetterMonitors.Value)
					{
						Plugin.Log.LogDebug((object)"Setting monitors to normal");
						GeneralImprovements_MonitorVar.initializeClassInstance._queuedMonitorTextUpdates.Enqueue(GeneralImprovements_MonitorVar.GM_monitor);
					}
					GeneralImprovements_Patches.GM_defaultMonitor = false;
					oldScrapInShip = -1;
				}
				return;
			}
			switch (Monitor.quotaText)
			{
			case 0:
				if (Game.started)
				{
					MonitorsHelper.UpdateGenericTextList(MonitorsHelper._profitQuotaTexts, "DAILY QUOTA:\n$" + Game.scrapInShip + "/$" + Game.scrapQuota);
				}
				Monitor.triggeredOnce = false;
				break;
			case 1:
				MonitorsHelper.UpdateGenericTextList(MonitorsHelper._profitQuotaTexts, Monitor.defaultMonitorText);
				Monitor.triggeredOnce = true;
				break;
			case 2:
				Monitor.quotaText = 0;
				break;
			}
		}

		internal static void UpdateProfitQuotaMonitor()
		{
			Plugin.Log.LogInfo((object)"Profit quota updated");
			Monitor.defaultMonitorText = "PROFIT\n QUOTA:\n$" + TimeOfDay.Instance.quotaFulfilled + "/$" + TimeOfDay.Instance.profitQuota;
		}
	}
	internal class GeneralImprovements_Patches
	{
		public static TextMeshProUGUI GM_dailyQuotaText;

		public static bool GM_monitorEnabled = false;

		public static bool GM_updateMonitor = false;

		public static bool GM_defaultMonitor = true;

		internal static Material material = null;

		internal static TextMeshProUGUI init_text = null;

		internal static Transform monitor_object = null;

		internal static void PatchClass()
		{
			Plugin.Instance._harmony.PatchAll(typeof(GeneralImprovements_Patches));
		}

		internal static void Reset()
		{
			GM_monitorEnabled = false;
			GM_updateMonitor = false;
			GM_defaultMonitor = true;
		}

		[HarmonyPatch(typeof(Monitors))]
		[HarmonyPatch("Initialize")]
		[HarmonyPrefix]
		private static void GetMaterial(ref Monitors __instance)
		{
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			if (!Config.GI_CreateMonitor.Value)
			{
				return;
			}
			if (!Plugin.UseBetterMonitors.Value)
			{
				Plugin.Log.LogWarning((object)"General Improvements monitor couldn't get initialized because that index doesn't exist when AddMoreBetterMonitors is false");
				return;
			}
			int value = Config.GI_MonitorIndex.Value;
			if (value < 1 || value > 14 || (value > 9 && !Plugin.AddMoreBetterMonitors.Value))
			{
				return;
			}
			value--;
			Transform val = ((Component)__instance).transform.Find("Monitors/TopGroupL");
			Transform val2 = ((Component)__instance).transform.Find("Monitors/TopGroupM");
			Transform val3 = ((Component)__instance).transform.Find("Monitors/TopGroupR");
			Transform val4 = ((Component)__instance).transform.Find("Monitors/BigLeft");
			Transform val5 = ((Component)__instance).transform.Find("Monitors/BigMiddle");
			Transform val6 = ((Component)__instance).transform.Find("Monitors/BigRight");
			List<Transform> list = new List<Transform>();
			if (Plugin.AddMoreBetterMonitors.Value)
			{
				list.AddRange((IEnumerable<Transform>)(object)new Transform[2]
				{
					val.Find("Screen1"),
					val.Find("Screen2")
				});
			}
			list.AddRange((IEnumerable<Transform>)(object)new Transform[4]
			{
				val2.Find("Screen3"),
				val2.Find("Screen4"),
				val3.Find("Screen5"),
				val3.Find("Screen6")
			});
			if (Plugin.AddMoreBetterMonitors.Value)
			{
				list.AddRange((IEnumerable<Transform>)(object)new Transform[2]
				{
					val.Find("Screen7"),
					val.Find("Screen8")
				});
			}
			list.AddRange((IEnumerable<Transform>)(object)new Transform[4]
			{
				val2.Find("Screen9"),
				val2.Find("Screen10"),
				val3.Find("Screen11"),
				val3.Find("Screen12")
			});
			if (Plugin.AddMoreBetterMonitors.Value)
			{
				list.Add(val4.Find("LScreen"));
			}
			list.Add(val6.Find("RScreen"));
			MeshRenderer component = ((Component)list[value]).GetComponent<MeshRenderer>();
			material = ((Renderer)component).material;
			Plugin.Log.LogDebug((object)"Monitor material found");
			TextMeshProUGUI[] componentsInChildren = ((Component)((Component)__instance).transform.Find("Canvas/Texts")).GetComponentsInChildren<TextMeshProUGUI>();
			monitor_object = list[value];
			int num = 0;
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (Plugin.AddMoreBetterMonitors.Value || !new int[5] { 0, 1, 6, 7, 12 }.Contains(i))
				{
					if (num == value)
					{
						init_text = componentsInChildren[i];
						break;
					}
					num++;
				}
			}
			((TMP_Text)init_text).font = ((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).font;
			((TMP_Text)init_text).spriteAsset = ((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).spriteAsset;
			((Graphic)init_text).color = Plugin.MonitorTextColorVal;
			((TMP_Text)init_text).alignment = (TextAlignmentOptions)(Plugin.CenterAlignMonitorText.Value ? 514 : 257);
			Plugin.Log.LogDebug((object)"Monitor text found");
			GeneralImprovements_MonitorVar.initializeClassInstance = __instance;
		}

		[HarmonyPatch(typeof(TimeOfDay))]
		[HarmonyPatch("UpdateProfitQuotaCurrentTime")]
		[HarmonyPostfix]
		private static void DefaultMonitor()
		{
			GM_defaultMonitor = true;
		}

		[HarmonyPatch(typeof(MonitorsHelper))]
		[HarmonyPatch("CreateOldStyleMonitors")]
		[HarmonyPostfix]
		internal static void CreateOldStyleMonitor()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_010b: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: 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_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: 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_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			if (!Config.GI_CreateMonitor.Value)
			{
				return;
			}
			ConfigEntry<eMonitorNames>[] shipMonitorAssignments = Plugin.ShipMonitorAssignments;
			int value = Config.GI_MonitorIndex.Value;
			if (value < 1 || value > 14)
			{
				Plugin.Log.LogWarning((object)"General Improvements monitor couldn't get initialized properly because of a faulty monitor index");
				return;
			}
			if (value > 8)
			{
				Plugin.Log.LogWarning((object)"General Improvements monitor couldn't get initialized because that index doesn't exist when UseBetterMonitors and AddMoreBetterMonitors are false");
				return;
			}
			if (value == 7)
			{
				Plugin.Log.LogWarning((object)"You can't use the internal cam monitor with UseBetterMonitors off");
				return;
			}
			value--;
			if ((int)shipMonitorAssignments[value].Value != 0 && (int)shipMonitorAssignments[value].Value != 26 && (int)shipMonitorAssignments[value].Value != 25)
			{
				ManualLogSource log = Plugin.Log;
				eMonitorNames value2 = shipMonitorAssignments[value].Value;
				log.LogWarning((object)("Monitor is already used: " + ((object)(eMonitorNames)(ref value2)).ToString()));
				return;
			}
			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))
			};
			Plugin.Log.LogInfo((object)"Monitor found");
			Vector3 key = list[value].Key;
			Vector3 value3 = list[value].Value;
			if (Plugin.ShowBlueMonitorBackground.Value)
			{
				Image val = Object.Instantiate<Image>(MonitorsHelper._originalProfitQuotaBG, ((Component)MonitorsHelper._originalProfitQuotaBG).transform.parent);
				((Behaviour)val).enabled = true;
				((Object)val).name = "DailyQuotaMonitorBackground";
				((Component)val).transform.localPosition = MonitorsHelper._originalProfitQuotaLocation + key;
				((Component)val).transform.localEulerAngles = MonitorsHelper._originalProfitQuotaRotation + value3;
				MonitorsHelper._monitorBackgrounds.Add(val);
			}
			GM_dailyQuotaText = Object.Instantiate<TextMeshProUGUI>(MonitorsHelper._originalProfitQuotaText, ((TMP_Text)MonitorsHelper._originalProfitQuotaText).transform.parent);
			((Behaviour)GM_dailyQuotaText).enabled = true;
			((Object)GM_dailyQuotaText).name = "DailyQuotaMonitorText";
			((TMP_Text)GM_dailyQuotaText).transform.localPosition = MonitorsHelper._originalProfitQuotaLocation + key + new Vector3(0f, 0f, -1f);
			((TMP_Text)GM_dailyQuotaText).transform.localEulerAngles = MonitorsHelper._originalProfitQuotaRotation + value3 + new Vector3(1f, 0f, 0f);
			((Behaviour)GM_dailyQuotaText).enabled = true;
			((TMP_Text)GM_dailyQuotaText).text = "DAILY QUOTA:\nCurrently none";
			GM_monitorEnabled = true;
		}

		[HarmonyPatch(typeof(MonitorsHelper))]
		[HarmonyPatch("CreateNewStyleMonitors")]
		[HarmonyPostfix]
		private static void CreateNewStyleMonitor()
		{
			int value = Config.GI_MonitorIndex.Value;
			if (!Config.GI_CreateMonitor.Value)
			{
				return;
			}
			if (value < 1 || value > 14)
			{
				Plugin.Log.LogWarning((object)"General Improvements monitor couldn't get initialized properly because of a faulty monitor index");
				return;
			}
			if (value > 9 && !Plugin.AddMoreBetterMonitors.Value)
			{
				Plugin.Log.LogWarning((object)"General Improvements monitor couldn't get initialized because that index doesn't exist when AddMoreBetterMonitors is false");
				return;
			}
			value--;
			MonitorInfo val = MonitorsAPI.AllMonitors[value];
			if (((Object)val.AssignedMaterial).name != "BlackScreen")
			{
				Plugin.Log.LogWarning((object)"This general Improvements monitor is already used");
				return;
			}
			Plugin.Log.LogDebug((object)("Found a monitor: " + (object)val.AssignedMaterial));
			Plugin.Log.LogDebug((object)"Replacing material");
			val.AssignedMaterial = material;
			((Renderer)((Component)monitor_object).GetComponent<MeshRenderer>()).material = material;
			Plugin.Log.LogDebug((object)"Replacing text");
			val.TextCanvas = init_text;
			if ((Object)(object)val.Camera == (Object)null)
			{
				Plugin.Log.LogWarning((object)"This general Improvements monitor isn't initialized");
				return;
			}
			Plugin.Log.LogDebug((object)("Found the camera: " + (object)val.Camera));
			Plugin.Log.LogDebug((object)("Monitor name: " + ((Object)val.MeshRenderer).name));
			Plugin.Log.LogDebug((object)"TextCanvas is not initialized, creating one...");
			GM_dailyQuotaText = val.TextCanvas;
			GM_monitorEnabled = true;
			GeneralImprovements_MonitorVar.GM_monitor = val;
			GeneralImprovements_MonitorVar.initializeClassInstance._queuedMonitorTextUpdates.Enqueue(GeneralImprovements_MonitorVar.GM_monitor);
		}
	}
	internal class GeneralImprovements_MonitorVar
	{
		internal static Monitors initializeClassInstance;

		internal static MonitorInfo GM_monitor;
	}
	internal class LethalConfig_Compatibility
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static CanModifyDelegate <0>__ConfigCanModifyCallback;

			public static CanModifyDelegate <1>__ConfigCanModifyCallbackMainMenu;
		}

		internal static bool canModify;

		internal static bool canModifyMainMenu;

		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig");
				}
				return _enabled.Value;
			}
		}

		internal static void CreateConfig()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_002a: 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_0035: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			LethalConfigManager.SetModDescription("A mod that add a new mechanic, the DailyQuota!");
			ConfigEntry<int> percentageOfQuotaToReach = Config.PercentageOfQuotaToReach;
			IntSliderOptions val = new IntSliderOptions();
			IntSliderOptions obj = val;
			object obj2 = <>O.<0>__ConfigCanModifyCallback;
			if (obj2 == null)
			{
				CanModifyDelegate val2 = ConfigCanModifyCallback;
				<>O.<0>__ConfigCanModifyCallback = val2;
				obj2 = (object)val2;
			}
			((BaseOptions)obj).CanModifyCallback = (CanModifyDelegate)obj2;
			((BaseOptions)val).RequiresRestart = false;
			((BaseRangeOptions<int>)(object)val).Min = 0;
			((BaseRangeOptions<int>)(object)val).Max = 100;
			IntSliderConfigItem val3 = new IntSliderConfigItem(percentageOfQuotaToReach, val);
			ConfigEntry<int> percentageOfQuotaForPenalty = Config.PercentageOfQuotaForPenalty;
			val = new IntSliderOptions();
			IntSliderOptions obj3 = val;
			object obj4 = <>O.<0>__ConfigCanModifyCallback;
			if (obj4 == null)
			{
				CanModifyDelegate val4 = ConfigCanModifyCallback;
				<>O.<0>__ConfigCanModifyCallback = val4;
				obj4 = (object)val4;
			}
			((BaseOptions)obj3).CanModifyCallback = (CanModifyDelegate)obj4;
			((BaseOptions)val).RequiresRestart = false;
			((BaseRangeOptions<int>)(object)val).Min = 0;
			((BaseRangeOptions<int>)(object)val).Max = 1000;
			IntSliderConfigItem val5 = new IntSliderConfigItem(percentageOfQuotaForPenalty, val);
			ConfigEntry<int> percentageOfQuotaToScale = Config.PercentageOfQuotaToScale;
			val = new IntSliderOptions();
			IntSliderOptions obj5 = val;
			object obj6 = <>O.<0>__ConfigCanModifyCallback;
			if (obj6 == null)
			{
				CanModifyDelegate val6 = ConfigCanModifyCallback;
				<>O.<0>__ConfigCanModifyCallback = val6;
				obj6 = (object)val6;
			}
			((BaseOptions)obj5).CanModifyCallback = (CanModifyDelegate)obj6;
			((BaseOptions)val).RequiresRestart = false;
			((BaseRangeOptions<int>)(object)val).Min = 0;
			((BaseRangeOptions<int>)(object)val).Max = 30;
			IntSliderConfigItem val7 = new IntSliderConfigItem(percentageOfQuotaToScale, val);
			ConfigEntry<bool> scalingQuota = Config.ScalingQuota;
			BoolCheckBoxOptions val8 = new BoolCheckBoxOptions();
			BoolCheckBoxOptions obj7 = val8;
			object obj8 = <>O.<0>__ConfigCanModifyCallback;
			if (obj8 == null)
			{
				CanModifyDelegate val9 = ConfigCanModifyCallback;
				<>O.<0>__ConfigCanModifyCallback = val9;
				obj8 = (object)val9;
			}
			((BaseOptions)obj7).CanModifyCallback = (CanModifyDelegate)obj8;
			((BaseOptions)val8).RequiresRestart = false;
			BoolCheckBoxConfigItem val10 = new BoolCheckBoxConfigItem(scalingQuota, val8);
			ConfigEntry<bool> betterScrapFlag = Config.BetterScrapFlag;
			val8 = new BoolCheckBoxOptions();
			BoolCheckBoxOptions obj9 = val8;
			object obj10 = <>O.<0>__ConfigCanModifyCallback;
			if (obj10 == null)
			{
				CanModifyDelegate val11 = ConfigCanModifyCallback;
				<>O.<0>__ConfigCanModifyCallback = val11;
				obj10 = (object)val11;
			}
			((BaseOptions)obj9).CanModifyCallback = (CanModifyDelegate)obj10;
			((BaseOptions)val8).RequiresRestart = false;
			BoolCheckBoxConfigItem val12 = new BoolCheckBoxConfigItem(betterScrapFlag, val8);
			ConfigEntry<bool> betterPlayerCheck = Config.BetterPlayerCheck;
			val8 = new BoolCheckBoxOptions();
			BoolCheckBoxOptions obj11 = val8;
			object obj12 = <>O.<0>__ConfigCanModifyCallback;
			if (obj12 == null)
			{
				CanModifyDelegate val13 = ConfigCanModifyCallback;
				<>O.<0>__ConfigCanModifyCallback = val13;
				obj12 = (object)val13;
			}
			((BaseOptions)obj11).CanModifyCallback = (CanModifyDelegate)obj12;
			((BaseOptions)val8).RequiresRestart = false;
			BoolCheckBoxConfigItem val14 = new BoolCheckBoxConfigItem(betterPlayerCheck, val8);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val10);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val14);
		}

		internal static void CreateGMConfig()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			ConfigEntry<bool> gI_CreateMonitor = Config.GI_CreateMonitor;
			BoolCheckBoxOptions val = new BoolCheckBoxOptions();
			object obj = <>O.<1>__ConfigCanModifyCallbackMainMenu;
			if (obj == null)
			{
				CanModifyDelegate val2 = ConfigCanModifyCallbackMainMenu;
				<>O.<1>__ConfigCanModifyCallbackMainMenu = val2;
				obj = (object)val2;
			}
			((BaseOptions)val).CanModifyCallback = (CanModifyDelegate)obj;
			((BaseOptions)val).RequiresRestart = false;
			BoolCheckBoxConfigItem val3 = new BoolCheckBoxConfigItem(gI_CreateMonitor, val);
			ConfigEntry<int> gI_MonitorIndex = Config.GI_MonitorIndex;
			IntSliderOptions val4 = new IntSliderOptions();
			object obj2 = <>O.<1>__ConfigCanModifyCallbackMainMenu;
			if (obj2 == null)
			{
				CanModifyDelegate val5 = ConfigCanModifyCallbackMainMenu;
				<>O.<1>__ConfigCanModifyCallbackMainMenu = val5;
				obj2 = (object)val5;
			}
			((BaseOptions)val4).CanModifyCallback = (CanModifyDelegate)obj2;
			((BaseOptions)val4).RequiresRestart = false;
			((BaseRangeOptions<int>)(object)val4).Min = 1;
			((BaseRangeOptions<int>)(object)val4).Max = 14;
			IntSliderConfigItem val6 = new IntSliderConfigItem(gI_MonitorIndex, val4);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3);
			LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val6);
		}

		private static CanModifyResult ConfigCanModifyCallback()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (canModify)
			{
				return CanModifyResult.op_Implicit((true, ""));
			}
			return CanModifyResult.op_Implicit((false, "You can't change the values during the round"));
		}

		private static CanModifyResult ConfigCanModifyCallbackMainMenu()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (canModifyMainMenu)
			{
				return CanModifyResult.op_Implicit((true, ""));
			}
			return CanModifyResult.op_Implicit((false, "You can't change the values in game"));
		}
	}
	internal class LethalFixes_Compatibility
	{
		private static bool? _enabled;

		public static bool Enabled
		{
			get
			{
				if (!_enabled.HasValue)
				{
					_enabled = Chainloader.PluginInfos.ContainsKey("uk.1a3.lethalfixes");
				}
				return _enabled.Value;
			}
		}

		[HarmonyPatch(typeof(Patches_General))]
		[HarmonyPatch("Fix_LeverDeadline")]
		[HarmonyPrefix]
		internal static bool Fix_LeverDeadline_Override()
		{
			if (Game.started)
			{
				return false;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace DailyQuota.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}