Decompiled source of CompanyProtocols v0.3.0

LethalCompanyProtocols.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CompanyProtocols.Networking;
using CompanyProtocols.TerminalPatches;
using GameMecanicOverhaul;
using GameNetcodeStuff;
using HarmonyLib;
using LethalCompanyProtocols;
using LethalCompanyProtocols.NetcodePatcher;
using LethalNetworkAPI;
using LethalReplacementCrew;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
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("LethalCompanyProtocols")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalCompanyProtocols")]
[assembly: AssemblyTitle("LethalCompanyProtocols")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[HarmonyPatch(typeof(HUDManager))]
public class ClockPatch
{
	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void UpdateClockFluidly()
	{
		if ((Object)(object)TimeOfDay.Instance == (Object)null || (Object)(object)HUDManager.Instance?.clockNumber == (Object)null || HUDManager.Instance.Clock.canvasGroup.alpha <= 0f)
		{
			return;
		}
		float normalizedTimeOfDay = TimeOfDay.Instance.normalizedTimeOfDay;
		int num = (int)(normalizedTimeOfDay * 1080f);
		int num2 = num / 60 + 6;
		int num3 = num % 60;
		if (num2 >= 24)
		{
			((TMP_Text)HUDManager.Instance.clockNumber).text = "12:00 AM";
			return;
		}
		string arg = ((num2 >= 12) ? "PM" : "AM");
		int num4 = num2 % 12;
		if (num4 == 0)
		{
			num4 = 12;
		}
		((TMP_Text)HUDManager.Instance.clockNumber).text = $"{num4}:{num3:00} {arg}";
	}
}
[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
public class EnemyCalculator
{
	[HarmonyPrefix]
	private static void Prefix()
	{
		Plugin.IndoorEnemyNames.Clear();
		Plugin.OutdoorEnemyNames.Clear();
		EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>();
		EnemyAI[] array2 = array;
		foreach (EnemyAI val in array2)
		{
			if (!val.isEnemyDead)
			{
				string enemyName = val.enemyType.enemyName;
				if (val.isOutside)
				{
					Plugin.OutdoorEnemyNames.Add(enemyName);
				}
				else
				{
					Plugin.IndoorEnemyNames.Add(enemyName);
				}
			}
		}
	}
}
[HarmonyPatch(typeof(JesterAI), "Update")]
public class JesterAIPatch
{
	private static int previousStateCache = -1;

	private static float footstepTimer = 0f;

	public static void TriggerJesterFearEffect()
	{
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if ((Object)(object)localPlayerController != (Object)null && localPlayerController.isPlayerControlled && !localPlayerController.isPlayerDead)
		{
			localPlayerController.JumpToFearLevel(0.8f, true);
			HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
		}
	}

	public static void ShakeCameraByDistance(Vector3 jesterPosition, float maxDistance = 25f)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
		if ((Object)(object)localPlayerController == (Object)null || !localPlayerController.isPlayerControlled || localPlayerController.isPlayerDead)
		{
			return;
		}
		float num = Vector3.Distance(((Component)localPlayerController).transform.position, jesterPosition);
		if (num <= maxDistance)
		{
			if (num < 8f)
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)1);
			}
			else
			{
				HUDManager.Instance.ShakeCamera((ScreenShakeType)0);
			}
		}
	}

	[HarmonyPostfix]
	private static void Postfix(JesterAI __instance)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: 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)
		if (((EnemyAI)__instance).currentBehaviourStateIndex == 2 && previousStateCache != 2 && ((NetworkBehaviour)__instance).IsServer)
		{
			Networking.Instance.JesterPopEvent.InvokeClients();
		}
		previousStateCache = ((EnemyAI)__instance).currentBehaviourStateIndex;
		if (((EnemyAI)__instance).currentBehaviourStateIndex != 2 || ((EnemyAI)__instance).isEnemyDead)
		{
			return;
		}
		Vector3 velocity = ((EnemyAI)__instance).agent.velocity;
		float magnitude = ((Vector3)(ref velocity)).magnitude;
		if (magnitude > 0.5f)
		{
			footstepTimer -= Time.deltaTime * (magnitude * 0.45f);
			if (footstepTimer <= 0f)
			{
				ShakeCameraByDistance(((Component)__instance).transform.position, 30f);
				footstepTimer = 0.35f;
			}
		}
	}
}
namespace LethalCompanyProtocols
{
	[BepInPlugin("com.mrkixcat.companyprotocols", "Company Protocols", "0.3.0")]
	public class Plugin : BaseUnityPlugin
	{
		public class PlayerData
		{
			public string PlayerName = "";

			public bool IsAlive = true;

			public int Health = 100;

			public string CauseOfDeath = "";
		}

		public static Plugin Instance = null;

		public static ManualLogSource Log = null;

		private readonly Harmony harmony = new Harmony("com.mrkixcat.companyprotocols");

		public static ConfigEntry<string> ExcludedMoons = null;

		public static ConfigEntry<string> FinalMoon = null;

		public static ConfigEntry<float> BaseMultiplier = null;

		public static ConfigEntry<float> MultiplierIncrement = null;

		public static ConfigEntry<bool> EnableGameCoreOverhaul = null;

		public static ConfigEntry<bool> EnableMonstersRework = null;

		public static ConfigEntry<bool> EnableEndOfRoundStats = null;

		public static ConfigEntry<bool> EnableScrapScanner = null;

		public static ConfigEntry<bool> EnableBetterClock = null;

		public static ConfigEntry<bool> EnableVariableMoons = null;

		public static ConfigEntry<bool> UseQuotaLuck = null;

		public static ConfigEntry<int> MinMoons = null;

		public static ConfigEntry<int> MaxMoons = null;

		public static ConfigEntry<bool> PreventLastQuotaMoons = null;

		public static float CurrentRunMultiplier = 1f;

		public static List<string> VisitedMoonNames = new List<string>();

		public static List<string> ChosenMoonNames = new List<string>();

		public static List<int> MoonSeeds = new List<int>();

		public static int collectedScrapSurLune = 0;

		public static int totalScrapSurLune = 0;

		public static int TeamsPenalty = 0;

		public static int collectedNB = 0;

		public static int allNB = 0;

		public static List<string> IndoorEnemyNames = new List<string>();

		public static List<string> OutdoorEnemyNames = new List<string>();

		public static bool IsCustomMenuOpen = false;

		public static Dictionary<ulong, PlayerData> PlayersRegistry = new Dictionary<ulong, PlayerData>();

		public static List<string> LastQuotaMoonNames = new List<string>();

		public static void Init(ConfigFile config)
		{
			EnableGameCoreOverhaul = config.Bind<bool>("Server", "GameCoreOverhaul", false, "");
			EnableMonstersRework = config.Bind<bool>("Server", "MonstersRework", false, "");
			EnableScrapScanner = config.Bind<bool>("Server", "ScrapNumberScanner", false, "");
			UseQuotaLuck = config.Bind<bool>("Server", "QuotaLuck", false, "Use luck when calculating the profit quota.");
			ExcludedMoons = config.Bind<string>("Server", "Excluded Moons", "CompanyBuildingLevel,LiquidationLevel,ParadonLevel", "These moons will not be chosen.");
			FinalMoon = config.Bind<string>("Server", "Final Moon", "CompanyBuildingLevel", "Determine which moon will be the final one ( CompanyBuildingLevel by default ).");
			BaseMultiplier = config.Bind<float>("Server", "Base Multiplier", 1f, "Base multiplier of the first quota.");
			MultiplierIncrement = config.Bind<float>("Server", "Multiplier Increment", 0.5f, "How much are increasing future quotas.");
			EnableVariableMoons = config.Bind<bool>("Server", "Enable Variable Moon Count", false, "If true, the number of moons chosen each quota will be random between Min and Max.");
			MinMoons = config.Bind<int>("Server", "Min Moons", 2, "Minimum number of moons to select (Min 1).");
			MaxMoons = config.Bind<int>("Server", "Max Moons", 4, "Maximum number of moons to select.");
			PreventLastQuotaMoons = config.Bind<bool>("Server", "Prevent Last Quota Moons", true, "If true, moons from the previous quota won't appear in the next one.");
			EnableEndOfRoundStats = config.Bind<bool>("Client", "EndOfRoundStats", false, "");
			EnableBetterClock = config.Bind<bool>("Client", "BetterClock", false, "");
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				Init(((BaseUnityPlugin)this).Config);
				CurrentRunMultiplier = BaseMultiplier.Value;
				harmony.PatchAll(typeof(StartOfRoundPatch));
				if (EnableGameCoreOverhaul.Value)
				{
					harmony.PatchAll(typeof(QuotaPatch.SyncQuotaClientPatch));
					harmony.PatchAll(typeof(CustomDisplayNewDeadlinePatch));
					harmony.PatchAll(typeof(BeginHoldingInteractOnLeverPatch));
					harmony.PatchAll(typeof(ForceResetQuotaOnFiredPatch));
					harmony.PatchAll(typeof(ScrapTracker));
					harmony.PatchAll(typeof(QuotaPatch));
					harmony.PatchAll(typeof(WeatherSyncPatch));
					harmony.PatchAll(typeof(SaveLoadPatch));
					harmony.PatchAll(typeof(LaunchPatch));
					harmony.PatchAll(typeof(ReplacementCrewHandler));
					harmony.PatchAll(typeof(DeletePatch));
					harmony.PatchAll(typeof(TerminalDisplayPatch));
					harmony.PatchAll(typeof(OnDisconnectedPatch));
					harmony.PatchAll(typeof(HUDRemoverPatches));
					harmony.PatchAll(typeof(AutoLandingPatch));
					harmony.PatchAll(typeof(DisconnectPatch));
					harmony.PatchAll(typeof(EventHUDUtility));
					harmony.PatchAll(typeof(Networking));
					harmony.PatchAll(typeof(NetworkLifeCycle));
					harmony.PatchAll(typeof(MeteorShowerUIPatcher));
					harmony.PatchAll(typeof(EndRoundPatch));
					harmony.PatchAll(typeof(TerminalPricePatch));
					harmony.PatchAll(typeof(LandingTimeManager.LandingTimePatch));
					harmony.PatchAll(typeof(LandingTimeManager.RoundResetPatch));
					harmony.PatchAll(typeof(ForceDeadlineDisplayPatch));
					harmony.PatchAll(typeof(CustomBuyingRatePatch));
				}
				if (EnableMonstersRework.Value)
				{
					harmony.PatchAll(typeof(JesterAIPatch));
					harmony.PatchAll(typeof(Networking));
				}
				if (EnableEndOfRoundStats.Value)
				{
					harmony.PatchAll(typeof(ScrapTracker));
					harmony.PatchAll(typeof(EnemyCalculator));
					harmony.PatchAll(typeof(HUDRemoverPatches));
					harmony.PatchAll(typeof(GMO_UIManager));
					harmony.PatchAll(typeof(GMO_UIElements));
					harmony.PatchAll(typeof(GMO_Animations));
					harmony.PatchAll(typeof(DayEndPatch));
					harmony.PatchAll(typeof(ScrapScan));
					harmony.PatchAll(typeof(EndRoundStatsPatch));
					harmony.PatchAll(typeof(LevelUIPatch));
				}
				if (EnableScrapScanner.Value)
				{
					harmony.PatchAll(typeof(ScrapTracker));
					harmony.PatchAll(typeof(ScrapMessager));
				}
				if (EnableBetterClock.Value)
				{
					harmony.PatchAll(typeof(ClockPatch));
				}
				Networking.Init();
				Log.LogInfo((object)"Company Protocols loaded successfully");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Company Protocols can't load : " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		public static void SaveData()
		{
			try
			{
				string path = Path.Combine(Application.persistentDataPath, GameNetworkManager.Instance.currentSaveFileName + "_gmo.txt");
				string contents = string.Format("{0};{1};{2};{3};{4}", CurrentRunMultiplier, string.Join(",", MoonSeeds), string.Join(",", ChosenMoonNames), string.Join(",", VisitedMoonNames), TimeOfDay.Instance.profitQuota);
				File.WriteAllText(path, contents);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[SAVE ERROR] : " + ex.Message));
			}
		}

		public static void LoadData()
		{
			try
			{
				string path = Path.Combine(Application.persistentDataPath, GameNetworkManager.Instance.currentSaveFileName + "_gmo.txt");
				if (!File.Exists(path))
				{
					CurrentRunMultiplier = BaseMultiplier.Value;
					if (NetworkManager.Singleton.IsServer)
					{
						GenerateInitialQuota();
					}
					return;
				}
				string text = File.ReadAllText(path);
				string[] array = text.Split(';');
				if (array.Length >= 1)
				{
					float.TryParse(array[0], out CurrentRunMultiplier);
				}
				if (array.Length >= 2)
				{
					MoonSeeds = (from s in array[1].Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
						select int.Parse(s)).ToList();
				}
				if (array.Length >= 3)
				{
					ChosenMoonNames = array[2].Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
				}
				if (array.Length >= 4)
				{
					VisitedMoonNames = array[3].Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();
					int num = ChosenMoonNames.Count + 1 - VisitedMoonNames.Count;
					TimeOfDay.Instance.timeUntilDeadline = (float)num * TimeOfDay.Instance.totalTime;
					TimeOfDay.Instance.quotaVariables.deadlineDaysAmount = num;
					TimeOfDay.Instance.SyncTimeClientRpc(TimeOfDay.Instance.globalTime, (int)TimeOfDay.Instance.timeUntilDeadline);
					if ((Object)(object)StartOfRound.Instance.deadlineMonitorText != (Object)null)
					{
						((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = $"DEADLINE:\n {num} Days";
					}
				}
				if (array.Length >= 5 && int.TryParse(array[4], out var result))
				{
					TimeOfDay.Instance.profitQuota = result;
					if ((Object)(object)StartOfRound.Instance.profitQuotaMonitorText != (Object)null)
					{
						((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).text = $"PROFIT QUOTA:\n${TimeOfDay.Instance.quotaFulfilled}/{result}";
					}
					if ((Object)(object)HUDManager.Instance != (Object)null)
					{
						HUDManager.Instance.SetQuota(result, -1);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("[LOAD ERROR] : " + ex.Message));
			}
		}

		public static void GenerateInitialQuota()
		{
			if (NetworkManager.Singleton.IsServer)
			{
				TimeOfDay.Instance.SetNewProfitQuota();
			}
		}

		public static string GetTargetMoonsNames()
		{
			if (ChosenMoonNames == null || ChosenMoonNames.Count == 0)
			{
				return "None";
			}
			IEnumerable<string> enumerable = from l in StartOfRound.Instance.levels
				where (Object)(object)l != (Object)null && ChosenMoonNames.Contains(((Object)l).name)
				select ((Object)l).name.Replace("\n", "");
			return enumerable.Any() ? string.Join(", ", enumerable) : "Unknown";
		}
	}
}
namespace CompanyProtocols.TerminalPatches
{
	[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
	public class TerminalDisplayPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Terminal __instance, ref string __result)
		{
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Invalid comparison between Unknown and I4
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(__result) || Plugin.ChosenMoonNames == null || !__result.Contains("Welcome to the exomoons catalogue"))
			{
				return;
			}
			LandingTimeManager.GenerateLandingTimes();
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("\n\n\n");
			stringBuilder.AppendLine("<color=red>[ COMPANY TARGETS - ASSIGNED MISSIONS ]</color>");
			stringBuilder.AppendLine("---------------------------------------------------\n");
			SelectableLevel[] moonsCatalogueList = __instance.moonsCatalogueList;
			List<SelectableLevel> list = (from m in moonsCatalogueList
				where (Object)(object)m != (Object)null && Plugin.ChosenMoonNames.Contains(((Object)m).name) && !Plugin.VisitedMoonNames.Contains(((Object)m).name)
				orderby GetRiskScore(m.riskLevel)
				select m).ToList();
			if (!list.Any())
			{
				stringBuilder.AppendLine("<color=yellow>ALL TARGETS CLEARED.</color>\nNo further missions available.");
			}
			else
			{
				foreach (SelectableLevel item in list)
				{
					string arg = "<color=#FFFFFF>8.0h</color>";
					if (LandingTimeManager.MoonLandingTimes.TryGetValue(((Object)item).name, out MoonTimeData value))
					{
						string text = ((value.Type == LandingTimeType.Early) ? "#00FFFF" : ((value.Type != LandingTimeType.Late) ? "#FFFFFF" : "#FFA500"));
						string text2 = LandingTimeManager.FormatTimeToClock(value.TargetHour);
						arg = "<color=" + text + ">" + text2 + "</color>";
					}
					stringBuilder.AppendLine("> <b>" + item.PlanetName.ToUpper() + "</b>");
					string arg2 = (((int)item.currentWeather != -1) ? "#FFFF00" : "#FFFFFF");
					stringBuilder.AppendLine($"<size=80%><b>RISK:</b> {item.riskLevel.PadRight(4)} | <b>SCRAP:</b> {item.minScrap}-{item.maxScrap} (${(int)CalculateMoonScrapAverage(item)})</size>");
					stringBuilder.AppendLine($"<size=80%><b>INFO:</b> <color={arg2}>{item.currentWeather}</color> ({arg})</size>");
					stringBuilder.AppendLine(" ");
					stringBuilder.AppendLine("");
				}
			}
			stringBuilder.AppendLine("---------------------------------------------------");
			stringBuilder.AppendLine("[ Type moon name to route the ship ]\n");
			__result = stringBuilder.ToString();
		}

		private static int GetRiskScore(string risk)
		{
			if (string.IsNullOrEmpty(risk))
			{
				return 0;
			}
			if (risk.Contains("S"))
			{
				return 5;
			}
			if (risk.Contains("A"))
			{
				return 4;
			}
			if (risk.Contains("B"))
			{
				return 3;
			}
			if (risk.Contains("C"))
			{
				return 2;
			}
			if (risk.Contains("D"))
			{
				return 1;
			}
			return 1;
		}

		public static float CalculateMoonScrapAverage(SelectableLevel level)
		{
			if ((Object)(object)level == (Object)null || level.spawnableScrap == null || level.spawnableScrap.Count == 0)
			{
				return 0f;
			}
			float num = 0f;
			int num2 = 0;
			foreach (SpawnableItemWithRarity item in level.spawnableScrap)
			{
				num2 += item.rarity;
			}
			for (int i = 0; i < 500; i++)
			{
				int num3 = Random.Range(level.minScrap, level.maxScrap + 1);
				for (int j = 0; j < num3; j++)
				{
					num += GetWeightedRandomScrapValue(level.spawnableScrap, num2);
				}
			}
			return num / 500f;
		}

		private static float GetWeightedRandomScrapValue(List<SpawnableItemWithRarity> pool, int totalWeight)
		{
			int num = Random.Range(0, totalWeight);
			int num2 = 0;
			foreach (SpawnableItemWithRarity item in pool)
			{
				num2 += item.rarity;
				if (num < num2)
				{
					float num3 = Random.Range(item.spawnableItem.minValue, item.spawnableItem.maxValue);
					return num3 * 0.4f;
				}
			}
			return 0f;
		}
	}
	[HarmonyPatch(typeof(Terminal), "Start")]
	public class TerminalPricePatch
	{
		[HarmonyPostfix]
		private static void Postfix(Terminal __instance)
		{
			TerminalKeyword val = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword k) => k.word == "route"));
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			CompatibleNoun[] compatibleNouns = val.compatibleNouns;
			foreach (CompatibleNoun val2 in compatibleNouns)
			{
				if (!((Object)(object)val2.result != (Object)null))
				{
					continue;
				}
				val2.result.itemCost = 0;
				if (val2.result.terminalOptions == null)
				{
					continue;
				}
				CompatibleNoun[] terminalOptions = val2.result.terminalOptions;
				foreach (CompatibleNoun val3 in terminalOptions)
				{
					if ((Object)(object)val3.result != (Object)null)
					{
						val3.result.itemCost = 0;
					}
				}
			}
		}
	}
}
namespace CompanyProtocols.Networking
{
	public class Networking
	{
		public LNetworkVariable<string[]> ChosenMoonsVar;

		public LNetworkVariable<string[]> VisitedMoonsVar;

		public LNetworkVariable<int[]> MoonSeedsVar;

		public LNetworkMessage<string> HudAlertMsg;

		public LNetworkMessage<int> RequestSyncMsg;

		public LNetworkEvent JesterPopEvent = LNetworkEvent.Connect("JesterFear_PopEvent", (Action<ulong>)null, (Action)delegate
		{
			JesterAIPatch.TriggerJesterFearEffect();
		}, (Action<ulong>)null);

		public static Networking Instance { get; private set; }

		public Networking()
		{
			Instance = this;
			Plugin.Log.LogInfo((object)"[GMO Networking] Starting Initialization...");
			try
			{
				ChosenMoonsVar = LNetworkVariable<string[]>.Connect("GMO_ChosenMoons", new string[0], (LNetworkVariableWritePerms)0, (Action<string[], string[]>)delegate(string[] oldVal, string[] newVal)
				{
					if (newVal != null)
					{
						Plugin.ChosenMoonNames.Clear();
						Plugin.ChosenMoonNames = newVal.ToList();
					}
				});
				VisitedMoonsVar = LNetworkVariable<string[]>.Connect("GMO_VisitedMoons", new string[0], (LNetworkVariableWritePerms)0, (Action<string[], string[]>)delegate(string[] oldVal, string[] newVal)
				{
					if (newVal != null)
					{
						Plugin.VisitedMoonNames.Clear();
						Plugin.VisitedMoonNames = newVal.ToList();
					}
				});
				MoonSeedsVar = LNetworkVariable<int[]>.Connect("GMO_MoonSeeds", new int[0], (LNetworkVariableWritePerms)0, (Action<int[], int[]>)delegate(int[] oldVal, int[] newVal)
				{
					if (newVal != null)
					{
						Plugin.MoonSeeds.Clear();
						Plugin.MoonSeeds = newVal.ToList();
						LandingTimeManager.GenerateLandingTimes();
					}
				});
				Plugin.Log.LogInfo((object)"[GMO Networking] Variables connected.");
				HudAlertMsg = LNetworkMessage<string>.Connect("GMO_HudAlert", (Action<string, ulong>)null, (Action<string>)null, (Action<string, ulong>)null);
				RequestSyncMsg = LNetworkMessage<int>.Connect("GMO_RequestSync", (Action<int, ulong>)null, (Action<int>)null, (Action<int, ulong>)null);
				Plugin.Log.LogInfo((object)"[GMO Networking] Messages connected.");
				HudAlertMsg.OnClientReceived += delegate(string moonName)
				{
					Plugin.Log.LogInfo((object)("[GMO NetMsg] Received HUD Alert for: " + moonName));
					if ((Object)(object)HUDManager.Instance != (Object)null)
					{
						HUDManager.Instance.DisplayTip("DESTINATION CHANGED", "The Company deploys you on " + moonName + " !", true, false, "LC_Tip1");
					}
					else
					{
						Plugin.Log.LogWarning((object)"[GMO NetMsg] HUDManager.Instance is NULL, cannot display alert.");
					}
				};
				RequestSyncMsg.OnServerReceived += delegate(int val, ulong clientId)
				{
					Plugin.Log.LogInfo((object)$"[GMO NetMsg] Server received Sync Request from Client ID: {clientId}");
					if ((Object)(object)NetworkManager.Singleton != (Object)null && NetworkManager.Singleton.IsServer)
					{
						Plugin.Log.LogInfo((object)"[GMO NetMsg] Processing sync for client...");
						ChosenMoonsVar.Value = Plugin.ChosenMoonNames.ToArray();
						VisitedMoonsVar.Value = Plugin.VisitedMoonNames.ToArray();
						MoonSeedsVar.Value = Plugin.MoonSeeds.ToArray();
					}
					else
					{
						Plugin.Log.LogWarning((object)"[GMO NetMsg] RequestSync received but this peer is not the Server.");
					}
				};
				Plugin.Log.LogInfo((object)"[GMO Networking] All handlers hooked successfully.");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[GMO Networking] CRITICAL ERROR DURING INIT: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		public static void Init()
		{
			if (Instance == null)
			{
				Plugin.Log.LogInfo((object)"[GMO Networking] Initializing Singleton...");
				new Networking();
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class NetworkLifeCycle
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void SyncOnStartHost(StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsConnectedClient)
			{
				Networking.Instance.RequestSyncMsg.SendServer((int)NetworkManager.Singleton.LocalClientId);
			}
		}
	}
}
namespace LethalReplacementCrew
{
	[HarmonyPatch]
	public class ReplacementCrewHandler : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Item, bool> <>9__11_0;

			public static Func<PlayerControllerB, bool> <>9__11_1;

			public static Func<SpawnableEnemyWithRarity, bool> <>9__12_0;

			public static Func<PlayerControllerB, bool> <>9__12_1;

			public static Func<SpawnableEnemyWithRarity, bool> <>9__15_0;

			public static Func<PlayerControllerB, bool> <>9__15_1;

			public static HandleNamedMessageDelegate <>9__20_0;

			public static HandleNamedMessageDelegate <>9__20_1;

			internal bool <SpawnScrapScattered>b__11_0(Item item)
			{
				return item.isScrap && (Object)(object)item.spawnPrefab != (Object)null;
			}

			internal bool <SpawnScrapScattered>b__11_1(PlayerControllerB p)
			{
				return p.isPlayerControlled;
			}

			internal bool <SpawnMaskedOnGround>b__12_0(SpawnableEnemyWithRarity e)
			{
				return e.enemyType.enemyName.Contains("Masked");
			}

			internal bool <SpawnMaskedOnGround>b__12_1(PlayerControllerB p)
			{
				return p.isPlayerControlled;
			}

			internal bool <SpawnMaskedOnGround>b__15_0(SpawnableEnemyWithRarity e)
			{
				return e.enemyType.enemyName.Contains("Masked");
			}

			internal bool <SpawnMaskedOnGround>b__15_1(PlayerControllerB p)
			{
				return p.isPlayerControlled;
			}

			internal void <RegisterNetworkMessages>b__20_0(ulong senderId, FastBufferReader reader)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				if (!NetworkManager.Singleton.IsServer)
				{
					Vector3 pos = default(Vector3);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
					Quaternion rot = default(Quaternion);
					((FastBufferReader)(ref reader)).ReadValueSafe(ref rot);
					SpawnFakeShipLocal(pos, rot);
				}
			}

			internal void <RegisterNetworkMessages>b__20_1(ulong senderId, FastBufferReader reader)
			{
				if (!NetworkManager.Singleton.IsServer)
				{
					ShowIntrusionAlertLocal();
				}
			}
		}

		public static float heightOffset = 40f;

		private const string SHIP_SPAWN_MESSAGE = "ReplacementCrew_SpawnShip";

		private const string HUD_ALERT_MESSAGE = "ReplacementCrew_HUDAlert";

		private static GameObject FakeShipPrefab = null;

		private static bool hasEventOccurredThisLevel = false;

		private static int lastCheckedHour = -1;

		[HarmonyPatch(typeof(RoundManager), "FinishGeneratingLevel")]
		[HarmonyPostfix]
		private static void ResetLevelStatus()
		{
			hasEventOccurredThisLevel = false;
			lastCheckedHour = -1;
		}

		[HarmonyPatch(typeof(TimeOfDay), "Update")]
		[HarmonyPostfix]
		private static void CheckTimeForEvent(TimeOfDay __instance)
		{
			if (!NetworkManager.Singleton.IsServer || hasEventOccurredThisLevel)
			{
				return;
			}
			if (StartOfRound.Instance.inShipPhase || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null)
			{
				lastCheckedHour = -1;
				return;
			}
			float num = 7.85f;
			string name = ((Object)StartOfRound.Instance.currentLevel).name;
			if (LandingTimeManager.MoonLandingTimes.TryGetValue(name, out MoonTimeData value))
			{
				num = value.TargetHour;
			}
			float num2 = 6f + __instance.normalizedTimeOfDay * 18f;
			int num3 = (int)num2;
			if (num2 >= num + 4f && num3 != lastCheckedHour && num3 % 2 == 0)
			{
				lastCheckedHour = num3;
				if (Random.value < 0.025f)
				{
					hasEventOccurredThisLevel = true;
					((MonoBehaviour)RoundManager.Instance).StartCoroutine(ExecuteEventSequence());
				}
			}
		}

		private static IEnumerator ExecuteEventSequence()
		{
			GameObject[] nodes = GameObject.FindGameObjectsWithTag("OutsideAINode");
			if (nodes != null && nodes.Length != 0)
			{
				Transform targetNode = nodes[Random.Range(0, nodes.Length)].transform;
				Vector3 groundPosition = targetNode.position;
				Vector3 shipPosition = groundPosition + Vector3.up * heightOffset;
				SendAlertToAllClients();
				Quaternion flatRotation = Quaternion.Euler(0f, targetNode.eulerAngles.y, 0f);
				SpawnFakeShipLocal(shipPosition, flatRotation);
				SyncShipToClients(shipPosition, flatRotation);
				yield return (object)new WaitForSeconds(5f);
				yield return (object)new WaitForSeconds(10f);
				SpawnScrapScattered(groundPosition, 8f);
				yield return (object)new WaitForSeconds(1f);
				SpawnMaskedOnGround(groundPosition, 6f);
			}
		}

		private static void ShowIntrusionAlertLocal()
		{
			EventHUDUtility.DisplayWarning("EMERGENCY ATMOSPHERIC ALERT", "UNIDENTIFIED VESSEL DETECTED\nINTRUSION IN LUNAR AIRSPACE", HUDManager.Instance.meteorShowerWarningAudio);
		}

		private static Vector3 GetGuaranteedNavMeshPosition(Vector3 center, float radius, int maxAttempts = 30)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			NavMeshHit val3 = default(NavMeshHit);
			for (int i = 0; i < maxAttempts; i++)
			{
				Vector2 val = Random.insideUnitCircle * radius;
				Vector3 val2 = center + new Vector3(val.x, 0f, val.y);
				if (NavMesh.SamplePosition(val2, ref val3, 2f, -1))
				{
					return ((NavMeshHit)(ref val3)).position;
				}
			}
			NavMeshHit val4 = default(NavMeshHit);
			if (NavMesh.SamplePosition(center, ref val4, 5f, -1))
			{
				return ((NavMeshHit)(ref val4)).position;
			}
			return center;
		}

		private static void SpawnScrapScattered(Vector3 centerNodePos, float spawnRadius)
		{
			//IL_00d1: 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)
			//IL_00da: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			List<Item> list = StartOfRound.Instance.allItemsList.itemsList.Where((Item item) => item.isScrap && (Object)(object)item.spawnPrefab != (Object)null).ToList();
			if (list.Count == 0)
			{
				return;
			}
			int num = StartOfRound.Instance.allPlayerScripts.Count((PlayerControllerB p) => p.isPlayerControlled);
			int num2 = Random.Range(Mathf.Max(1, num / 2), num + 1);
			List<NetworkObjectReference> list2 = new List<NetworkObjectReference>();
			List<int> list3 = new List<int>();
			for (int num3 = 0; num3 < num2; num3++)
			{
				Item val = list[Random.Range(0, list.Count)];
				Vector3 guaranteedNavMeshPosition = GetGuaranteedNavMeshPosition(centerNodePos, spawnRadius);
				guaranteedNavMeshPosition += Vector3.up * 0.5f;
				GameObject val2 = Object.Instantiate<GameObject>(val.spawnPrefab, guaranteedNavMeshPosition, Quaternion.identity);
				NetworkObject component = val2.GetComponent<NetworkObject>();
				if ((Object)(object)component != (Object)null)
				{
					component.Spawn(false);
					int num4 = (int)((float)Random.Range(val.minValue, val.maxValue) * 0.4f);
					GrabbableObject component2 = val2.GetComponent<GrabbableObject>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.targetFloorPosition = guaranteedNavMeshPosition - Vector3.up * 0.5f;
						component2.SetScrapValue(num4);
						list2.Add(NetworkObjectReference.op_Implicit(component));
						list3.Add(num4);
					}
				}
			}
			if (list2.Count > 0)
			{
				RoundManager.Instance.SyncScrapValuesClientRpc(list2.ToArray(), list3.ToArray());
			}
		}

		private static void SpawnMaskedOnGround(Vector3 centerNodePos, float spawnRadius)
		{
			//IL_0099: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			EnemyType val = ((IEnumerable<SpawnableEnemyWithRarity>)RoundManager.Instance.currentLevel.Enemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity e) => e.enemyType.enemyName.Contains("Masked")))?.enemyType;
			if (!((Object)(object)val == (Object)null))
			{
				int num = StartOfRound.Instance.allPlayerScripts.Count((PlayerControllerB p) => p.isPlayerControlled);
				for (int num2 = 0; num2 < num; num2++)
				{
					Vector3 guaranteedNavMeshPosition = GetGuaranteedNavMeshPosition(centerNodePos, spawnRadius);
					RoundManager.Instance.SpawnEnemyGameObject(guaranteedNavMeshPosition, 0f, -1, val);
				}
			}
		}

		private static GameObject SpawnFakeShipLocal(Vector3 pos, Quaternion rot)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)FakeShipPrefab == (Object)null)
			{
				LoadAssets();
			}
			GameObject val = Object.Instantiate<GameObject>(FakeShipPrefab, pos, rot);
			SetLayerRecursive(val, 8);
			Rigidbody component = val.GetComponent<Rigidbody>();
			component.mass = 5000f;
			component.useGravity = true;
			component.isKinematic = false;
			component.collisionDetectionMode = (CollisionDetectionMode)1;
			GameObject val2 = GameObject.Find("Environment");
			if ((Object)(object)val2 != (Object)null)
			{
				val.transform.SetParent(val2.transform);
			}
			((MonoBehaviour)RoundManager.Instance).StartCoroutine(DisablePhysicsAfterDelay(val, component, 10f));
			return val;
		}

		private static IEnumerator DisablePhysicsAfterDelay(GameObject ship, Rigidbody rb, float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			if ((Object)(object)rb != (Object)null)
			{
				rb.isKinematic = true;
				rb.useGravity = false;
				Physics.SyncTransforms();
			}
		}

		private static void SpawnMaskedOnGround(Vector3 groundPos, Vector3 AINode)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			EnemyType val = ((IEnumerable<SpawnableEnemyWithRarity>)RoundManager.Instance.currentLevel.Enemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity e) => e.enemyType.enemyName.Contains("Masked")))?.enemyType;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			int num = StartOfRound.Instance.allPlayerScripts.Count((PlayerControllerB p) => p.isPlayerControlled);
			NavMeshHit val3 = default(NavMeshHit);
			for (int num2 = 0; num2 < num; num2++)
			{
				Vector3 val2 = groundPos + new Vector3(Random.Range(-3f, 3f), 0f, Random.Range(-3f, 3f));
				if (NavMesh.SamplePosition(val2, ref val3, 10f, -1))
				{
					RoundManager.Instance.SpawnEnemyGameObject(((NavMeshHit)(ref val3)).position, 0f, -1, val);
				}
				else
				{
					RoundManager.Instance.SpawnEnemyGameObject(AINode, 0f, -1, val);
				}
			}
		}

		private static void SetLayerRecursive(GameObject obj, int newLayer)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			obj.layer = newLayer;
			foreach (Transform item in obj.transform)
			{
				Transform val = item;
				SetLayerRecursive(((Component)val).gameObject, newLayer);
			}
		}

		private static void SendAlertToAllClients()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkManager.Singleton.IsServer)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("ReplacementCrew_HUDAlert", new FastBufferWriter(0, (Allocator)2, -1), (NetworkDelivery)3);
				ShowIntrusionAlertLocal();
			}
		}

		private static void SyncShipToClients(Vector3 pos, Quaternion rot)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(28, (Allocator)2, -1);
			((FastBufferWriter)(ref val)).WriteValueSafe(ref pos);
			((FastBufferWriter)(ref val)).WriteValueSafe(ref rot);
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("ReplacementCrew_SpawnShip", val, (NetworkDelivery)3);
		}

		public static void LoadAssets()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "fakeshipevent"));
			if ((Object)(object)val != (Object)null)
			{
				FakeShipPrefab = val.LoadAsset<GameObject>("FakeShip");
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void RegisterNetworkMessages()
		{
			//IL_0035: 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_0040: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return;
			}
			CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
			object obj = <>c.<>9__20_0;
			if (obj == null)
			{
				HandleNamedMessageDelegate val = delegate(ulong senderId, FastBufferReader reader)
				{
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					if (!NetworkManager.Singleton.IsServer)
					{
						Vector3 pos = default(Vector3);
						((FastBufferReader)(ref reader)).ReadValueSafe(ref pos);
						Quaternion rot = default(Quaternion);
						((FastBufferReader)(ref reader)).ReadValueSafe(ref rot);
						SpawnFakeShipLocal(pos, rot);
					}
				};
				<>c.<>9__20_0 = val;
				obj = (object)val;
			}
			customMessagingManager.RegisterNamedMessageHandler("ReplacementCrew_SpawnShip", (HandleNamedMessageDelegate)obj);
			CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager;
			object obj2 = <>c.<>9__20_1;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val2 = delegate
				{
					if (!NetworkManager.Singleton.IsServer)
					{
						ShowIntrusionAlertLocal();
					}
				};
				<>c.<>9__20_1 = val2;
				obj2 = (object)val2;
			}
			customMessagingManager2.RegisterNamedMessageHandler("ReplacementCrew_HUDAlert", (HandleNamedMessageDelegate)obj2);
		}
	}
}
namespace GameMecanicOverhaul
{
	[HarmonyPatch(typeof(StartOfRound), "ArriveAtLevel")]
	public class AutoLandingPatch
	{
		[HarmonyPostfix]
		private static void Postfix(StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsServer)
			{
				__instance.StartGameServerRpc();
			}
		}
	}
	[HarmonyPatch(typeof(EndRoundStatsPatch), "ReplaceEndGameScreen")]
	public class DayEndPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			ScrapTracker.CalculateCollectedScrap();
			Plugin.PlayersRegistry.Clear();
			int num = 0;
			bool flag = false;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!val.isPlayerControlled && !val.isPlayerDead)
				{
					continue;
				}
				bool flag2 = !val.isPlayerDead && (val.isInHangarShipRoom || val.isInElevator);
				if (flag2)
				{
					flag = true;
				}
				string causeOfDeath = "None";
				if (val.isPlayerDead)
				{
					causeOfDeath = ((object)Unsafe.As<CauseOfDeath, CauseOfDeath>(ref val.causeOfDeath)/*cast due to .constrained prefix*/).ToString();
				}
				else if (!flag2)
				{
					causeOfDeath = "Abandoned";
				}
				Plugin.PlayersRegistry[val.playerClientId] = new Plugin.PlayerData
				{
					PlayerName = val.playerUsername,
					IsAlive = flag2,
					Health = val.health,
					CauseOfDeath = causeOfDeath
				};
				if (flag2)
				{
					continue;
				}
				if (val.isPlayerDead)
				{
					if ((Object)(object)val.deadBody == (Object)null || !val.deadBody.isInShip)
					{
						num++;
					}
				}
				else
				{
					num++;
				}
			}
			if (!flag)
			{
				Plugin.collectedScrapSurLune = 0;
				Plugin.collectedNB = 0;
			}
			Terminal val2 = Object.FindObjectOfType<Terminal>();
			int num2 = (((Object)(object)val2 != (Object)null) ? val2.groupCredits : 0);
			int num3 = num2;
			for (int j = 0; j < num; j++)
			{
				num3 -= Mathf.CeilToInt((float)num3 * 0.2f);
			}
			Plugin.TeamsPenalty = num2 - num3;
		}
	}
	[HarmonyPatch(typeof(DeleteFileButton), "DeleteFile")]
	public class DeletePatch
	{
		[HarmonyPrefix]
		private static void Prefix(DeleteFileButton __instance)
		{
			int fileToDelete = __instance.fileToDelete;
			if (1 == 0)
			{
			}
			string text = fileToDelete switch
			{
				0 => "LCSaveFile1", 
				1 => "LCSaveFile2", 
				2 => "LCSaveFile3", 
				_ => "LCSaveFile1", 
			};
			if (1 == 0)
			{
			}
			string text2 = text;
			string path = Path.Combine(Application.persistentDataPath, text2 + "_gmo.txt");
			try
			{
				if (File.Exists(path))
				{
					File.Delete(path);
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[GMO] Error deleting custom save files: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class DisconnectPatch
	{
		[HarmonyPatch("ResetGameValuesToDefault")]
		[HarmonyPostfix]
		public static void ResetVariablesOnDisconnect()
		{
			Plugin.CurrentRunMultiplier = 1f;
			Plugin.collectedScrapSurLune = 0;
			Plugin.totalScrapSurLune = 0;
			Plugin.TeamsPenalty = 0;
			Plugin.collectedNB = 0;
			Plugin.allNB = 0;
			Plugin.VisitedMoonNames.Clear();
			Plugin.ChosenMoonNames.Clear();
			Plugin.MoonSeeds.Clear();
			LandingTimeManager.LandingTimePatch.IsTimeAppliedForToday = false;
		}
	}
	[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
	public class EndRoundPatch
	{
		[HarmonyPrefix]
		public static void Prefix()
		{
			if (StartOfRound.Instance.currentLevelID != 3)
			{
				Plugin.VisitedMoonNames.Add(((Object)StartOfRound.Instance.currentLevel).name);
				LandingTimeManager.GenerateLandingTimes();
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
	public class EndRoundStatsPatch
	{
		[HarmonyPrefix]
		public static bool ReplaceEndGameScreen(HUDManager __instance, EndOfGameStats stats)
		{
			if ((Object)(object)GMO_UIManager.Instance == (Object)null)
			{
				GMO_UIManager.Instance = ((Component)__instance).gameObject.AddComponent<GMO_UIManager>();
				GMO_UIManager.Instance.Initialize();
			}
			HUDManager.Instance.RemoveSpectateUI();
			if (StartOfRound.Instance.currentLevelID != 3)
			{
				GMO_UIManager.Instance.ShowResults(stats);
			}
			return false;
		}
	}
	public static class EventHUDUtility
	{
		private static GameObject _warningCanvasObj;

		private static TextMeshProUGUI _titleText;

		private static TextMeshProUGUI _bodyText;

		private static CanvasGroup _canvasGroup;

		public static void DisplayWarning(string title, string body, AudioClip sfx = null)
		{
			if (!((Object)(object)HUDManager.Instance == (Object)null))
			{
				if ((Object)(object)_warningCanvasObj == (Object)null)
				{
					BuildWarningUI();
				}
				((TMP_Text)_titleText).text = title;
				((TMP_Text)_bodyText).text = body;
				if ((Object)(object)sfx != (Object)null && (Object)(object)HUDManager.Instance.UIAudio != (Object)null)
				{
					HUDManager.Instance.UIAudio.PlayOneShot(sfx, 1f);
				}
				((MonoBehaviour)HUDManager.Instance).StartCoroutine(WarningAnimationSequence());
			}
		}

		private static void BuildWarningUI()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Expected O, but got Unknown
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Systems/UI/Canvas");
			if (!((Object)(object)val == (Object)null))
			{
				_warningCanvasObj = new GameObject("GMO_WarningUI");
				_warningCanvasObj.transform.SetParent(val.transform, false);
				RectTransform val2 = _warningCanvasObj.AddComponent<RectTransform>();
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				_canvasGroup = _warningCanvasObj.AddComponent<CanvasGroup>();
				_canvasGroup.alpha = 0f;
				GameObject val3 = new GameObject("Background");
				val3.transform.SetParent(_warningCanvasObj.transform, false);
				Image val4 = val3.AddComponent<Image>();
				((Graphic)val4).color = new Color(0f, 0f, 0f, 0.1f);
				RectTransform rectTransform = ((Graphic)val4).rectTransform;
				rectTransform.anchorMin = new Vector2(0f, 0.5f);
				rectTransform.anchorMax = new Vector2(1f, 0.5f);
				rectTransform.pivot = new Vector2(0.5f, 0.5f);
				rectTransform.sizeDelta = new Vector2(0f, 100f);
				VerticalLayoutGroup val5 = val3.AddComponent<VerticalLayoutGroup>();
				((LayoutGroup)val5).childAlignment = (TextAnchor)4;
				((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false;
				((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = true;
				((LayoutGroup)val5).padding = new RectOffset(20, 20, 20, 20);
				((HorizontalOrVerticalLayoutGroup)val5).spacing = 10f;
				ContentSizeFitter val6 = val3.AddComponent<ContentSizeFitter>();
				val6.verticalFit = (FitMode)2;
				TMP_FontAsset font = ((TMP_Text)HUDManager.Instance.controlTipLines[0]).font;
				GameObject val7 = new GameObject("TitleText");
				val7.transform.SetParent(val3.transform, false);
				_titleText = val7.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_titleText).font = font;
				((TMP_Text)_titleText).fontSize = 38f;
				((Graphic)_titleText).color = new Color(0.9f, 0f, 0f, 1f);
				((TMP_Text)_titleText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_titleText).characterSpacing = 8f;
				((TMP_Text)_titleText).fontStyle = (FontStyles)1;
				((TMP_Text)_titleText).enableWordWrapping = true;
				GameObject val8 = new GameObject("BodyText");
				val8.transform.SetParent(val3.transform, false);
				_bodyText = val8.AddComponent<TextMeshProUGUI>();
				((TMP_Text)_bodyText).font = font;
				((TMP_Text)_bodyText).fontSize = 18f;
				((Graphic)_bodyText).color = new Color(0.8f, 0.8f, 0.8f, 0.9f);
				((TMP_Text)_bodyText).alignment = (TextAlignmentOptions)514;
				((TMP_Text)_bodyText).characterSpacing = 2f;
				((TMP_Text)_bodyText).lineSpacing = 10f;
				((TMP_Text)_bodyText).enableWordWrapping = true;
			}
		}

		private static void CreateSubtleLine(Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 sizeOffset)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Line");
			val.transform.SetParent(parent, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0.8f, 0.1f, 0.1f, 0.3f);
			RectTransform rectTransform = ((Graphic)val2).rectTransform;
			rectTransform.anchorMin = anchorMin;
			rectTransform.anchorMax = anchorMax;
			rectTransform.sizeDelta = sizeOffset;
		}

		private static void CreateBorderLine(Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 sizeOffset)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BorderLine");
			val.transform.SetParent(parent, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(1f, 0f, 0f, 0.6f);
			RectTransform rectTransform = ((Graphic)val2).rectTransform;
			rectTransform.anchorMin = anchorMin;
			rectTransform.anchorMax = anchorMax;
			rectTransform.sizeDelta = sizeOffset;
		}

		private static IEnumerator WarningAnimationSequence()
		{
			float elapsed = 0f;
			while (elapsed < 0.2f)
			{
				elapsed += Time.deltaTime;
				_canvasGroup.alpha = elapsed / 0.2f;
				yield return null;
			}
			float alertTimer = 0f;
			while (alertTimer < 8f)
			{
				alertTimer += Time.deltaTime;
				float pulse = 0.75f + Mathf.Sin(Time.time * 10f) * 0.25f;
				((TMP_Text)_titleText).alpha = pulse;
				yield return null;
			}
			elapsed = 0f;
			while (elapsed < 0.5f)
			{
				elapsed += Time.deltaTime;
				_canvasGroup.alpha = 1f - elapsed / 0.5f;
				yield return null;
			}
		}
	}
	public static class GMO_Animations
	{
		public static IEnumerator TerminalSequence(GMO_UIElements ui, EndOfGameStats stats, Action<bool> onComplete)
		{
			onComplete(obj: false);
			((TMP_Text)ui.GeneralStatsText).text = "";
			((TMP_Text)ui.TitleText).text = "ESTABLISHING CONNECTION...";
			foreach (Transform item in ui.PlayerListContent)
			{
				Transform child = item;
				Object.Destroy((Object)(object)((Component)child).gameObject);
			}
			foreach (Transform item2 in ui.IndoorContent)
			{
				Transform child2 = item2;
				Object.Destroy((Object)(object)((Component)child2).gameObject);
			}
			foreach (Transform item3 in ui.OutdoorContent)
			{
				Transform child3 = item3;
				Object.Destroy((Object)(object)((Component)child3).gameObject);
			}
			((TMP_Text)ui.IndoorTitle).text = "INDOOR (0)";
			((TMP_Text)ui.OutdoorTitle).text = "OUTDOOR (0)";
			yield return (object)new WaitForSeconds(0.5f);
			if (Plugin.EnableGameCoreOverhaul.Value)
			{
				((TMP_Text)ui.TitleText).text = $"MISSION REPORT | {Plugin.ChosenMoonNames.Count + 1 - Plugin.VisitedMoonNames.Count} DAYS UNTIL DEADLINE";
			}
			else
			{
				((TMP_Text)ui.TitleText).text = $"MISSION REPORT | {Mathf.CeilToInt(TimeOfDay.Instance.timeUntilDeadline / TimeOfDay.Instance.totalTime)} DAYS UNTIL DEADLINE";
			}
			HUDManager.Instance.HideHUD(true);
			((Component)HUDManager.Instance.chatTextField).gameObject.SetActive(false);
			float totalScrapInLevel = Plugin.totalScrapSurLune;
			float collectedScrapValue = Plugin.collectedScrapSurLune;
			float ratio = ((totalScrapInLevel > 0f) ? (collectedScrapValue / totalScrapInLevel) : 0f);
			int collectedCount = Plugin.collectedNB;
			int totalCount = Plugin.allNB;
			string grade = "D";
			if (ratio >= 0.95f)
			{
				grade = "S";
			}
			else if (ratio > 0.75f)
			{
				grade = "A";
			}
			else if (ratio > 0.5f)
			{
				grade = "B";
			}
			else if (ratio > 0.25f)
			{
				grade = "C";
			}
			StringBuilder sb = new StringBuilder();
			sb.AppendLine("<color=#FF720D>SECTOR:</color> " + RoundManager.Instance.currentLevel.PlanetName);
			sb.AppendLine($"<color=#FF720D>ITEMS RETRIEVED:</color> {collectedCount} / {totalCount}");
			sb.AppendLine($"<color=#FF720D>SCRAP COLLECTED:</color> {collectedScrapValue}$ / {totalScrapInLevel}$");
			sb.AppendLine($"<color=#FF720D>CREW EFFICIENCY:</color> {ratio * 100f:F0}%");
			sb.AppendLine("");
			sb.AppendLine("");
			sb.AppendLine("<size=150%>GRADE: <color=#FFFFFF>[ " + grade + " ]</color></size>");
			sb.AppendLine("");
			if (Plugin.TeamsPenalty > 0)
			{
				sb.AppendLine($"<color=red>CASUALTY FINES:</color> -{Plugin.TeamsPenalty}$");
			}
			else
			{
				sb.AppendLine("<color=green>CASUALTY FINES:</color> NONE");
			}
			yield return Type(ui.GeneralStatsText, sb.ToString());
			yield return (object)new WaitForSeconds(0.3f);
			TMP_FontAsset font = ((TMP_Text)HUDManager.Instance.weightCounter).font;
			foreach (KeyValuePair<ulong, Plugin.PlayerData> entry in Plugin.PlayersRegistry)
			{
				_ = entry.Key;
				Plugin.PlayerData pData = entry.Value;
				string pName = pData.PlayerName;
				bool isDead = !pData.IsAlive;
				string status = (isDead ? ("DECEASED (" + pData.CauseOfDeath + ")") : ((pData.Health <= 20) ? $"CRITICAL ({pData.Health}HP)" : ((pData.Health > 75) ? $"STABLE ({pData.Health}HP)" : $"INJURED ({pData.Health}HP)")));
				ui.CreatePlayerRow(pName, status, isDead, font);
				yield return (object)new WaitForSeconds(0.15f);
			}
			((TMP_Text)ui.IndoorTitle).text = $"INDOOR ({Plugin.IndoorEnemyNames.Count})";
			using (List<string>.Enumerator enumerator5 = Plugin.IndoorEnemyNames.GetEnumerator())
			{
				while (enumerator5.MoveNext())
				{
					ui.CreateSimpleRow(text: "> " + enumerator5.Current.ToUpper(), container: ui.IndoorContent, color: new Color(1f, 0.6f, 0f), font: font);
					yield return (object)new WaitForSeconds(0.05f);
				}
			}
			((TMP_Text)ui.OutdoorTitle).text = $"OUTDOOR ({Plugin.OutdoorEnemyNames.Count})";
			using (List<string>.Enumerator enumerator6 = Plugin.OutdoorEnemyNames.GetEnumerator())
			{
				while (enumerator6.MoveNext())
				{
					ui.CreateSimpleRow(text: "> " + enumerator6.Current.ToUpper(), container: ui.OutdoorContent, color: new Color(1f, 0.6f, 0f), font: font);
					yield return (object)new WaitForSeconds(0.05f);
				}
			}
			yield return (object)new WaitForSeconds(3f);
			ui.BtnObj.SetActive(true);
			onComplete(obj: true);
		}

		private static IEnumerator Type(TextMeshProUGUI el, string t)
		{
			((TMP_Text)el).text = t;
			((TMP_Text)el).maxVisibleCharacters = 0;
			int total = t.Length;
			_ = ((TMP_Text)el).textInfo;
			while (((TMP_Text)el).maxVisibleCharacters < total)
			{
				int maxVisibleCharacters = ((TMP_Text)el).maxVisibleCharacters;
				((TMP_Text)el).maxVisibleCharacters = maxVisibleCharacters + 1;
				yield return (object)new WaitForSeconds(0.01f);
				if (((TMP_Text)el).maxVisibleCharacters >= ((TMP_Text)el).textInfo.characterCount)
				{
					break;
				}
			}
			((TMP_Text)el).maxVisibleCharacters = 99999;
		}
	}
	public class GMO_UIElements
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__13_0;

			internal void <BuildUI>b__13_0()
			{
				GMO_UIManager.Instance.OnContinueClicked();
			}
		}

		public GameObject CanvasObj = null;

		public GameObject BtnObj = null;

		public TextMeshProUGUI TitleText = null;

		public TextMeshProUGUI GeneralStatsText = null;

		public Transform PlayerListContent = null;

		public Transform IndoorContent = null;

		public Transform OutdoorContent = null;

		public TextMeshProUGUI IndoorTitle = null;

		public TextMeshProUGUI OutdoorTitle = null;

		private Color _cBlack05 = new Color(0f, 0f, 0f, 0.5f);

		private Color _cOrange05 = new Color(1f, 0.45f, 0.05f, 0.5f);

		private Color _cOrangeFull = new Color(1f, 0.45f, 0.05f, 1f);

		private Color _cRed = new Color(0.8f, 0.1f, 0.1f, 1f);

		public void BuildUI(Transform parent)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_0204: 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_025f: 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_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Expected O, but got Unknown
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Expected O, but got Unknown
			TMP_FontAsset font = ((TMP_Text)HUDManager.Instance.weightCounter).font;
			CanvasObj = new GameObject("GMO_MissionReport");
			Canvas val = CanvasObj.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 9999;
			CanvasObj.AddComponent<GraphicRaycaster>();
			CanvasScaler val2 = CanvasObj.AddComponent<CanvasScaler>();
			val2.uiScaleMode = (ScaleMode)1;
			val2.referenceResolution = new Vector2(1920f, 1080f);
			val2.matchWidthOrHeight = 0.5f;
			Image val3 = new GameObject("GlobalBackground").AddComponent<Image>();
			((Component)val3).transform.SetParent(CanvasObj.transform, false);
			((Graphic)val3).color = _cBlack05;
			((Graphic)val3).raycastTarget = true;
			Stretch(((Graphic)val3).rectTransform);
			GameObject val4 = new GameObject("TerminalFrame");
			val4.transform.SetParent(CanvasObj.transform, false);
			Image val5 = val4.AddComponent<Image>();
			((Graphic)val5).color = _cOrange05;
			((Graphic)val5).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)val5).rectTransform;
			rectTransform.anchorMin = new Vector2(0.1f, 0.1f);
			rectTransform.anchorMax = new Vector2(0.9f, 0.9f);
			Vector2 val6 = (rectTransform.offsetMin = (rectTransform.offsetMax = Vector2.zero));
			TitleText = CreateTxt("Title", val4.transform, font, 50, new Vector2(0f, -50f));
			((TMP_Text)TitleText).rectTransform.anchorMin = new Vector2(0f, 1f);
			((TMP_Text)TitleText).rectTransform.anchorMax = new Vector2(1f, 1f);
			((TMP_Text)TitleText).rectTransform.pivot = new Vector2(0.5f, 1f);
			((TMP_Text)TitleText).text = "MISSION REPORT";
			((Graphic)TitleText).color = Color.white;
			((TMP_Text)TitleText).alignment = (TextAlignmentOptions)514;
			GeneralStatsText = CreateTxt("Stats", val4.transform, font, 26, new Vector2(40f, -120f));
			((TMP_Text)GeneralStatsText).rectTransform.anchorMin = new Vector2(0f, 1f);
			((TMP_Text)GeneralStatsText).rectTransform.anchorMax = new Vector2(0.6f, 1f);
			((TMP_Text)GeneralStatsText).rectTransform.pivot = new Vector2(0f, 1f);
			((TMP_Text)GeneralStatsText).alignment = (TextAlignmentOptions)257;
			((Graphic)GeneralStatsText).color = Color.white;
			((TMP_Text)GeneralStatsText).rectTransform.sizeDelta = new Vector2(0f, 250f);
			float num = 0.12f;
			float num2 = 0.45f;
			CreateColumn(val4.transform, "Crew", new Vector2(0.05f, num), new Vector2(0.33f, num2), "CREW STATUS", out PlayerListContent, out TextMeshProUGUI _);
			CreateColumn(val4.transform, "Indoor", new Vector2(0.35f, num), new Vector2(0.64f, num2), "INDOOR (0)", out IndoorContent, out IndoorTitle);
			CreateColumn(val4.transform, "Outdoor", new Vector2(0.66f, num), new Vector2(0.95f, num2), "OUTDOOR (0)", out OutdoorContent, out OutdoorTitle);
			BtnObj = new GameObject("ActionBtn");
			BtnObj.transform.SetParent(CanvasObj.transform, false);
			RectTransform val8 = BtnObj.AddComponent<RectTransform>();
			((Vector2)(ref val6))..ctor(0.5f, 0.15f);
			val8.anchorMax = val6;
			val8.anchorMin = val6;
			val8.sizeDelta = new Vector2(300f, 40f);
			Image val9 = BtnObj.AddComponent<Image>();
			((Graphic)val9).color = _cOrangeFull;
			((Graphic)val9).raycastTarget = true;
			ButtonClickedEvent onClick = BtnObj.AddComponent<Button>().onClick;
			object obj = <>c.<>9__13_0;
			if (obj == null)
			{
				UnityAction val10 = delegate
				{
					GMO_UIManager.Instance.OnContinueClicked();
				};
				<>c.<>9__13_0 = val10;
				obj = (object)val10;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj);
			TextMeshProUGUI val11 = CreateTxt("Label", BtnObj.transform, font, 28, Vector2.zero);
			((TMP_Text)val11).text = "CONTINUE";
			((Graphic)val11).color = Color.black;
			((TMP_Text)val11).alignment = (TextAlignmentOptions)514;
			Stretch(((TMP_Text)val11).rectTransform);
			BtnObj.transform.SetAsLastSibling();
			CanvasObj.SetActive(false);
		}

		private void CreatePlayerScrollView(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			GameObject val = new GameObject("PlayerList_ScrollView");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.05f, 0.1f);
			val2.anchorMax = new Vector2(0.95f, 0.5f);
			Vector2 offsetMin = (val2.offsetMax = Vector2.zero);
			val2.offsetMin = offsetMin;
			((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.4f);
			ScrollRect val3 = val.AddComponent<ScrollRect>();
			val3.horizontal = false;
			val3.vertical = true;
			GameObject val4 = new GameObject("Viewport");
			val4.transform.SetParent(val.transform, false);
			Stretch(val4.AddComponent<RectTransform>());
			val4.AddComponent<Mask>().showMaskGraphic = false;
			((Graphic)val4.AddComponent<Image>()).color = Color.white;
			GameObject val5 = new GameObject("Content");
			val5.transform.SetParent(val4.transform, false);
			RectTransform val6 = val5.AddComponent<RectTransform>();
			val6.anchorMin = new Vector2(0f, 1f);
			val6.anchorMax = new Vector2(1f, 1f);
			val6.pivot = new Vector2(0.5f, 1f);
			val6.sizeDelta = new Vector2(0f, 100f);
			VerticalLayoutGroup val7 = val5.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val7).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val7).spacing = 5f;
			((LayoutGroup)val7).padding = new RectOffset(10, 10, 10, 10);
			val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			val3.content = val6;
			val3.viewport = val4.GetComponent<RectTransform>();
			PlayerListContent = (Transform)(object)val6;
		}

		public void CreatePlayerRow(string name, string status, bool isDead, TMP_FontAsset font)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PlayerRow");
			val.transform.SetParent(PlayerListContent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			LayoutElement val3 = val.AddComponent<LayoutElement>();
			val3.minHeight = 30f;
			val3.flexibleWidth = 1f;
			TextMeshProUGUI val4 = CreateTxt("Name", val.transform, font, 20, Vector2.zero);
			((TMP_Text)val4).text = name;
			((TMP_Text)val4).alignment = (TextAlignmentOptions)513;
			((TMP_Text)val4).rectTransform.anchorMin = new Vector2(0f, 0f);
			((TMP_Text)val4).rectTransform.anchorMax = new Vector2(0.6f, 1f);
			((TMP_Text)val4).rectTransform.offsetMin = new Vector2(5f, 0f);
			((TMP_Text)val4).rectTransform.offsetMax = Vector2.zero;
			TextMeshProUGUI val5 = CreateTxt("Status", val.transform, font, 18, Vector2.zero);
			((TMP_Text)val5).text = status;
			((Graphic)val5).color = (isDead ? Color.red : Color.green);
			((TMP_Text)val5).alignment = (TextAlignmentOptions)516;
			((TMP_Text)val5).enableAutoSizing = true;
			((TMP_Text)val5).fontSizeMin = 10f;
			((TMP_Text)val5).fontSizeMax = 18f;
			((TMP_Text)val5).enableWordWrapping = false;
			((TMP_Text)val5).rectTransform.anchorMin = new Vector2(0.4f, 0f);
			((TMP_Text)val5).rectTransform.anchorMax = new Vector2(1f, 1f);
			((TMP_Text)val5).rectTransform.offsetMin = Vector2.zero;
			((TMP_Text)val5).rectTransform.offsetMax = new Vector2(-5f, 0f);
		}

		private void CreateColumn(Transform parent, string n, Vector2 min, Vector2 max, string title, out Transform content, out TextMeshProUGUI titleTxt)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			GameObject val = new GameObject(n + "_Scroll");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = min;
			val2.anchorMax = max;
			Vector2 offsetMin = (val2.offsetMax = Vector2.zero);
			val2.offsetMin = offsetMin;
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0f, 0f, 0f, 0.6f);
			titleTxt = CreateTxt(n + "_Title", parent, ((TMP_Text)HUDManager.Instance.weightCounter).font, 18, Vector2.zero);
			((TMP_Text)titleTxt).rectTransform.anchorMin = new Vector2(min.x, max.y + 0.005f);
			((TMP_Text)titleTxt).rectTransform.anchorMax = new Vector2(max.x, max.y + 0.05f);
			RectTransform rectTransform = ((TMP_Text)titleTxt).rectTransform;
			offsetMin = (((TMP_Text)titleTxt).rectTransform.offsetMax = Vector2.zero);
			rectTransform.offsetMin = offsetMin;
			((TMP_Text)titleTxt).text = title.ToUpper();
			((Graphic)titleTxt).color = _cOrangeFull;
			((TMP_Text)titleTxt).alignment = (TextAlignmentOptions)514;
			((TMP_Text)titleTxt).fontStyle = (FontStyles)1;
			GameObject val4 = new GameObject("Viewport");
			val4.transform.SetParent(val.transform, false);
			RectTransform val5 = val4.AddComponent<RectTransform>();
			Stretch(val5);
			val4.AddComponent<RectMask2D>();
			GameObject val6 = new GameObject("Content");
			val6.transform.SetParent(val4.transform, false);
			content = (Transform)(object)val6.AddComponent<RectTransform>();
			((RectTransform)content).anchorMin = new Vector2(0f, 1f);
			((RectTransform)content).anchorMax = new Vector2(1f, 1f);
			((RectTransform)content).pivot = new Vector2(0.5f, 1f);
			RectTransform val7 = (RectTransform)content;
			offsetMin = (((RectTransform)content).offsetMax = Vector2.zero);
			val7.offsetMin = offsetMin;
			VerticalLayoutGroup val8 = val6.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val8).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val8).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val8).childForceExpandHeight = false;
			((LayoutGroup)val8).padding = new RectOffset(5, 5, 5, 5);
			((HorizontalOrVerticalLayoutGroup)val8).spacing = 4f;
			val6.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			ScrollRect val9 = val.AddComponent<ScrollRect>();
			val9.content = (RectTransform)content;
			val9.viewport = val5;
			val9.horizontal = false;
			val9.vertical = true;
		}

		public void CreateSimpleRow(Transform container, string text, Color color, TMP_FontAsset font)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("EnemyRow");
			val.transform.SetParent(container, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			TextMeshProUGUI val3 = CreateTxt("Text", val.transform, font, 16, Vector2.zero);
			((TMP_Text)val3).text = text;
			((Graphic)val3).color = color;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val3).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)val3).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)val3).rectTransform.offsetMin = new Vector2(5f, 0f);
			((TMP_Text)val3).rectTransform.offsetMax = new Vector2(-5f, 0f);
			LayoutElement val4 = val.AddComponent<LayoutElement>();
			val4.minHeight = 22f;
			val4.preferredWidth = 800f;
		}

		private TextMeshProUGUI CreateTxt(string n, Transform p, TMP_FontAsset f, int s, Vector2 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(n);
			val.transform.SetParent(p, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val2).font = f;
			((TMP_Text)val2).fontSize = s;
			((Graphic)val2).raycastTarget = false;
			((TMP_Text)val2).rectTransform.anchoredPosition = pos;
			return val2;
		}

		private void Stretch(RectTransform r)
		{
			//IL_000f: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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)
			if (!((Object)(object)r == (Object)null))
			{
				r.anchorMin = Vector2.zero;
				r.anchorMax = Vector2.one;
				r.offsetMin = Vector2.zero;
				r.offsetMax = Vector2.zero;
				((Transform)r).localScale = Vector3.one;
			}
		}
	}
	public class GMO_UIManager : MonoBehaviour
	{
		public static GMO_UIManager Instance;

		public GMO_UIElements Elements = null;

		private bool _isAnimating = false;

		public void Initialize()
		{
			Instance = this;
			Elements = new GMO_UIElements();
			Elements.BuildUI(((Component)this).transform);
		}

		public void ShowResults(EndOfGameStats stats)
		{
			((MonoBehaviour)this).StopAllCoroutines();
			Elements.CanvasObj.SetActive(true);
			Elements.BtnObj.SetActive(false);
			HUDManager.Instance.HideHUD(true);
			((Component)HUDManager.Instance.chatTextField).gameObject.SetActive(false);
			Plugin.IsCustomMenuOpen = true;
			SetPlayerInputs(enabled: false);
			((MonoBehaviour)this).StartCoroutine(GMO_Animations.TerminalSequence(Elements, stats, delegate(bool done)
			{
				_isAnimating = !done;
			}));
		}

		public void OnContinueClicked()
		{
			if (!_isAnimating)
			{
				Elements.CanvasObj.SetActive(false);
				SetPlayerInputs(enabled: true);
				Plugin.IsCustomMenuOpen = false;
				HUDManager.Instance.HideHUD(false);
				((Component)HUDManager.Instance.chatTextField).gameObject.SetActive(true);
			}
		}

		public void SetPlayerInputs(bool enabled)
		{
			Cursor.visible = !enabled;
			Cursor.lockState = (CursorLockMode)(enabled ? 1 : 0);
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController != (Object)null)
			{
				localPlayerController.disableLookInput = !enabled;
				localPlayerController.disableMoveInput = !enabled;
				localPlayerController.isFreeCamera = !enabled;
			}
		}

		private void Update()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			if (Elements != null && (Object)(object)Elements.CanvasObj != (Object)null && Elements.CanvasObj.activeSelf && (int)Cursor.lockState > 0)
			{
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDRemoverPatches
	{
		[HarmonyPatch("DisplayGlobalNotification")]
		[HarmonyPrefix]
		private static bool BlockGlobalAlerts(string displayText)
		{
			if ((Object)(object)TimeOfDay.Instance != (Object)null && TimeOfDay.Instance.daysUntilDeadline <= 0 && !string.IsNullOrEmpty(displayText) && displayText.Contains("HALT"))
			{
				return false;
			}
			return true;
		}

		[HarmonyPatch("DisplayDaysLeft")]
		[HarmonyPrefix]
		private static bool BlockDaysLeftAlert(int daysLeft)
		{
			return false;
		}
	}
	public enum LandingTimeType
	{
		Early,
		Normal,
		Late
	}
	public class MoonTimeData
	{
		public LandingTimeType Type;

		public float TargetHour;
	}
	public static class LandingTimeManager
	{
		[HarmonyPatch(typeof(TimeOfDay), "SyncTimeClientRpc")]
		public class LandingTimePatch
		{
			public static bool IsTimeAppliedForToday;

			[HarmonyPostfix]
			private static void Postfix(TimeOfDay __instance)
			{
				if (!((Object)(object)StartOfRound.Instance?.currentLevel == (Object)null) && !StartOfRound.Instance.inShipPhase && !IsTimeAppliedForToday && !(__instance.globalTime > 250f))
				{
					GenerateLandingTimes();
					string name = ((Object)StartOfRound.Instance.currentLevel).name;
					if (MoonLandingTimes.TryGetValue(name, out MoonTimeData value))
					{
						float num = value.TargetHour - 6f;
						float num2 = __instance.lengthOfHours * (float)__instance.numberOfHours;
						float globalTime = num / 18f * num2;
						__instance.globalTime = globalTime;
						IsTimeAppliedForToday = true;
					}
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		public class RoundResetPatch
		{
			[HarmonyPatch("ShipLeave")]
			[HarmonyPostfix]
			private static void ResetTimeFlagLeave()
			{
				LandingTimePatch.IsTimeAppliedForToday = false;
			}

			[HarmonyPatch("StartGame")]
			[HarmonyPostfix]
			private static void ResetTimeFlagStart()
			{
				LandingTimePatch.IsTimeAppliedForToday = false;
			}
		}

		public static Dictionary<string, MoonTimeData> MoonLandingTimes = new Dictionary<string, MoonTimeData>();

		public static void GenerateLandingTimes()
		{
			if (Plugin.ChosenMoonNames == null || Plugin.MoonSeeds == null || Plugin.MoonSeeds.Count == 0)
			{
				return;
			}
			MoonLandingTimes.Clear();
			for (int i = 0; i < Plugin.ChosenMoonNames.Count; i++)
			{
				string text = Plugin.ChosenMoonNames[i];
				int num = ((i < Plugin.MoonSeeds.Count) ? Plugin.MoonSeeds[i] : Plugin.MoonSeeds[0]);
				int count = Plugin.VisitedMoonNames.Count;
				int seed = num + count + text.GetHashCode();
				Random random = new Random(seed);
				random.Next();
				int num2 = random.Next(0, 3);
				LandingTimeType landingTimeType = (LandingTimeType)num2;
				float targetHour;
				switch (landingTimeType)
				{
				case LandingTimeType.Early:
					targetHour = (float)(6.2 + random.NextDouble() * 0.8);
					break;
				case LandingTimeType.Late:
					targetHour = (float)(9.0 + random.NextDouble() * 1.5);
					break;
				default:
					landingTimeType = LandingTimeType.Normal;
					targetHour = 7.85f;
					break;
				}
				MoonLandingTimes[text] = new MoonTimeData
				{
					Type = landingTimeType,
					TargetHour = targetHour
				};
			}
		}

		public static string FormatTimeToClock(float rawHours)
		{
			int num = Mathf.FloorToInt(rawHours);
			int num2 = Mathf.FloorToInt((rawHours - (float)num) * 60f);
			string arg = ((num >= 12) ? "PM" : "AM");
			int num3 = num % 12;
			if (num3 == 0)
			{
				num3 = 12;
			}
			return $"{num3}:{num2:D2} {arg}";
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "StartGame")]
	public class LaunchPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(StartOfRound __instance)
		{
			if (!NetworkManager.Singleton.IsServer)
			{
				return true;
			}
			List<string> list = Plugin.ChosenMoonNames.Where((string name) => !Plugin.VisitedMoonNames.Contains(name)).ToList();
			if (__instance.currentLevelID == 3)
			{
				return true;
			}
			if (list.Count <= 0)
			{
				Terminal val = Object.FindObjectOfType<Terminal>();
				int num = (((Object)(object)val != (Object)null) ? val.groupCredits : 0);
				string targetMoonName = Plugin.FinalMoon.Value;
				int num2 = 3;
				List<SelectableLevel> list2 = (from l in StartOfRound.Instance.levels
					where (Object)(object)l != (Object)null && l.levelID != 3 && !string.IsNullOrWhiteSpace(((Object)l).name) && targetMoonName.Any((char ex) => ((Object)l).name.IndexOf(ex, StringComparison.OrdinalIgnoreCase) >= 0)
					group l by ((Object)l).name into g
					select g.First()).ToList();
				if (list2.Count == 0)
				{
					Networking.Instance.HudAlertMsg.SendClients("Gordion");
				}
				else
				{
					Networking.Instance.HudAlertMsg.SendClients(Plugin.FinalMoon.Value);
				}
				__instance.ChangeLevelServerRpc(num2, num);
				return false;
			}
			if (Plugin.ChosenMoonNames.Contains(((Object)__instance.currentLevel).name) && !Plugin.VisitedMoonNames.Contains(((Object)__instance.currentLevel).name))
			{
				return true;
			}
			if (list.Count > 0)
			{
				string randomName = list[Random.Range(0, list.Count)];
				SelectableLevel val2 = ((IEnumerable<SelectableLevel>)__instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => ((Object)l).name == randomName));
				int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits;
				if ((Object)(object)val2 != (Object)null)
				{
					__instance.ChangeLevelServerRpc(val2.levelID, groupCredits);
				}
				if ((Object)(object)val2 != (Object)null)
				{
					Networking.Instance.HudAlertMsg.SendClients(val2.PlanetName);
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(StartMatchLever), "BeginHoldingInteractOnLever")]
	public class BeginHoldingInteractOnLeverPatch
	{
		[HarmonyPrefix]
		public static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class LevelUIPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		public static void PostfixXP(HUDManager __instance)
		{
			if ((Object)(object)__instance.playerLevelMeter != (Object)null && ((Component)__instance.playerLevelMeter).gameObject.activeSelf)
			{
				((Component)__instance.playerLevelMeter).gameObject.SetActive(false);
				if ((Object)(object)__instance.playerLevelBoxAnimator != (Object)null)
				{
					((Component)__instance.playerLevelBoxAnimator).gameObject.SetActive(false);
				}
				if ((Object)(object)__instance.endgameStatsAnimator != (Object)null)
				{
					((Component)__instance.endgameStatsAnimator).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPrefix]
		private static bool PlateformeHUDLock(HUDManager __instance)
		{
			if (Plugin.IsCustomMenuOpen)
			{
				HUDManager.Instance.HideHUD(true);
				((Component)HUDManager.Instance.chatTextField).gameObject.SetActive(false);
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class MeteorShowerUIPatcher
	{
		[HarmonyPatch("MeteorShowerWarningHUD")]
		[HarmonyPrefix]
		public static bool ReplaceMeteorUI(HUDManager __instance)
		{
			EventHUDUtility.DisplayWarning("EMERGENCY WEATHER ALERT", "METEOR SHOWERS DETECTED.\nTAKE SHELTER IMMEDIATELY.\n\nYOUR AUTOPILOT SATELLITE ISSUED A WEATHER WARNING", __instance.meteorShowerWarningAudio);
			return false;
		}
	}
	public class MoonMultiplierManager
	{
		public static Dictionary<string, ConfigEntry<float>> MoonMultipliers = new Dictionary<string, ConfigEntry<float>>();

		public static void GenerateMoonMultiplierConfigs(ConfigFile configFile)
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			if (StartOfRound.Instance?.levels == null)
			{
				return;
			}
			SelectableLevel[] levels = StartOfRound.Instance.levels;
			foreach (SelectableLevel val in levels)
			{
				if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((Object)val).name))
				{
					string text = ((Object)val).name.Trim().Replace(" ", "");
					if (!string.IsNullOrEmpty(text) && !MoonMultipliers.ContainsKey(text))
					{
						AcceptableValueRange<float> val2 = new AcceptableValueRange<float>(0.1f, 10f);
						ConfigEntry<float> value = configFile.Bind<float>("MoonsConfigList", text ?? "", 1f, new ConfigDescription("MoonMultiplier : " + text, (AcceptableValueBase)(object)val2, Array.Empty<object>()));
						MoonMultipliers[text] = value;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "Start")]
	public class StartOfRoundPatch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			MoonMultiplierManager.GenerateMoonMultiplierConfigs(((BaseUnityPlugin)Plugin.Instance).Config);
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "SaveGame")]
	public class OnDisconnectedPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			Plugin.SaveData();
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")]
	public static class CustomBuyingRatePatch
	{
		[HarmonyPrefix]
		public static bool Prefix(TimeOfDay __instance)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return true;
			}
			if (!NetworkManager.Singleton.IsServer)
			{
				return false;
			}
			if ((Object)(object)StartOfRound.Instance != (Object)null)
			{
				StartOfRound.Instance.companyBuyingRate = 1f;
				StartOfRound.Instance.SyncCompanyBuyingRateClientRpc(1f);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "UpdateProfitQuotaCurrentTime")]
	public static class ForceDeadlineDisplayPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(TimeOfDay __instance)
		{
			return RunDeadlineLogic(__instance);
		}

		public static bool RunDeadlineLogic(TimeOfDay __instance)
		{
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return true;
			}
			if ((Object)(object)__instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null)
			{
				return true;
			}
			int num = Plugin.ChosenMoonNames?.Count ?? 0;
			int num2 = Plugin.VisitedMoonNames?.Count ?? 0;
			int num3 = Mathf.Max(1, num + 1 - num2);
			__instance.timeUntilDeadline = (float)num3 * __instance.totalTime;
			__instance.quotaVariables.deadlineDaysAmount = num3;
			__instance.SyncTimeClientRpc(__instance.globalTime, (int)__instance.timeUntilDeadline);
			if ((Object)(object)StartOfRound.Instance.deadlineMonitorText != (Object)null)
			{
				((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = $"DEADLINE:\n {num3} Days";
			}
			if ((Object)(object)StartOfRound.Instance.profitQuotaMonitorText != (Object)null)
			{
				((TMP_Text)StartOfRound.Instance.profitQuotaMonitorText).text = $"PROFIT QUOTA:\n${__instance.quotaFulfilled}/${__instance.profitQuota}";
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
	public static class QuotaPatch
	{
		[HarmonyPatch(typeof(TimeOfDay), "SyncNewProfitQuotaClientRpc")]
		public static class SyncQuotaClientPatch
		{
			[HarmonyPostfix]
			public static void Postfix(TimeOfDay __instance)
			{
				if (!((Object)(object)HUDManager.Instance == (Object)null) && !((Object)(object)StartOfRound.Instance == (Object)null))
				{
					HUDManager.Instance.displayingNewQuota = true;
					if ((Object)(object)HUDManager.Instance.reachedProfitQuotaAnimator != (Object)null)
					{
						HUDManager.Instance.reachedProfitQuotaAnimator.SetBool("display", false);
					}
					((MonoBehaviour)HUDManager.Instance).StartCoroutine(CustomHUDManager.CustomSequence(HUDManager.Instance));
				}
			}
		}

		public static class CustomHUDManager
		{
			private static TextMeshProUGUI customHudText;

			private static GameObject customHudPanel;

			public static IEnumerator CustomSequence(HUDManager hudManager)
			{
				yield return (object)new WaitForSeconds(4f);
				if ((Object)(object)TimeOfDay.Instance != (Object)null)
				{
					ForceDeadlineDisplayPatch.RunDeadlineLogic(TimeOfDay.Instance);
				}
				yield return (object)new WaitForSeconds(2f);
				yield return ((MonoBehaviour)hudManager).StartCoroutine(ShowSeparateHUD(hudManager));
				if ((Object)(object)HUDManager.Instance != (Object)null)
				{
					HUDManager.Instance.displayingNewQuota = false;
				}
			}

			private static IEnumerator ShowSeparateHUD(HUDManager hudManager)
			{
				if (!((Object)(object)TimeOfDay.Instance == (Object)null))
				{
					if ((Object)(object)customHudText == (Object)null || (Object)(object)customHudPanel == (Object)null)
					{
						CreateCustomHUDObject(hudManager);
					}
					PlayQuotaSound(hudManager);
					int quota = TimeOfDay.Instance.profitQuota;
					int daysLeft = TimeOfDay.Instance.quotaVariables.deadlineDaysAmount;
					if ((Object)(object)customHudText != (Object)null)
					{
						((TMP_Text)customHudText).text = $"PROFIT QUOTA\n${quota}\n\nDays left: {daysLeft}";
					}
					if ((Object)(object)customHudPanel != (Object)null)
					{
						customHudPanel.SetActive(true);
					}
					if ((Object)(object)customHudText != (Object)null)
					{
						((Component)customHudText).gameObject.SetActive(true);
					}
					yield return (object)new WaitForSeconds(5f);
					if ((Object)(object)customHudPanel != (Object)null)
					{
						customHudPanel.SetActive(false);
					}
					if ((Object)(object)customHudText != (Object)null)
					{
						((Component)customHudText).gameObject.SetActive(false);
					}
				}
			}

			private static void PlayQuotaSound(HUDManager hudManager)
			{
				if ((Object)(object)hudManager != (Object)null && (Object)(object)hudManager.UIAudio != (Object)null && (Object)(object)hudManager.newProfitQuotaSFX != (Object)null)
				{
					hudManager.UIAudio.PlayOneShot(hudManager.newProfitQuotaSFX);
				}
			}

			private static void CreateCustomHUDObject(HUDManager hudManager)
			{
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Expected O, but got Unknown
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)hudManager.newProfitQuotaText != (Object)null && (Object)(object)hudManager.HUDContainer != (Object)null)
				{
					customHudPanel = new GameObject("CustomQuotaPanel", new Type[3]
					{
						typeof(RectTransform),
						typeof(CanvasRenderer),
						typeof(Image)
					});
					customHudPanel.transform.SetParent(hudManager.HUDContainer.transform, false);
					RectTransform component = customHudPanel.GetComponent<RectTransform>();
					component.sizeDelta = new Vector2(320f, 220f);
					component.anchoredPosition = Vector2.zero;
					component.anchorMin = new Vector2(0.5f, 0.5f);
					component.anchorMax = new Vector2(0.5f, 0.5f);
					component.pivot = new Vector2(0.5f, 0.5f);
					Image component2 = customHudPanel.GetComponent<Image>();
					((Graphic)component2).color = new Color(0f, 0f, 0f, 0.75f);
					GameObject val = Object.Instantiate<GameObject>(((Component)hudManager.newProfitQuotaText).gameObject, customHudPanel.transform);
					((Object)val).name = "CustomQuotaSeparateText";
					customHudText = val.GetComponent<TextMeshProUGUI>();
					((TMP_Text)customHudText).alignment = (TextAlignmentOptions)514;
					((TMP_Text)customHudText).fontSize = 38f;
					((TMP_Text)customHudText).enableWordWrapping = false;
					RectTransform component3 = val.GetComponent<RectTransform>();
					component3.anchoredPosition = Vector2.zero;
					component3.anchorMin = new Vector2(0f, 0f);
					component3.anchorMax = new Vector2(1f, 1f);
					component3.offsetMin = new Vector2(10f, 10f);
					component3.offsetMax = new Vector2(-10f, -10f);
				}
			}
		}

		[HarmonyPrefix]
		public static bool Prefix(TimeOfDay __instance)
		{
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Expected O, but got Unknown
			if ((Object)(object)NetworkManager.Singleton == (Object)null)
			{
				return true;
			}
			if (!NetworkManager.Singleton.IsServer)
			{
				return false;
			}
			if ((Object)(object)__instance == (Object)null || (Object)(object)StartOfRound.Instance == (Object)null)
			{
				return true;
			}
			if (__instance.timesFulfilledQuota > 0)
			{
				Plugin.CurrentRunMultiplier += Plugin.MultiplierIncrement.Value;
			}
			else
			{
				Plugin.CurrentR