Decompiled source of CompanyProtocols v0.1.3

CompanyProtocols.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CompanyProtocols.NetcodePatcher;
using CompanyProtocols.Networking;
using CompanyProtocols.TerminalPatches;
using GameMecanicOverhaul;
using GameNetcodeStuff;
using HarmonyLib;
using LethalNetworkAPI;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CompanyProtocols")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CompanyProtocols")]
[assembly: AssemblyTitle("CompanyProtocols")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch(typeof(Landmine))]
public class LandmineCleanupPatch
{
	[HarmonyPatch("ExplodeMineClientRpc")]
	[HarmonyPostfix]
	public static void PostfixExplosion(Landmine __instance)
	{
		TerminalAccessibleObject component = ((Component)__instance).GetComponent<TerminalAccessibleObject>();
		if ((Object)(object)component != (Object)null)
		{
			if ((Object)(object)component.mapRadarObject != (Object)null)
			{
				component.mapRadarObject.SetActive(false);
			}
			((Behaviour)component).enabled = false;
		}
		Transform val = ((Component)__instance).transform.Find("ScanNode");
		if ((Object)(object)val != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)val).gameObject);
		}
	}
}
[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}";
	}
}
namespace CompanyProtocols.Visuals
{
	[HarmonyPatch(typeof(HUDManager))]
	internal class HideHUDLCVisuals
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void Postfix(HUDManager __instance)
		{
			if (Plugin.HideHUD.Value && (Object)(object)__instance.HUDContainer != (Object)null)
			{
				__instance.HUDContainer.SetActive(false);
			}
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void EnsureChatIsClosed(HUDManager __instance)
		{
			if (Plugin.HideHUD.Value && (Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null && GameNetworkManager.Instance.localPlayerController.isTypingChat)
			{
				GameNetworkManager.Instance.localPlayerController.isTypingChat = false;
			}
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal class LightingAndSunLCVisuals
	{
		[HarmonyPatch("FinishGeneratingLevel")]
		[HarmonyPostfix]
		private static void EnhanceLights()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.EnableVisualOverhaul.Value)
			{
				return;
			}
			Light[] array = Object.FindObjectsOfType<Light>();
			Light[] array2 = array;
			foreach (Light val in array2)
			{
				if ((int)val.type == 1)
				{
					HDAdditionalLightData component = ((Component)val).GetComponent<HDAdditionalLightData>();
					if ((Object)(object)component != (Object)null)
					{
						component.intensity = 150000f;
						component.EnableColorTemperature(true);
						component.SetColor(Color.white, 5500f);
						component.angularDiameter = 2.5f;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class RetroHorrorOverlayLCVisuals
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ApplyHorrorOverlay()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.EnableVisualOverhaul.Value)
			{
				return;
			}
			Volume val = Object.FindObjectOfType<Volume>();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val.profile == (Object)null))
			{
				VolumeProfile profile = val.profile;
				Bloom val2 = default(Bloom);
				if (!profile.TryGet<Bloom>(ref val2))
				{
					val2 = profile.Add<Bloom>(false);
				}
				((VolumeParameter<float>)(object)val2.intensity).value = 3.5f;
				((VolumeParameter<float>)(object)val2.scatter).value = 0.85f;
				((VolumeParameter<float>)(object)val2.dirtIntensity).value = 2f;
				FilmGrain val3 = default(FilmGrain);
				if (!profile.TryGet<FilmGrain>(ref val3))
				{
					val3 = profile.Add<FilmGrain>(false);
				}
				((VolumeParameter<float>)(object)val3.intensity).value = 1f;
				((VolumeParameter<float>)(object)val3.response).value = 0.8f;
				Vignette val4 = default(Vignette);
				if (!profile.TryGet<Vignette>(ref val4))
				{
					val4 = profile.Add<Vignette>(false);
				}
				((VolumeParameter<float>)(object)val4.intensity).value = 0.45f;
				((VolumeParameter<float>)(object)val4.smoothness).value = 1f;
				((VolumeParameter<Color>)(object)val4.color).value = Color.black;
				((VolumeParameter)val4.intensity).overrideState = true;
				DepthOfField val5 = default(DepthOfField);
				if (!profile.TryGet<DepthOfField>(ref val5))
				{
					val5 = profile.Add<DepthOfField>(false);
				}
				((VolumeParameter<DepthOfFieldMode>)(object)val5.focusMode).value = (DepthOfFieldMode)2;
				((VolumeParameter<float>)(object)val5.nearFocusEnd).value = 0f;
				((VolumeParameter<float>)(object)val5.farFocusStart).value = 12f;
				((VolumeParameter<float>)(object)val5.farFocusEnd).value = 25f;
				((VolumeComponent)val5).active = true;
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class TrueDarknessLCVisuals
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void ApplyTrueDarkness()
		{
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.EnableVisualOverhaul.Value)
			{
				return;
			}
			Volume val = Object.FindObjectOfType<Volume>();
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val.profile == (Object)null))
			{
				VolumeProfile profile = val.profile;
				IndirectLightingController val2 = default(IndirectLightingController);
				if (!profile.TryGet<IndirectLightingController>(ref val2))
				{
					val2 = profile.Add<IndirectLightingController>(false);
				}
				((VolumeParameter<float>)(object)val2.indirectDiffuseLightingMultiplier).value = 0f;
				((VolumeParameter)val2.indirectDiffuseLightingMultiplier).overrideState = true;
				ColorAdjustments val3 = default(ColorAdjustments);
				if (profile.TryGet<ColorAdjustments>(ref val3))
				{
					((VolumeParameter<float>)(object)val3.contrast).value = 45f;
					((VolumeParameter<float>)(object)val3.postExposure).value = -1.2f;
				}
				WhiteBalance val4 = default(WhiteBalance);
				if (!profile.TryGet<WhiteBalance>(ref val4))
				{
					val4 = profile.Add<WhiteBalance>(false);
				}
				((VolumeParameter<float>)(object)val4.temperature).value = -25f;
				((VolumeParameter<float>)(object)val4.tint).value = -10f;
				((VolumeParameter)val4.temperature).overrideState = true;
				Fog val5 = default(Fog);
				if (!profile.TryGet<Fog>(ref val5))
				{
					val5 = profile.Add<Fog>(false);
				}
				((VolumeParameter<bool>)(object)val5.enabled).value = true;
				((VolumeParameter<bool>)(object)val5.enableVolumetricFog).value = true;
				((VolumeParameter<float>)(object)val5.meanFreePath).value = 15f;
				((VolumeParameter<float>)(object)val5.baseHeight).value = -10f;
				((VolumeParameter<float>)(object)val5.maximumHeight).value = 50f;
				((VolumeParameter<Color>)(object)val5.tint).value = new Color(0.05f, 0.05f, 0.06f);
				HDShadowSettings val6 = default(HDShadowSettings);
				if (!profile.TryGet<HDShadowSettings>(ref val6))
				{
					val6 = profile.Add<HDShadowSettings>(false);
				}
				((VolumeParameter<float>)(object)val6.maxShadowDistance).value = 150f;
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class NightVisionOverrideClient
	{
		[HarmonyPatch("SetNightVisionEnabled")]
		[HarmonyPostfix]
		public static void Postfix(PlayerControllerB __instance)
		{
			if (Plugin.EnableVisualOverhaul.Value)
			{
				__instance.nightVision.intensity = 0f;
			}
		}
	}
}
namespace CompanyProtocols.TerminalPatches
{
	[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;
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
	public class TerminalDisplayPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Terminal __instance, ref string __result)
		{
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Invalid comparison between Unknown and I4
			//IL_01fa: 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");
			IOrderedEnumerable<SelectableLevel> orderedEnumerable = from m in __instance.moonsCatalogueList
				where Plugin.ChosenMoonNames.Contains(((Object)m).name) && !Plugin.VisitedMoonNames.Contains(((Object)m).name)
				orderby GetRiskScore(m.riskLevel)
				select m;
			if (!orderedEnumerable.Any())
			{
				stringBuilder.AppendLine("<color=yellow>ALL TARGETS CLEARED.</color>\nNo further missions available.");
			}
			else
			{
				foreach (SelectableLevel item in orderedEnumerable)
				{
					string arg = "<color=#FFFFFF>8.0h</color>";
					if (LandingTimeManager.MoonLandingTimes.TryGetValue(((Object)item).name, out MoonTimeData value))
					{
						string arg2 = ((value.Type == LandingTimeType.Early) ? "#00FFFF" : ((value.Type != LandingTimeType.Late) ? "#FFFFFF" : "#FFA500"));
						arg = $"<color={arg2}>{value.TargetHour:F1}h</color>";
					}
					stringBuilder.AppendLine("> <b>" + item.PlanetName.ToUpper() + "</b>");
					string arg3 = (((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={arg3}>{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;
		}
	}
}
namespace CompanyProtocols.Networking
{
	public class PlayerStatus
	{
		public string PlayerName = null;

		public bool IsAlive;

		public int Health;

		public string CauseOfDeath = null;
	}
	[Serializable]
	public class EndGameStatsData
	{
		public int TotalScrap;

		public int CollectedScrap;

		public int Penalty;

		public int CollectedCount;

		public int TotalCount;

		public List<PlayerStatusData> PlayerRegistry = new List<PlayerStatusData>();

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

		public List<string> OutdoorEnemyNames = new List<string>();
	}
	[Serializable]
	public class PlayerStatusData
	{
		public ulong ClientId;

		public string PlayerName = null;

		public bool IsAlive;

		public int Health;

		public string CauseOfDeath = null;
	}
	[HarmonyPatch(typeof(RoundManager))]
	public class DungeonSpreader : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <SpawnMapObjectsThrottled>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RoundManager rm;

			private RandomMapObject[] <allNodes>5__1;

			private int <count>5__2;

			private RandomMapObject[] <>s__3;

			private int <>s__4;

			private RandomMapObject <node>5__5;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<allNodes>5__1 = null;
				<>s__3 = null;
				<node>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_0102;
				}
				<>1__state = -1;
				Plugin.Log.LogInfo((object)"[GMO] Network Sanitizer: Début du spawn cadencé des Map Objects...");
				<allNodes>5__1 = Object.FindObjectsOfType<RandomMapObject>();
				<count>5__2 = 0;
				<>s__3 = <allNodes>5__1;
				<>s__4 = 0;
				goto IL_0118;
				IL_0118:
				if (<>s__4 < <>s__3.Length)
				{
					<node>5__5 = <>s__3[<>s__4];
					if ((Object)(object)<node>5__5 == (Object)null)
					{
						goto IL_010a;
					}
					if (SpawnAdsMethod != null)
					{
						SpawnAdsMethod.Invoke(<node>5__5, null);
						<count>5__2++;
						if (<count>5__2 % 2 == 0)
						{
							<>2__current = (object)new WaitForSeconds(SpawnDelay);
							<>1__state = 1;
							return true;
						}
						goto IL_0102;
					}
					Plugin.Log.LogWarning((object)"[GMO] Impossible de trouver la méthode SpawnAds !");
					return false;
				}
				<>s__3 = null;
				Plugin.Log.LogInfo((object)$"[GMO] {<count>5__2} Map Objects (Mines/Tourelles) synchronisés progressivement.");
				return false;
				IL_010a:
				<>s__4++;
				goto IL_0118;
				IL_0102:
				<node>5__5 = null;
				goto IL_010a;
			}

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

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

		public static float SpawnDelay = 0.05f;

		private static readonly MethodInfo SpawnAdsMethod = typeof(RandomMapObject).GetMethod("SpawnAds", BindingFlags.Instance | BindingFlags.NonPublic);

		[HarmonyPatch("SpawnMapObjects")]
		[HarmonyPrefix]
		private static bool ThrottledMapObjects(RoundManager __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(SpawnMapObjectsThrottled(__instance));
			return false;
		}

		[IteratorStateMachine(typeof(<SpawnMapObjectsThrottled>d__3))]
		private static IEnumerator SpawnMapObjectsThrottled(RoundManager rm)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnMapObjectsThrottled>d__3(0)
			{
				rm = rm
			};
		}
	}
	public class Networking
	{
		public LNetworkVariable<string[]> ChosenMoonsVar = null;

		public LNetworkVariable<string[]> VisitedMoonsVar = null;

		public LNetworkVariable<int[]> MoonSeedsVar = null;

		public LNetworkMessage<string> HudAlertMsg = null;

		public LNetworkMessage<EndGameStatsData> EndGameStatsMsg = null;

		public LNetworkMessage<int> RequestSyncMsg = null;

		public LNetworkMessage<int> PayQuotaRequestMsg = null;

		public LNetworkMessage<int> SyncQuotaMsg = 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 = 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 = 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 = newVal.ToList();
					}
				});
				PayQuotaRequestMsg = LNetworkMessage<int>.Connect("GMO_PayQuotaRequest", (Action<int, ulong>)null, (Action<int>)null, (Action<int, ulong>)null);
				SyncQuotaMsg = LNetworkMessage<int>.Connect("GMO_SyncQuota", (Action<int, ulong>)null, (Action<int>)null, (Action<int, ulong>)null);
				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);
				EndGameStatsMsg = LNetworkMessage<EndGameStatsData>.Connect("GMO_EndGame", (Action<EndGameStatsData, ulong>)null, (Action<EndGameStatsData>)null, (Action<EndGameStatsData, 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.");
				SyncQuotaMsg.OnClientReceived += delegate(int newQuota)
				{
					Plugin.Log.LogInfo((object)$"[GMO NetMsg] Syncing quota fulfilled: {newQuota}");
					TimeOfDay.Instance.quotaFulfilled = newQuota;
					TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
				};
				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.");
					}
				};
				EndGameStatsMsg.OnClientReceived += delegate(EndGameStatsData data)
				{
					Plugin.Log.LogInfo((object)"[GMO NetMsg] Received EndGameStats data.");
					Plugin.totalScrapSurLune = data.TotalScrap;
					Plugin.collectedScrapSurLune = data.CollectedScrap;
					Plugin.TeamsPenalty = data.Penalty;
					Plugin.collectedNB = data.CollectedCount;
					Plugin.allNB = data.TotalCount;
					Plugin.IndoorEnemyNames = data.IndoorEnemyNames;
					Plugin.OutdoorEnemyNames = data.OutdoorEnemyNames;
					Plugin.PlayersRegistry.Clear();
					foreach (PlayerStatusData item in data.PlayerRegistry)
					{
						Plugin.PlayersRegistry[item.ClientId] = new PlayerStatus
						{
							PlayerName = item.PlayerName,
							IsAlive = item.IsAlive,
							Health = item.Health,
							CauseOfDeath = item.CauseOfDeath
						};
					}
				};
				PayQuotaRequestMsg.OnServerReceived += delegate(int amount, ulong clientId)
				{
					Plugin.Log.LogInfo((object)$"[GMO NetMsg] Server received payment request ({amount}) from: {clientId}");
					Terminal val2 = Object.FindObjectOfType<Terminal>();
					if ((Object)(object)val2 != (Object)null && val2.groupCredits >= amount)
					{
						int num = val2.groupCredits - amount;
						val2.SyncGroupCreditsServerRpc(num, val2.numberOfItemsInDropship);
						TimeOfDay instance = TimeOfDay.Instance;
						instance.quotaFulfilled += amount;
						TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
						SyncQuotaMsg.SendClients(TimeOfDay.Instance.quotaFulfilled);
					}
				};
				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 NetworkLifecycleHost
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void SyncOnStartHost(StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsConnectedClient)
			{
				Networking.Instance.RequestSyncMsg.SendServer((int)NetworkManager.Singleton.LocalClientId);
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class NetworkModOptimizer
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void OptimizeNetworkSettings()
		{
			if ((Object)(object)NetworkManager.Singleton != (Object)null)
			{
				NetworkManager.Singleton.NetworkConfig.TickRate = 100u;
				Debug.Log((object)"[GMO] Network TickRate optimisé à 100.");
			}
		}
	}
}
namespace GameMecanicOverhaul
{
	[HarmonyPatch(typeof(StartOfRound), "ArriveAtLevel")]
	public class AutoLandingPatch
	{
		[HarmonyPostfix]
		private static void Postfix(StartOfRound __instance)
		{
			if (NetworkManager.Singleton.IsServer && Plugin.IsDiverting)
			{
				__instance.StartGameServerRpc();
			}
		}
	}
	[HarmonyPatch]
	internal static class DropshipManagementPatch
	{
		[HarmonyPatch(typeof(Terminal))]
		internal class TerminalLimitPatches
		{
			[HarmonyPostfix]
			[HarmonyPatch("Start")]
			private static void OnStart(Terminal __instance)
			{
				__instance.terminalNodes.specialNodes[4].displayText = __instance.terminalNodes.specialNodes[4].displayText.Replace("12", "9999");
			}

			[HarmonyTranspiler]
			[HarmonyPatch("LoadNewNodeIfAffordable")]
			public static IEnumerable<CodeInstruction> OnLoadNewNodeIfAffordableIL(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				int num = 0;
				for (int i = 2; i < list.Count; i++)
				{
					if (list[i - 2].opcode == OpCodes.Ldarg_0 && list[i - 1].opcode == OpCodes.Ldfld && list[i - 1].operand.ToString() == "System.Int32 playerDefinedAmount" && list[i].opcode == OpCodes.Ldc_I4_S && list[i].operand.ToString() == "12")
					{
						num = i;
						list[i].opcode = OpCodes.Ldc_I4;
						list[i].operand = 9999;
						break;
					}
				}
				for (int j = num + 4; j < list.Count; j++)
				{
					if (list[j - 4].opcode == OpCodes.Ldarg_0 && list[j - 3].opcode == OpCodes.Ldfld && list[j - 3].operand.ToString() == "System.Int32 numberOfItemsInDropship" && list[j - 2].opcode == OpCodes.Conv_R4 && list[j - 1].opcode == OpCodes.Add && list[j].opcode == OpCodes.Ldc_R4 && list[j].operand.ToString() == "12")
					{
						list[j].operand = 9999f;
						break;
					}
				}
				return list.AsEnumerable();
			}

			[HarmonyTranspiler]
			[HarmonyPatch("SyncBoughtItemsWithServer")]
			public static IEnumerable<CodeInstruction> OnSyncBoughtItemsWithServerIL(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				for (int i = 3; i < list.Count; i++)
				{
					if (list[i - 3].opcode == OpCodes.Ldarg_1 && list[i - 2].opcode == OpCodes.Ldlen && list[i - 1].opcode == OpCodes.Conv_I4 && list[i].opcode == OpCodes.Ldc_I4_S && list[i].operand.ToString() == "12")
					{
						list[i].opcode = OpCodes.Ldc_I4;
						list[i].operand = 9999;
						break;
					}
				}
				return list.AsEnumerable();
			}

			[HarmonyTranspiler]
			[HarmonyPatch("BuyItemsServerRpc")]
			public static IEnumerable<CodeInstruction> OnBuyItemsServerRpcIL(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				for (int i = 4; i < list.Count; i++)
				{
					if (list[i - 4].opcode == OpCodes.Nop && list[i - 3].opcode == OpCodes.Ldarg_1 && list[i - 2].opcode == OpCodes.Ldlen && list[i - 1].opcode == OpCodes.Conv_I4 && list[i].opcode == OpCodes.Ldc_I4_S && list[i].operand.ToString() == "12")
					{
						list[i].opcode = OpCodes.Ldc_I4;
						list[i].operand = 9999;
						break;
					}
				}
				return list.AsEnumerable();
			}

			[HarmonyTranspiler]
			[HarmonyPatch("ParsePlayerSentence")]
			public static IEnumerable<CodeInstruction> OnParsePlayerSentenceIL(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> list = new List<CodeInstruction>(instructions);
				for (int i = 4; i < list.Count; i++)
				{
					if (list[i - 4].opcode == OpCodes.Ldarg_0 && list[i - 3].opcode == OpCodes.Ldloc_3 && list[i - 2].opcode == OpCodes.Call && list[i - 1].opcode == OpCodes.Ldc_I4_0 && list[i].opcode == OpCodes.Ldc_I4_S && list[i].operand.ToString() == "10")
					{
						list[i].opcode = OpCodes.Ldc_I4;
						list[i].operand = 999;
						break;
					}
				}
				return list.AsEnumerable();
			}
		}

		private static Terminal terminalScript = null;

		private static List<int> itemsToDeliver = null;

		private static float previousShipTimer = 0f;

		private static bool previousFirstOrder = true;

		[HarmonyPatch(typeof(ItemDropship), "Start")]
		[HarmonyPrefix]
		private static void InitializeDropship(ItemDropship __instance)
		{
			itemsToDeliver = (List<int>)Traverse.Create((object)__instance).Field("itemsToDeliver").GetValue();
		}

		[HarmonyPatch(typeof(Terminal), "Start")]
		[HarmonyPrefix]
		private static void InitializeTerminal(Terminal __instance)
		{
			terminalScript = __instance;
		}

		[HarmonyPatch(typeof(ItemDropship), "Update")]
		[HarmonyPrefix]
		private static void DropshipUpdatePrefix(ItemDropship __instance)
		{
			if (NetworkManager.Singleton.IsServer)
			{
				previousShipTimer = __instance.shipTimer;
				previousFirstOrder = __instance.playersFirstOrder;
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "Update")]
		[HarmonyPostfix]
		private static void DropshipUpdatePostfix(ItemDropship __instance)
		{
			if (NetworkManager.Singleton.IsServer && !__instance.deliveringOrder && (__instance.shipTimer < previousShipTimer || (previousFirstOrder && !__instance.playersFirstOrder)) && (terminalScript.orderedItemsFromTerminal.Count > 0 || terminalScript.orderedVehicleFromTerminal != -1))
			{
				__instance.shipTimer = 34f;
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "OpenShipDoorsOnServer")]
		[HarmonyPrefix]
		private static void PreOnOpenShipDoors(ItemDropship __instance)
		{
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			previousShipTimer = __instance.shipTimer;
			previousFirstOrder = __instance.playersFirstOrder;
			if (__instance.deliveringOrder && !__instance.shipDoorsOpened && (Object)(object)terminalScript != (Object)null)
			{
				while (terminalScript.orderedItemsFromTerminal.Count > 0)
				{
					itemsToDeliver.Add(terminalScript.orderedItemsFromTerminal[0]);
					terminalScript.orderedItemsFromTerminal.RemoveAt(0);
				}
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "OpenShipDoorsOnServer")]
		[HarmonyPostfix]
		private static void PostOnOpenShipDoors(ItemDropship __instance)
		{
			if (NetworkManager.Singleton.IsServer)
			{
				__instance.shipTimer = 27f;
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "ShipLandedAnimationEvent")]
		[HarmonyPostfix]
		private static void OnLandShipFinished(ItemDropship __instance)
		{
			if (!NetworkManager.Singleton.IsServer)
			{
				return;
			}
			__instance.shipTimer = -30f;
			if ((Object)(object)terminalScript != (Object)null)
			{
				while (terminalScript.orderedItemsFromTerminal.Count > 0)
				{
					itemsToDeliver.Add(terminalScript.orderedItemsFromTerminal[0]);
					terminalScript.orderedItemsFromTerminal.RemoveAt(0);
				}
			}
		}

		[HarmonyPatch(typeof(ItemDropship), "ShipLeave")]
		[HarmonyPatch(typeof(ItemDropship), "FinishDeliveringVehicleOnServer")]
		[HarmonyPostfix]
		private static void OnShipLeave(ItemDropship __instance)
		{
			__instance.shipTimer = 34f;
		}
	}
	[HarmonyPatch(typeof(EndRoundStatsPatch), "ReplaceEndGameScreen")]
	public class DayEndPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			if (!NetworkManager.Singleton.IsServer || StartOfRound.Instance.currentLevelID == 3)
			{
				return;
			}
			Networking.Instance.MoonSeedsVar.Value = (from _ in Enumerable.Range(0, Plugin.ChosenMoonNames.Count)
				select Random.Range(1000, 999999)).ToArray();
			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)(CauseOfDeath)(ref val.causeOfDeath)).ToString();
				}
				else if (!flag2)
				{
					causeOfDeath = "Abandoned";
				}
				Plugin.PlayersRegistry[val.playerClientId] = new PlayerStatus
				{
					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;
			EndGameStatsData endGameStatsData = new EndGameStatsData
			{
				TotalScrap = Plugin.totalScrapSurLune,
				CollectedScrap = Plugin.collectedScrapSurLune,
				Penalty = Plugin.TeamsPenalty,
				CollectedCount = Plugin.collectedNB,
				TotalCount = Plugin.allNB,
				PlayerRegistry = new List<PlayerStatusData>(),
				IndoorEnemyNames = Plugin.IndoorEnemyNames,
				OutdoorEnemyNames = Plugin.OutdoorEnemyNames
			};
			foreach (KeyValuePair<ulong, PlayerStatus> item in Plugin.PlayersRegistry)
			{
				endGameStatsData.PlayerRegistry.Add(new PlayerStatusData
				{
					ClientId = item.Key,
					PlayerName = item.Value.PlayerName,
					IsAlive = item.Value.IsAlive,
					Health = item.Value.Health,
					CauseOfDeath = item.Value.CauseOfDeath
				});
			}
			Networking.Instance.EndGameStatsMsg.SendClients(endGameStatsData);
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
	public class EnemyCalculator
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			if (!((NetworkBehaviour)StartOfRound.Instance).IsHost)
			{
				return;
			}
			Plugin.IndoorEnemyNames.Clear();
			Plugin.OutdoorEnemyNames.Clear();
			EnemyAI[] array = Object.FindObjectsOfType<EnemyAI>();
			EnemyAI[] array2 = array;
			foreach (EnemyAI val in array2)
			{
				if (!val.isEnemyDead)
				{
					((Component)StartOfRound.Instance).SendMessage(val.enemyType.enemyName);
					string enemyName = val.enemyType.enemyName;
					if (val.isOutside)
					{
						Plugin.OutdoorEnemyNames.Add(enemyName);
					}
					else
					{
						Plugin.IndoorEnemyNames.Add(enemyName);
					}
				}
			}
		}
	}
	[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)
			{
				Plugin.VisitedMoonNames.Add(((Object)StartOfRound.Instance.currentLevel).name);
				GMO_UIManager.Instance.ShowResults(stats);
			}
			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;
		}
	}
	public static class GMO_Animations
	{
		[CompilerGenerated]
		private sealed class <TerminalSequence>d__0 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public GMO_UIElements ui;

			public EndOfGameStats stats;

			public Action<bool> onComplete;

			private float <totalScrapInLevel>5__1;

			private float <collectedScrapValue>5__2;

			private float <ratio>5__3;

			private int <collectedCount>5__4;

			private int <totalCount>5__5;

			private string <grade>5__6;

			private StringBuilder <sb>5__7;

			private TMP_FontAsset <font>5__8;

			private IEnumerator <>s__9;

			private Transform <child>5__10;

			private IEnumerator <>s__11;

			private Transform <child>5__12;

			private IEnumerator <>s__13;

			private Transform <child>5__14;

			private Dictionary<ulong, PlayerStatus>.Enumerator <>s__15;

			private KeyValuePair<ulong, PlayerStatus> <entry>5__16;

			private ulong <playerId>5__17;

			private PlayerStatus <pData>5__18;

			private string <pName>5__19;

			private string <status>5__20;

			private bool <isDead>5__21;

			private List<string>.Enumerator <>s__22;

			private string <enemy>5__23;

			private List<string>.Enumerator <>s__24;

			private string <enemy>5__25;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				switch (<>1__state)
				{
				case -3:
				case 5:
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
					break;
				case -4:
				case 6:
					try
					{
					}
					finally
					{
						<>m__Finally2();
					}
					break;
				}
				<grade>5__6 = null;
				<sb>5__7 = null;
				<font>5__8 = null;
				<>s__9 = null;
				<child>5__10 = null;
				<>s__11 = null;
				<child>5__12 = null;
				<>s__13 = null;
				<child>5__14 = null;
				<>s__15 = default(Dictionary<ulong, PlayerStatus>.Enumerator);
				<entry>5__16 = default(KeyValuePair<ulong, PlayerStatus>);
				<pData>5__18 = null;
				<pName>5__19 = null;
				<status>5__20 = null;
				<>s__22 = default(List<string>.Enumerator);
				<enemy>5__23 = null;
				<>s__24 = default(List<string>.Enumerator);
				<enemy>5__25 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0507: Expected O, but got Unknown
				//IL_07bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_07dc: Expected O, but got Unknown
				//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_08cd: Expected O, but got Unknown
				//IL_0914: Unknown result type (might be due to invalid IL or missing references)
				//IL_091e: Expected O, but got Unknown
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Expected O, but got Unknown
				//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_06fb: Expected O, but got Unknown
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: Expected O, but got Unknown
				//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Expected O, but got Unknown
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						onComplete(obj: false);
						((TMP_Text)ui.GeneralStatsText).text = "";
						((TMP_Text)ui.TitleText).text = "ESTABLISHING CONNECTION...";
						<>s__9 = ui.PlayerListContent.GetEnumerator();
						try
						{
							while (<>s__9.MoveNext())
							{
								<child>5__10 = (Transform)<>s__9.Current;
								Object.Destroy((Object)(object)((Component)<child>5__10).gameObject);
								<child>5__10 = null;
							}
						}
						finally
						{
							if (<>s__9 is IDisposable disposable)
							{
								disposable.Dispose();
							}
						}
						<>s__9 = null;
						<>s__11 = ui.IndoorContent.GetEnumerator();
						try
						{
							while (<>s__11.MoveNext())
							{
								<child>5__12 = (Transform)<>s__11.Current;
								Object.Destroy((Object)(object)((Component)<child>5__12).gameObject);
								<child>5__12 = null;
							}
						}
						finally
						{
							if (<>s__11 is IDisposable disposable2)
							{
								disposable2.Dispose();
							}
						}
						<>s__11 = null;
						<>s__13 = ui.OutdoorContent.GetEnumerator();
						try
						{
							while (<>s__13.MoveNext())
							{
								<child>5__14 = (Transform)<>s__13.Current;
								Object.Destroy((Object)(object)((Component)<child>5__14).gameObject);
								<child>5__14 = null;
							}
						}
						finally
						{
							if (<>s__13 is IDisposable disposable3)
							{
								disposable3.Dispose();
							}
						}
						<>s__13 = null;
						((TMP_Text)ui.IndoorTitle).text = "INDOOR (0)";
						((TMP_Text)ui.OutdoorTitle).text = "OUTDOOR (0)";
						<>2__current = (object)new WaitForSeconds(0.5f);
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						((TMP_Text)ui.TitleText).text = $"MISSION REPORT | {TimeOfDay.Instance.daysUntilDeadline - 1} DAYS UNTIL DEADLINE";
						HUDManager.Instance.HideHUD(true);
						((Component)HUDManager.Instance.chatTextField).gameObject.SetActive(false);
						<totalScrapInLevel>5__1 = Plugin.totalScrapSurLune;
						<collectedScrapValue>5__2 = Plugin.collectedScrapSurLune;
						<ratio>5__3 = ((<totalScrapInLevel>5__1 > 0f) ? (<collectedScrapValue>5__2 / <totalScrapInLevel>5__1) : 0f);
						<collectedCount>5__4 = Plugin.collectedNB;
						<totalCount>5__5 = Plugin.allNB;
						<grade>5__6 = "D";
						if (<ratio>5__3 >= 0.95f)
						{
							<grade>5__6 = "S";
						}
						else if (<ratio>5__3 > 0.75f)
						{
							<grade>5__6 = "A";
						}
						else if (<ratio>5__3 > 0.5f)
						{
							<grade>5__6 = "B";
						}
						else if (<ratio>5__3 > 0.25f)
						{
							<grade>5__6 = "C";
						}
						<sb>5__7 = new StringBuilder();
						<sb>5__7.AppendLine("<color=#FF720D>SECTOR:</color> " + RoundManager.Instance.currentLevel.PlanetName);
						<sb>5__7.AppendLine($"<color=#FF720D>ITEMS RETRIEVED:</color> {<collectedCount>5__4} / {<totalCount>5__5}");
						<sb>5__7.AppendLine($"<color=#FF720D>SCRAP COLLECTED:</color> {<collectedScrapValue>5__2}$ / {<totalScrapInLevel>5__1}$");
						<sb>5__7.AppendLine($"<color=#FF720D>CREW EFFICIENCY:</color> {<ratio>5__3 * 100f:F0}%");
						<sb>5__7.AppendLine("");
						<sb>5__7.AppendLine("");
						<sb>5__7.AppendLine("<size=150%>GRADE: <color=#FFFFFF>[ " + <grade>5__6 + " ]</color></size>");
						<sb>5__7.AppendLine("");
						if (Plugin.TeamsPenalty > 0)
						{
							<sb>5__7.AppendLine($"<color=red>CASUALTY FINES:</color> -{Plugin.TeamsPenalty}$");
						}
						else
						{
							<sb>5__7.AppendLine("<color=green>CASUALTY FINES:</color> NONE");
						}
						<>2__current = Type(ui.GeneralStatsText, <sb>5__7.ToString());
						<>1__state = 2;
						return true;
					case 2:
						<>1__state = -1;
						<>2__current = (object)new WaitForSeconds(0.3f);
						<>1__state = 3;
						return true;
					case 3:
						<>1__state = -1;
						<font>5__8 = ((TMP_Text)HUDManager.Instance.weightCounter).font;
						<>s__15 = Plugin.PlayersRegistry.GetEnumerator();
						try
						{
							while (<>s__15.MoveNext())
							{
								<entry>5__16 = <>s__15.Current;
								<playerId>5__17 = <entry>5__16.Key;
								<pData>5__18 = <entry>5__16.Value;
								<pName>5__19 = <pData>5__18.PlayerName;
								<status>5__20 = "ACTIVE";
								<isDead>5__21 = !<pData>5__18.IsAlive;
								if (<isDead>5__21)
								{
									<status>5__20 = "DECEASED (" + <pData>5__18.CauseOfDeath + ")";
								}
								else if (<pData>5__18.Health <= 20)
								{
									<status>5__20 = $"CRITICAL ({<pData>5__18.Health}HP)";
								}
								else if (<pData>5__18.Health <= 75)
								{
									<status>5__20 = $"INJURED ({<pData>5__18.Health}HP)";
								}
								else
								{
									<status>5__20 = $"STABLE ({<pData>5__18.Health}HP)";
								}
								ui.CreatePlayerRow(<pName>5__19, <status>5__20, <isDead>5__21, <font>5__8);
								<pData>5__18 = null;
								<pName>5__19 = null;
								<status>5__20 = null;
								<entry>5__16 = default(KeyValuePair<ulong, PlayerStatus>);
							}
						}
						finally
						{
							((IDisposable)<>s__15).Dispose();
						}
						<>s__15 = default(Dictionary<ulong, PlayerStatus>.Enumerator);
						<>2__current = (object)new WaitForSeconds(0.15f);
						<>1__state = 4;
						return true;
					case 4:
						<>1__state = -1;
						Debug.Log((object)$"[GMO] Debug Ennemis - Indoor: {Plugin.IndoorEnemyNames.Count} | Outdoor: {Plugin.OutdoorEnemyNames.Count}");
						((TMP_Text)ui.IndoorTitle).text = $"INDOOR ({Plugin.IndoorEnemyNames.Count})";
						<>s__22 = Plugin.IndoorEnemyNames.GetEnumerator();
						<>1__state = -3;
						goto IL_07fa;
					case 5:
						<>1__state = -3;
						<enemy>5__23 = null;
						goto IL_07fa;
					case 6:
						<>1__state = -4;
						<enemy>5__25 = null;
						goto IL_08eb;
					case 7:
						{
							<>1__state = -1;
							ui.BtnObj.SetActive(true);
							onComplete(obj: true);
							return false;
						}
						IL_07fa:
						if (<>s__22.MoveNext())
						{
							<enemy>5__23 = <>s__22.Current;
							ui.CreateSimpleRow(ui.IndoorContent, "> " + <enemy>5__23.ToUpper(), Color.white, <font>5__8);
							<>2__current = (object)new WaitForSeconds(0.05f);
							<>1__state = 5;
							return true;
						}
						<>m__Finally1();
						<>s__22 = default(List<string>.Enumerator);
						((TMP_Text)ui.OutdoorTitle).text = $"OUTDOOR ({Plugin.OutdoorEnemyNames.Count})";
						<>s__24 = Plugin.OutdoorEnemyNames.GetEnumerator();
						<>1__state = -4;
						goto IL_08eb;
						IL_08eb:
						if (<>s__24.MoveNext())
						{
							<enemy>5__25 = <>s__24.Current;
							ui.CreateSimpleRow(ui.OutdoorContent, "> " + <enemy>5__25.ToUpper(), new Color(1f, 0.6f, 0f), <font>5__8);
							<>2__current = (object)new WaitForSeconds(0.05f);
							<>1__state = 6;
							return true;
						}
						<>m__Finally2();
						<>s__24 = default(List<string>.Enumerator);
						<>2__current = (object)new WaitForSeconds(3f);
						<>1__state = 7;
						return true;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__22).Dispose();
			}

			private void <>m__Finally2()
			{
				<>1__state = -1;
				((IDisposable)<>s__24).Dispose();
			}

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

		[CompilerGenerated]
		private sealed class <Type>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public TextMeshProUGUI el;

			public string t;

			private int <total>5__1;

			private TMP_TextInfo <textInfo>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					if (((TMP_Text)el).maxVisibleCharacters >= ((TMP_Text)el).textInfo.characterCount)
					{
						goto IL_00d8;
					}
				}
				else
				{
					<>1__state = -1;
					((TMP_Text)el).text = t;
					((TMP_Text)el).maxVisibleCharacters = 0;
					<total>5__1 = t.Length;
					<textInfo>5__2 = ((TMP_Text)el).textInfo;
				}
				if (((TMP_Text)el).maxVisibleCharacters < <total>5__1)
				{
					TextMeshProUGUI obj = el;
					int maxVisibleCharacters = ((TMP_Text)obj).maxVisibleCharacters;
					((TMP_Text)obj).maxVisibleCharacters = maxVisibleCharacters + 1;
					<>2__current = (object)new WaitForSeconds(0.01f);
					<>1__state = 1;
					return true;
				}
				goto IL_00d8;
				IL_00d8:
				((TMP_Text)el).maxVisibleCharacters = 99999;
				return false;
			}

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

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

		[IteratorStateMachine(typeof(<TerminalSequence>d__0))]
		public static IEnumerator TerminalSequence(GMO_UIElements ui, EndOfGameStats stats, Action<bool> onComplete)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TerminalSequence>d__0(0)
			{
				ui = ui,
				stats = stats,
				onComplete = onComplete
			};
		}

		[IteratorStateMachine(typeof(<Type>d__1))]
		private static IEnumerator Type(TextMeshProUGUI el, string t)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Type>d__1(0)
			{
				el = el,
				t = t
			};
		}
	}
	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 val7 = (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 val7))..ctor(0.5f, 0.15f);
			val8.anchorMax = val7;
			val8.anchorMin = val7;
			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(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)
			{
				Plugin.IsDiverting = true;
				return true;
			}
			if (Plugin.ChosenMoonNames.Contains(((Object)__instance.currentLevel).name) && !Plugin.VisitedMoonNames.Contains(((Object)__instance.currentLevel).name))
			{
				Plugin.IsDiverting = true;
				return true;
			}
			if (list.Count > 0)
			{
				string randomName = list[Random.Range(0, list.Count)];
				SelectableLevel val = ((IEnumerable<SelectableLevel>)__instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => ((Object)l).name == randomName));
				int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits;
				if ((Object)(object)val != (Object)null)
				{
					Plugin.IsDiverting = true;
					__instance.ChangeLevelServerRpc(val.levelID, groupCredits);
				}
				if ((Object)(object)val != (Object)null)
				{
					Networking.Instance.HudAlertMsg.SendClients(val.PlanetName);
				}
				return false;
			}
			Plugin.IsDiverting = true;
			return true;
		}
	}
	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;

			[HarmonyPrefix]
			private static void Prefix(TimeOfDay __instance, ref float time)
			{
				if ((Object)(object)StartOfRound.Instance?.currentLevel == (Object)null)
				{
					return;
				}
				if (StartOfRound.Instance.inShipPhase)
				{
					IsTimeAppliedForToday = false;
				}
				else if (!IsTimeAppliedForToday && !(time > 250f))
				{
					GenerateLandingTimes();
					string name = ((Object)StartOfRound.Instance.currentLevel).name;
					if (MoonLandingTimes.TryGetValue(name, out MoonTimeData value))
					{
						float num = value.TargetHour - 6f;
						float num2 = ((__instance.totalTime > 0f) ? __instance.totalTime : 1100f);
						time = num / 18f * num2;
						IsTimeAppliedForToday = true;
						int num3 = Plugin.ChosenMoonNames.IndexOf(name);
						int num4 = ((num3 != -1) ? Plugin.MoonSeeds[num3] : 0);
						Debug.Log((object)$"[GMO] Landing on {name}: Time forced to {value.TargetHour:F2}h (Type: {value.Type}) using Seed: {num4}");
					}
				}
			}
		}

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

		public static void GenerateLandingTimes()
		{
			if (Plugin.ChosenMoonNames == null || Plugin.MoonSeeds == null)
			{
				return;
			}
			MoonLandingTimes.Clear();
			for (int i = 0; i < Plugin.ChosenMoonNames.Count && i < Plugin.MoonSeeds.Count; i++)
			{
				string key = Plugin.ChosenMoonNames[i];
				int seed = Plugin.MoonSeeds[i];
				Random random = new Random(seed);
				int num = random.Next(0, 3);
				LandingTimeType landingTimeType = (LandingTimeType)num;
				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[key] = new MoonTimeData
				{
					Type = landingTimeType,
					TargetHour = targetHour
				};
			}
		}
	}
	public class ScrapTracker
	{
		private static string[] excludedItems = new string[3] { "Knife", "Shotgun", "Key" };

		private static int interiorCount = 0;

		private static int exteriorCount = 0;

		private static HashSet<int> _trackedScrapIds = new HashSet<int>();

		public static void ScanMapForPotentialScrap()
		{
			ResetTracker();
			GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
			GrabbableObject[] array2 = array;
			foreach (GrabbableObject val in array2)
			{
				if (IsValidTargetScrap(val))
				{
					_trackedScrapIds.Add(((Object)val).GetInstanceID());
					Plugin.totalScrapSurLune += val.scrapValue;
					Plugin.allNB++;
					if (!val.itemProperties.itemName.Equals("Hive") && !val.itemProperties.itemName.Equals("Egg"))
					{
						interiorCount++;
					}
					else
					{
						exteriorCount++;
					}
				}
			}
			Debug.Log((object)$"[ScrapTracker] Scan terminé. Potentiel: {Plugin.allNB} objets pour {Plugin.totalScrapSurLune}$");
		}

		public static void CalculateCollectedScrap()
		{
			Plugin.collectedScrapSurLune = 0;
			Plugin.collectedNB = 0;
			IEnumerable<GrabbableObject> enumerable = from obj in Object.FindObjectsOfType<GrabbableObject>()
				where IsInShip(obj)
				select obj;
			foreach (GrabbableObject item in enumerable)
			{
				if (_trackedScrapIds.Contains(((Object)item).GetInstanceID()))
				{
					Plugin.collectedScrapSurLune += item.scrapValue;
					Plugin.collectedNB++;
				}
			}
		}

		private static void ResetTracker()
		{
			Plugin.totalScrapSurLune = 0;
			Plugin.allNB = 0;
			Plugin.collectedScrapSurLune = 0;
			Plugin.collectedNB = 0;
			interiorCount = 0;
			exteriorCount = 0;
			_trackedScrapIds.Clear();
		}

		private static bool IsValidTargetScrap(GrabbableObject obj)
		{
			if ((Object)(object)obj == (Object)null || (Object)(object)obj.itemProperties == (Object)null)
			{
				return false;
			}
			return obj.scrapValue > 0 && !excludedItems.Contains(obj.itemProperties.itemName) && !IsInShip(obj);
		}

		public static bool IsInShip(GrabbableObject obj)
		{
			if ((Object)(object)obj == (Object)null)
			{
				return false;
			}
			return obj.isInShipRoom || obj.isInElevator;
		}

		public static void SendChatMessage()
		{
			HUDManager instance = HUDManager.Instance;
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if (!((Object)(object)instance == (Object)null) && !((Object)(object)val == (Object)null) && !((Object)TimeOfDay.Instance.currentLevel).name.Equals("CompanyBuildingLevel"))
			{
				if (interiorCount > 0)
				{
					instance.AddTextToChatOnServer($"Indoor Scrap : {interiorCount}", -1);
				}
				if (exteriorCount > 0)
				{
					instance.AddTextToChatOnServer($"Outdoor Scrap : {exteriorCount}", -1);
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class ScrapPatch
	{
		[HarmonyPatch("OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void Postfix()
		{
			if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsHost)
			{
				Plugin.IsDiverting = false;
				ScrapTracker.ScanMapForPotentialScrap();
				ScrapTracker.SendChatMessage();
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class DeathPenaltyPatch
	{
		[HarmonyPatch("ApplyPenalty")]
		[HarmonyPrefix]
		private static bool CancelPenaltyAtCompany()
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.currentLevel != (Object)null && !StartOfRound.Instance.currentLevel.planetHasTime)
			{
				return false;
			}
			return true;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.mrkixcat.companyprotocols", "Company Protocols", "0.0.8")]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		public class SavedMoonItem
		{
			public string itemName = null;

			public Vector3 pos;

			public Vector3 rot;

			public int scrapValue;
		}

		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<float> BaseMultiplier = null;

		public static ConfigEntry<float> MultiplierIncrement = null;

		public static ConfigEntry<bool> EnableVisualOverhaul = null;

		public static ConfigEntry<bool> HideHUD = 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 bool IsDiverting;

		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, PlayerStatus> PlayersRegistry = new Dictionary<ulong, PlayerStatus>();

		public static void Init(ConfigFile config)
		{
			EnableVisualOverhaul = config.Bind<bool>("Client", "VisualOverhaul", false, "Some visual changes");
			HideHUD = config.Bind<bool>("Client", "HideHUD", false, "Hide HUD ( lol )");
			ExcludedMoons = config.Bind<string>("MoonRotation", "Excluded Moons", "Gordion,Liquidation,Paradon", "These moons will not be chosen.");
			BaseMultiplier = config.Bind<float>("Quota", "Base Multiplier", 1f, "Base multiplier of the first quota.");
			MultiplierIncrement = config.Bind<float>("Quota", "Multiplier Increment", 0.25f, "How much are increasing future quotas.");
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Log = Logger.CreateLogSource("Company Protocols");
			try
			{
				Init(((BaseUnityPlugin)this).Config);
				CurrentRunMultiplier = BaseMultiplier.Value;
				Networking.Init();
				harmony.PatchAll();
				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}", CurrentRunMultiplier, string.Join(",", MoonSeeds), string.Join(",", ChosenMoonNames), string.Join(",", VisitedMoonNames));
				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();
				}
			}
			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 l.PlanetName.Replace("\n", "");
			return enumerable.Any() ? string.Join(", ", enumerable) : "Unknown";
		}
	}
	[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
	public class SaveLoadPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			if (NetworkManager.Singleton.IsServer)
			{
				Plugin.LoadData();
			}
		}
	}
	[HarmonyPatch(typeof(DeleteFileButton), "DeleteFile")]
	public class DeletePatch
	{
		[HarmonyPrefix]
		private static void Prefix(DeleteFileButton __instance)
		{
			string text = "";
			text = __instance.fileToDelete switch
			{
				0 => "LCSaveFile1", 
				1 => "LCSaveFile2", 
				2 => "LCSaveFile3", 
				_ => "LCSaveFile1", 
			};
			string path = Path.Combine(Application.persistentDataPath, text + "_gmo.txt");
			string path2 = Path.Combine(Application.persistentDataPath, text + "_paradon_gmo.txt");
			try
			{
				if (File.Exists(path))
				{
					File.Delete(path);
					Plugin.Log.LogInfo((object)("[DELETE] Global save destroyed for " + text));
				}
				if (File.Exists(path2))
				{
					File.Delete(path2);
					Plugin.Log.LogInfo((object)("[DELETE] Paradon save destroyed for " + text));
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[DELETE ERROR] : " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "SaveGame")]
	public class OnDisconnectedPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			Plugin.SaveData();
		}
	}
	[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.IsDiverting = false;
			Plugin.VisitedMoonNames.Clear();
			Plugin.ChosenMoonNames.Clear();
			Plugin.MoonSeeds.Clear();
		}
	}
	[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
	public class QuotaPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(TimeOfDay __instance)
		{
			if (!NetworkManager.Singleton.IsServer)
			{
				return false;
			}
			if (__instance.timesFulfilledQuota > 0)
			{
				Plugin.CurrentRunMultiplier += Plugin.MultiplierIncrement.Value;
			}
			else
			{
				Plugin.CurrentRunMultiplier = Plugin.BaseMultiplier.Value;
			}
			GenerateRandomMoons();
			float num = 0f;
			int num2 = 0;
			foreach (string name in Plugin.ChosenMoonNames)
			{
				SelectableLevel val = ((IEnumerable<SelectableLevel>)StartOfRound.Instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => ((Object)l).name == name));
				if ((Object)(object)val != (Object)null)
				{
					float num3 = 1f;
					if (val.PlanetName == "7 Dine")
					{
						num3 = 0.25f;
					}
					float num4 = TerminalDisplayPatch.CalculateMoonScrapAverage(val) * num3;
					num += num4;
					num2++;
				}
			}
			if (num2 > 0)
			{
				float num5 = num / 3f;
				float num6 = num5 * Plugin.CurrentRunMultiplier;
				__instance.profitQuota = Mathf.RoundToInt(num6);
			}
			__instance.quotaFulfilled = 0;
			__instance.timeUntilDeadline = __instance.totalTime * 3f;
			Plugin.MoonSeeds.Clear();
			for (int i = 0; i < Plugin.ChosenMoonNames.Count; i++)
			{
				Plugin.MoonSeeds.Add(Random.Range(1000, 999999));
			}
			Plugin.SaveData();
			if (NetworkManager.Singleton.IsServer)
			{
				Networking.Instance.ChosenMoonsVar.Value = Plugin.ChosenMoonNames.ToArray();
				Networking.Instance.VisitedMoonsVar.Value = Plugin.VisitedMoonNames.ToArray();
				Networking.Instance.MoonSeedsVar.Value = Plugin.MoonSeeds.ToArray();
			}
			__instance.SyncNewProfitQuotaClientRpc(__instance.profitQuota, 0, __instance.timesFulfilledQuota);
			return false;
		}

		public static void GenerateRandomMoons()
		{
			if ((Object)(object)StartOfRound.Instance == (Object)null || StartOfRound.Instance.levels == null)
			{
				return;
			}
			Random random = new Random(Guid.NewGuid().GetHashCode());
			Plugin.ChosenMoonNames.Clear();
			Plugin.VisitedMoonNames.Clear();
			string[] excluded = (from s in Plugin.ExcludedMoons.Value.Split(',')
				select s.Trim().ToLower()).ToArray();
			List<SelectableLevel> list = StartOfRound.Instance.levels.Where((SelectableLevel l) => (Object)(object)l != (Object)null && l.levelID != 3 && !excluded.Any((string ex) => l.PlanetName.ToLower().Contains(ex))).ToList();
			int num = Math.Min(3, list.Count);
			for (int i = 0; i < num; i++)
			{
				int index = random.Next(list.Count);
				Plugin.ChosenMoonNames.Add(((Object)list[index]).name);
				list.RemoveAt(index);
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	public class HUDRemoverPatches
	{
		[HarmonyPatch("BeginDisplayAd")]
		[HarmonyPrefix]
		private static bool OnDisplayAd()
		{
			return false;
		}

		[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;
		}

		[HarmonyPatch("DisplayTip")]
		[HarmonyPrefix]
		private static bool BlockSmallTips(string headerText, string bodyText)
		{
			if ((Object)(object)TimeOfDay.Instance != (Object)null && TimeOfDay.Instance.daysUntilDeadline <= 0 && !string.IsNullOrEmpty(bodyText) && bodyText.Contains("route to the company"))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(TimeOfDay))]
	internal class TimeOfDayRemoverPatches
	{
		[HarmonyPatch("SetTimeForAdToPlay")]
		[HarmonyPrefix]
		private static bool OnAdTimer()
		{
			TimeOfDay.Instance.normalizedTimeToShowAd = -1f;
			return false;
		}
	}
	[HarmonyPatch(typeof(RoundManager))]
	internal static class AtmosphericRemoverPatches
	{
		[HarmonyPatch("RefreshEnemiesList")]
		[HarmonyPostfix]
		private static void AdjustAtmosphericClarity()
		{
			if ((Object)(object)RoundManager.Instance?.indoorFog != (Object)null)
			{
				GameObject gameObject = ((Component)RoundManager.Instance.indoorFog).gameObject;
				if (gameObject.activeSelf)
				{
					gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch("FinishGeneratingLevel")]
		[HarmonyPostfix]
		private static void PurgeSubterraneanAerosols()
		{
			LocalVolumetricFog[] array = Object.FindObjectsByType<LocalVolumetricFog>((FindObjectsSortMode)0);
			LocalVolumetricFog[] array2 = array;
			foreach (LocalVolumetricFog val in array2)
			{
				if (IsPositionBelowSurface(val))
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		private static bool IsPositionBelowSurface(LocalVolumetricFog targetVolume)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)RoundManager.Instance?.dungeonGenerator?.Root == (Object)null)
			{
				return false;
			}
			float num = RoundManager.Instance.dungeonGenerator.Root.transform.position.y + 10f;
			float num2 = ((Component)targetVolume).transform.position.y - targetVolume.parameters.size.y / 2f;
			return num2 <= num;
		}
	}
	[HarmonyPatch(typeof(DepositItemsDesk))]
	public class DepositItemsDeskPatch
	{
		[HarmonyPatch("SellAndDisplayItemProfits")]
		[HarmonyPostfix]
		public static void PreventQuotaFill(int profit)
		{
			TimeOfDay instance = TimeOfDay.Instance;
			instance.quotaFulfilled -= profit;
			TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	public class TerminalQuotaPatch
	{
		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPrefix]
		public static bool AddQuotaCommand(Terminal __instance, ref TerminalNode __result)
		{
			string text = __instance.screenText.text;
			int textAdded = __instance.textAdded;
			if (textAdded <= 0)
			{
				return true;
			}
			string text2 = text.Substring(text.Length - textAdded).Trim().ToLower();
			if (text2 == "quota")
			{
				int num = TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled;
				if (num <= 0)
				{
					__result = CreateNode("THE QUOTA IS ALREADY FULFILLED.\n\n");
					return false;
				}
				if (__instance.groupCredits >= num)
				{
					Networking.Instance.PayQuotaRequestMsg.SendServer(num);
					__result = CreateNode($"PROCESSING PAYMENT...\nSent {num} credits to The Company.\n\n");
				}
				else
				{
					__result = CreateNode($"INSUFFICIENT FUNDS.\nRemaining quota: {num}\nYour credits: {__instance.groupCredits}\n\n");
				}
				return false;
			}
			return true;
		}

		private static TerminalNode CreateNode(string text)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.displayText = text;
			val.clearPreviousText = true;
			return val;
		}
	}
}
namespace CompanyProtocols.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}