Decompiled source of CompanyProtocols v0.0.1

GameMecanicOverhaul.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
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: AssemblyTitle("GameMecanicOverhaul")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GameMecanicOverhaul")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3103ce72-f6b3-44d1-bae3-2b8ceeb84dc0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GameMecanicOverhaul;

[HarmonyPatch(typeof(HUDManager))]
internal class InterfaceHooks
{
	[HarmonyPatch("BeginDisplayAd")]
	[HarmonyPrefix]
	private static bool OnDisplayAd()
	{
		return false;
	}
}
[HarmonyPatch(typeof(TimeOfDay))]
internal class WorldHooks
{
	[HarmonyPatch("SetTimeForAdToPlay")]
	[HarmonyPrefix]
	private static bool OnAdTimer()
	{
		TimeOfDay.Instance.normalizedTimeToShowAd = -1f;
		return false;
	}
}
[HarmonyPatch(typeof(HUDManager))]
public class NotificationManager
{
	[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]
internal static class DropshipManagementPatch
{
	private static Terminal terminalScript;

	private static List<int> itemsToDeliver;

	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;
	}
}
public class ScrapTracker
{
	public static List<GrabbableObject> StartingItems = new List<GrabbableObject>();

	public static void UpdateInitialItems()
	{
		StartingItems.Clear();
		IEnumerable<GrabbableObject> collection = from obj in Object.FindObjectsOfType<GrabbableObject>()
			where IsInShip(obj)
			select obj;
		StartingItems.AddRange(collection);
		Debug.Log((object)$"[GameMecanicOverhaul] {StartingItems.Count} objets ignorés (déjà dans le vaisseau).");
	}

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

	public static bool IsRealNewScrap(GrabbableObject obj)
	{
		return (Object)(object)obj != (Object)null && obj.itemProperties.isScrap && (Object)(object)((Component)obj).GetComponent<RagdollGrabbableObject>() == (Object)null && !StartingItems.Contains(obj);
	}
}
[HarmonyPatch(typeof(StartOfRound))]
public class ScrapPatch
{
	[HarmonyPatch("OnShipLandedMiscEvents")]
	[HarmonyPostfix]
	private static void Postfix()
	{
		ScrapTracker.UpdateInitialItems();
	}
}
[HarmonyPatch(typeof(StartOfRound), "ArriveAtLevel")]
public class AutoLandingPatch
{
	[HarmonyPostfix]
	private static void Postfix(StartOfRound __instance)
	{
		if (NetworkManager.Singleton.IsServer && Plugin.IsDiverting)
		{
			Networking.Instance.UpdateDivertingStatus(newValue: false);
			__instance.StartGameServerRpc();
		}
	}
}
[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");
		try
		{
			if (File.Exists(path))
			{
				File.Delete(path);
				Plugin.Instance.Log.LogInfo((object)("[DELETE] Save file destroyed " + text));
			}
		}
		catch (Exception ex)
		{
			Plugin.Instance.Log.LogError((object)("[DELETE ERROR] : " + ex.Message));
		}
	}
}
[HarmonyPatch(typeof(HUDManager), "FillEndGameStats")]
public class EndRoundStatsPatch
{
	[HarmonyPrefix]
	public static bool ReplaceEndGameScreen(HUDManager __instance, EndOfGameStats stats)
	{
		if (!Plugin.EndOfRoundStatsRevampEnabled.Value)
		{
			return true;
		}
		if ((Object)(object)GMO_UIManager.Instance == (Object)null)
		{
			GMO_UIManager.Instance = ((Component)__instance).gameObject.AddComponent<GMO_UIManager>();
			GMO_UIManager.Instance.Initialize();
		}
		HUDManager.Instance.RemoveSpectateUI();
		GMO_UIManager.Instance.ShowResults(stats);
		Plugin.VisitedMoonIDs.Add(StartOfRound.Instance.currentLevelID);
		Plugin.SaveData();
		return false;
	}
}
[HarmonyPatch(typeof(HUDManager))]
public class LevelUIPatch
{
	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	public static void PostfixXP(HUDManager __instance)
	{
		if (Plugin.EndOfRoundStatsRevampEnabled.Value && (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.EndOfRoundStatsRevampEnabled.Value)
		{
			return true;
		}
		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>, IDisposable, IEnumerator
	{
		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 Dictionary<ulong, PlayerStatus>.Enumerator <>s__11;

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

		private ulong <playerId>5__13;

		private PlayerStatus <pData>5__14;

		private string <pName>5__15;

		private string <status>5__16;

		private bool <isDead>5__17;

		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()
		{
			int num = <>1__state;
			if (num == -3 || num == 4)
			{
				try
				{
				}
				finally
				{
					<>m__Finally1();
				}
			}
			<grade>5__6 = null;
			<sb>5__7 = null;
			<font>5__8 = null;
			<>s__9 = null;
			<child>5__10 = null;
			<>s__11 = default(Dictionary<ulong, PlayerStatus>.Enumerator);
			<entry>5__12 = default(KeyValuePair<ulong, PlayerStatus>);
			<pData>5__14 = null;
			<pName>5__15 = null;
			<status>5__16 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Expected O, but got Unknown
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Expected O, but got Unknown
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: 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;
					<>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__11 = Plugin.PlayersRegistry.GetEnumerator();
					<>1__state = -3;
					goto IL_05bf;
				case 4:
					<>1__state = -3;
					<pData>5__14 = null;
					<pName>5__15 = null;
					<status>5__16 = null;
					<entry>5__12 = default(KeyValuePair<ulong, PlayerStatus>);
					goto IL_05bf;
				case 5:
					{
						<>1__state = -1;
						ui.BtnObj.SetActive(true);
						onComplete(obj: true);
						return false;
					}
					IL_05bf:
					if (<>s__11.MoveNext())
					{
						<entry>5__12 = <>s__11.Current;
						<playerId>5__13 = <entry>5__12.Key;
						<pData>5__14 = <entry>5__12.Value;
						<pName>5__15 = <pData>5__14.PlayerName;
						<status>5__16 = "ACTIVE";
						<isDead>5__17 = !<pData>5__14.IsAlive;
						if (<isDead>5__17)
						{
							<status>5__16 = "DECEASED (" + <pData>5__14.CauseOfDeath + ")";
						}
						else if (<pData>5__14.Health <= 20)
						{
							<status>5__16 = $"CRITICAL ({<pData>5__14.Health}HP)";
						}
						else if (<pData>5__14.Health <= 75)
						{
							<status>5__16 = $"INJURED ({<pData>5__14.Health}HP)";
						}
						else
						{
							<status>5__16 = $"STABLE ({<pData>5__14.Health}HP)";
						}
						ui.CreatePlayerRow(<pName>5__15, <status>5__16, <isDead>5__17, <font>5__8);
						<>2__current = (object)new WaitForSeconds(0.15f);
						<>1__state = 4;
						return true;
					}
					<>m__Finally1();
					<>s__11 = default(Dictionary<ulong, PlayerStatus>.Enumerator);
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 5;
					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__11).Dispose();
		}

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

	[CompilerGenerated]
	private sealed class <Type>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		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__9_0;

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

	public GameObject CanvasObj;

	public GameObject BtnObj;

	public TextMeshProUGUI TitleText;

	public TextMeshProUGUI GeneralStatsText;

	public Transform PlayerListContent;

	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_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Expected O, but got Unknown
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: 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);
		CreatePlayerScrollView(val4.transform);
		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__9_0;
		if (obj == null)
		{
			UnityAction val10 = delegate
			{
				GMO_UIManager.Instance.OnContinueClicked();
			};
			<>c.<>9__9_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 playerName, 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: 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_0170: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("PlayerRow");
		val.transform.SetParent(PlayerListContent, false);
		((Graphic)val.AddComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.6f);
		val.AddComponent<LayoutElement>().minHeight = 40f;
		TextMeshProUGUI val2 = CreateTxt("Name", val.transform, font, 22, Vector2.zero);
		((TMP_Text)val2).text = playerName;
		((TMP_Text)val2).alignment = (TextAlignmentOptions)4097;
		((TMP_Text)val2).rectTransform.anchorMin = new Vector2(0.02f, 0f);
		((TMP_Text)val2).rectTransform.anchorMax = new Vector2(0.5f, 1f);
		RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
		Vector2 offsetMin = (((TMP_Text)val2).rectTransform.offsetMax = Vector2.zero);
		rectTransform.offsetMin = offsetMin;
		((Graphic)val2).color = _cOrangeFull;
		TextMeshProUGUI val3 = CreateTxt("Status", val.transform, font, 22, Vector2.zero);
		((TMP_Text)val3).text = status;
		((TMP_Text)val3).alignment = (TextAlignmentOptions)4100;
		((TMP_Text)val3).rectTransform.anchorMin = new Vector2(0.5f, 0f);
		((TMP_Text)val3).rectTransform.anchorMax = new Vector2(0.98f, 1f);
		RectTransform rectTransform2 = ((TMP_Text)val3).rectTransform;
		offsetMin = (((TMP_Text)val3).rectTransform.offsetMax = Vector2.zero);
		rectTransform2.offsetMin = offsetMin;
		((Graphic)val3).color = (isDead ? _cRed : Color.green);
	}

	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_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		r.anchorMin = Vector2.zero;
		r.anchorMax = Vector2.one;
		Vector2 offsetMin = (r.offsetMax = Vector2.zero);
		r.offsetMin = offsetMin;
	}
}
public class GMO_UIManager : MonoBehaviour
{
	public static GMO_UIManager Instance;

	public GMO_UIElements Elements;

	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(RoundManager))]
internal static class AtmosphericDensityCorrector
{
	[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;
	}
}
public struct MoonSyncData : INetworkSerializable
{
	public float CurrentMultiplier;

	public int[] MoonIDs;

	public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		((BufferSerializer<float>*)(&serializer))->SerializeValue<float>(ref CurrentMultiplier, default(ForPrimitives));
		int num = 0;
		if (!serializer.IsReader)
		{
			num = ((MoonIDs != null) ? MoonIDs.Length : 0);
		}
		((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref num, default(ForPrimitives));
		if (serializer.IsReader)
		{
			MoonIDs = new int[num];
		}
		for (int i = 0; i < num; i++)
		{
			((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref MoonIDs[i], default(ForPrimitives));
		}
	}
}
public struct HudAlertData : INetworkSerializable
{
	public int MoonID;

	public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref MoonID, default(ForPrimitives));
	}
}
public class Networking
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static HandleNamedMessageDelegate <>9__13_1;

		internal void <RegisterHandlers>b__13_1(ulong sender, FastBufferReader reader)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (((FastBufferReader)(ref reader)).TryBeginRead(1))
			{
				bool isDiverting = default(bool);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isDiverting, default(ForPrimitives));
				Plugin.IsDiverting = isDiverting;
			}
		}
	}

	private const string MOD_GUID = "com.mrkixcat.gamemecanicoverhaul";

	private const string MSG_SYNC_DATA = "com.mrkixcat.gamemecanicoverhaul_SyncData";

	private const string MSG_REQUEST_SYNC = "com.mrkixcat.gamemecanicoverhaul_RequestSync";

	private const string MSG_HUD_ALERT = "com.mrkixcat.gamemecanicoverhaul_HudAlert";

	private const string MSG_SYNC_DIVERTING = "com.mrkixcat.gamemecanicoverhaul_SyncDiverting";

	private const string MSG_SYNC_ENDGAME = "com.mrkixcat.gamemecanicoverhaul_SyncEndGame";

	private ManualLogSource _logger;

	public static Networking Instance { get; private set; }

	public Networking(ManualLogSource logger)
	{
		Instance = this;
		_logger = logger;
	}

	public static void Init(ManualLogSource logger)
	{
		if (Instance == null)
		{
			new Networking(logger);
		}
	}

	public void RegisterHandlers()
	{
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Expected O, but got Unknown
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Expected O, but got Unknown
		if ((Object)(object)NetworkManager.Singleton == (Object)null || NetworkManager.Singleton.CustomMessagingManager == null)
		{
			return;
		}
		CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager;
		customMessagingManager.UnregisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_SyncData");
		customMessagingManager.UnregisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_HudAlert");
		customMessagingManager.UnregisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_RequestSync");
		customMessagingManager.UnregisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_SyncDiverting");
		customMessagingManager.UnregisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_SyncEndGame");
		customMessagingManager.RegisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_SyncEndGame", new HandleNamedMessageDelegate(ReceiveEndGameStats));
		customMessagingManager.RegisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_SyncData", new HandleNamedMessageDelegate(ReceiveAllData));
		customMessagingManager.RegisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_HudAlert", new HandleNamedMessageDelegate(ReceiveHudAlert));
		customMessagingManager.RegisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_RequestSync", (HandleNamedMessageDelegate)delegate(ulong sender, FastBufferReader reader)
		{
			if (NetworkManager.Singleton.IsServer)
			{
				SendDataToClient(sender);
			}
		});
		object obj = <>c.<>9__13_1;
		if (obj == null)
		{
			HandleNamedMessageDelegate val = delegate(ulong sender, FastBufferReader reader)
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				if (((FastBufferReader)(ref reader)).TryBeginRead(1))
				{
					bool isDiverting = default(bool);
					((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isDiverting, default(ForPrimitives));
					Plugin.IsDiverting = isDiverting;
				}
			};
			<>c.<>9__13_1 = val;
			obj = (object)val;
		}
		customMessagingManager.RegisterNamedMessageHandler("com.mrkixcat.gamemecanicoverhaul_SyncDiverting", (HandleNamedMessageDelegate)obj);
	}

	public void BroadcastEndGameStats()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkManager.Singleton.IsServer)
		{
			return;
		}
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(2048, (Allocator)2, -1);
		try
		{
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref Plugin.totalScrapSurLune, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref Plugin.collectedScrapSurLune, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref Plugin.TeamsPenalty, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref Plugin.collectedNB, default(ForPrimitives));
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref Plugin.allNB, default(ForPrimitives));
			int count = Plugin.PlayersRegistry.Count;
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref count, default(ForPrimitives));
			foreach (KeyValuePair<ulong, PlayerStatus> item in Plugin.PlayersRegistry)
			{
				ulong key = item.Key;
				((FastBufferWriter)(ref val)).WriteValueSafe<ulong>(ref key, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe(item.Value.PlayerName, false);
				((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref item.Value.IsAlive, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref item.Value.Health, default(ForPrimitives));
				((FastBufferWriter)(ref val)).WriteValueSafe(item.Value.CauseOfDeath, false);
			}
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("com.mrkixcat.gamemecanicoverhaul_SyncEndGame", val, (NetworkDelivery)3);
			_logger.LogInfo((object)"[SERVER] End Game stats sent.");
		}
		finally
		{
			((IDisposable)(FastBufferWriter)(ref val)).Dispose();
		}
	}

	private void ReceiveEndGameStats(ulong senderId, FastBufferReader reader)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkManager.Singleton.IsServer)
		{
			return;
		}
		try
		{
			int totalScrapSurLune = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref totalScrapSurLune, default(ForPrimitives));
			int collectedScrapSurLune = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref collectedScrapSurLune, default(ForPrimitives));
			int teamsPenalty = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref teamsPenalty, default(ForPrimitives));
			int collectedNB = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref collectedNB, default(ForPrimitives));
			int allNB = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref allNB, default(ForPrimitives));
			Plugin.totalScrapSurLune = totalScrapSurLune;
			Plugin.collectedScrapSurLune = collectedScrapSurLune;
			Plugin.TeamsPenalty = teamsPenalty;
			Plugin.collectedNB = collectedNB;
			Plugin.allNB = allNB;
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			Plugin.PlayersRegistry.Clear();
			ulong key = default(ulong);
			string playerName = default(string);
			bool isAlive = default(bool);
			int health = default(int);
			string causeOfDeath = default(string);
			for (int i = 0; i < num; i++)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe<ulong>(ref key, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe(ref playerName, false);
				((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref isAlive, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref health, default(ForPrimitives));
				((FastBufferReader)(ref reader)).ReadValueSafe(ref causeOfDeath, false);
				Plugin.PlayersRegistry[key] = new PlayerStatus
				{
					PlayerName = playerName,
					IsAlive = isAlive,
					Health = health,
					CauseOfDeath = causeOfDeath
				};
			}
			_logger.LogInfo((object)"[CLIENT] End Game stats received and synced.");
		}
		catch (Exception ex)
		{
			_logger.LogError((object)("[CLIENT] Sync Error (Buffer mismatch): " + ex.Message));
		}
	}

	public void UpdateDivertingStatus(bool newValue)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkManager.Singleton.IsServer)
		{
			return;
		}
		Plugin.IsDiverting = newValue;
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(1, (Allocator)2, -1);
		try
		{
			((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref newValue, default(ForPrimitives));
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("com.mrkixcat.gamemecanicoverhaul_SyncDiverting", val, (NetworkDelivery)3);
		}
		finally
		{
			((IDisposable)(FastBufferWriter)(ref val)).Dispose();
		}
	}

	public void SendDataToAll()
	{
		if (NetworkManager.Singleton.IsServer)
		{
			SendDataToClient(ulong.MaxValue, toAll: true);
		}
	}

	public void SendDataToClient(ulong clientId, bool toAll = false)
	{
		//IL_003c: 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_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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_0121: 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)
		int num = 8 + Plugin.ChosenMoonIDs.Count * 4 + Plugin.VisitedMoonIDs.Count * 4;
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(num + 32, (Allocator)2, -1);
		try
		{
			int count = Plugin.ChosenMoonIDs.Count;
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref count, default(ForPrimitives));
			foreach (int chosenMoonID in Plugin.ChosenMoonIDs)
			{
				int current = chosenMoonID;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref current, default(ForPrimitives));
			}
			count = Plugin.VisitedMoonIDs.Count;
			((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref count, default(ForPrimitives));
			foreach (int visitedMoonID in Plugin.VisitedMoonIDs)
			{
				int current2 = visitedMoonID;
				((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref current2, default(ForPrimitives));
			}
			if (toAll)
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("com.mrkixcat.gamemecanicoverhaul_SyncData", val, (NetworkDelivery)3);
			}
			else
			{
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("com.mrkixcat.gamemecanicoverhaul_SyncData", clientId, val, (NetworkDelivery)3);
			}
		}
		finally
		{
			((IDisposable)(FastBufferWriter)(ref val)).Dispose();
		}
	}

	public void BroadcastHudAlert(string moonName)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkManager.Singleton.IsServer)
		{
			FastBufferWriter val = default(FastBufferWriter);
			((FastBufferWriter)(ref val))..ctor(128, (Allocator)2, -1);
			try
			{
				((FastBufferWriter)(ref val)).WriteValueSafe(moonName, false);
				NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll("com.mrkixcat.gamemecanicoverhaul_HudAlert", val, (NetworkDelivery)3);
			}
			finally
			{
				((IDisposable)(FastBufferWriter)(ref val)).Dispose();
			}
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				HUDManager.Instance.DisplayTip("DESTINATION CHANGED", "The Company deploys you on " + moonName + " !", true, false, "LC_Tip1");
			}
		}
	}

	private void ReceiveAllData(ulong senderId, FastBufferReader reader)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkManager.Singleton.IsServer)
		{
			return;
		}
		try
		{
			int num = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives));
			List<int> list = new List<int>();
			int item = default(int);
			for (int i = 0; i < num; i++)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref item, default(ForPrimitives));
				list.Add(item);
			}
			Plugin.ChosenMoonIDs = list;
			int num2 = default(int);
			((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num2, default(ForPrimitives));
			List<int> list2 = new List<int>();
			int item2 = default(int);
			for (int j = 0; j < num2; j++)
			{
				((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref item2, default(ForPrimitives));
				list2.Add(item2);
			}
			Plugin.VisitedMoonIDs = list2;
			_logger.LogInfo((object)$"[CLIENT] Synced: {num} chosen, {num2} visited moons.");
		}
		catch (Exception ex)
		{
			_logger.LogError((object)("Sync Error: " + ex.Message));
		}
	}

	private void ReceiveHudAlert(ulong senderId, FastBufferReader reader)
	{
		if (((FastBufferReader)(ref reader)).TryBeginRead(4))
		{
			string text = default(string);
			((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false);
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				HUDManager.Instance.DisplayTip("DESTINATION CHANGED", "The Company deploys you on " + text + " !", true, false, "LC_Tip1");
			}
		}
	}

	public void RequestSync()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkManager.Singleton.IsServer)
		{
			return;
		}
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1);
		try
		{
			NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage("com.mrkixcat.gamemecanicoverhaul_RequestSync", 0uL, val, (NetworkDelivery)3);
		}
		finally
		{
			((IDisposable)(FastBufferWriter)(ref val)).Dispose();
		}
	}
}
[HarmonyPatch(typeof(StartOfRound), "StartGame")]
public class LaunchPatch
{
	[HarmonyPrefix]
	private static bool Prefix(StartOfRound __instance)
	{
		if (!NetworkManager.Singleton.IsServer)
		{
			return true;
		}
		if (TimeOfDay.Instance.daysUntilDeadline <= 0)
		{
			if (__instance.currentLevelID != 3)
			{
				Networking.Instance.UpdateDivertingStatus(newValue: true);
				int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits;
				__instance.ChangeLevelServerRpc(3, groupCredits);
				Networking.Instance.BroadcastHudAlert("Company Building");
				return false;
			}
			return true;
		}
		if (__instance.currentLevelID == 3)
		{
			return true;
		}
		if (Plugin.ChosenMoonIDs.Contains(__instance.currentLevelID) && !Plugin.VisitedMoonIDs.Contains(__instance.currentLevelID))
		{
			return true;
		}
		List<int> list = Plugin.ChosenMoonIDs.Where((int id) => !Plugin.VisitedMoonIDs.Contains(id)).ToList();
		if (list.Count > 0)
		{
			int randomID = list[Random.Range(0, list.Count)];
			SelectableLevel val = ((IEnumerable<SelectableLevel>)__instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => l.levelID == randomID));
			Networking.Instance.UpdateDivertingStatus(newValue: true);
			int groupCredits2 = Object.FindObjectOfType<Terminal>().groupCredits;
			__instance.ChangeLevelServerRpc(randomID, groupCredits2);
			Networking.Instance.BroadcastHudAlert(val?.PlanetName);
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(Terminal), "Start")]
public class TerminalPricePatch
{
	[HarmonyPostfix]
	private static void Postfix(Terminal __instance)
	{
		if (!Plugin.FreeMoonEnabled.Value || (Object)(object)__instance.terminalNodes == (Object)null || __instance.terminalNodes.allKeywords == null)
		{
			return;
		}
		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;
				}
			}
		}
	}
}
public class PlayerStatus
{
	public string PlayerName;

	public bool IsAlive;

	public int Health;

	public string CauseOfDeath;
}
[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
public class DayEndPatch
{
	[HarmonyPostfix]
	private static void Postfix(StartOfRound __instance)
	{
		if (!((NetworkBehaviour)__instance).IsHost || __instance.currentLevelID == 3)
		{
			return;
		}
		GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
		int num = 0;
		int num2 = 0;
		int num3 = 0;
		GrabbableObject[] array2 = array;
		foreach (GrabbableObject val in array2)
		{
			if (ScrapTracker.IsRealNewScrap(val))
			{
				num3++;
				if (ScrapTracker.IsInShip(val))
				{
					num2++;
					num += val.scrapValue;
				}
			}
		}
		Plugin.allNB = num3;
		Plugin.totalScrapSurLune = Mathf.CeilToInt(RoundManager.Instance.totalScrapValueInLevel);
		Plugin.PlayersRegistry.Clear();
		bool flag = false;
		PlayerControllerB[] allPlayerScripts = __instance.allPlayerScripts;
		foreach (PlayerControllerB val2 in allPlayerScripts)
		{
			if (val2.isPlayerControlled || val2.isPlayerDead)
			{
				bool flag2 = !val2.isPlayerDead;
				if (flag2)
				{
					flag = true;
				}
				PlayerStatus value = new PlayerStatus
				{
					PlayerName = val2.playerUsername,
					IsAlive = flag2,
					Health = val2.health,
					CauseOfDeath = (val2.isPlayerDead ? ((object)(CauseOfDeath)(ref val2.causeOfDeath)).ToString() : "None")
				};
				Plugin.PlayersRegistry[val2.playerClientId] = value;
			}
		}
		Plugin.collectedScrapSurLune = (flag ? num : 0);
		Plugin.collectedNB = (flag ? num2 : 0);
		int num4 = 0;
		PlayerControllerB[] allPlayerScripts2 = __instance.allPlayerScripts;
		foreach (PlayerControllerB val3 in allPlayerScripts2)
		{
			if ((val3.isPlayerControlled || val3.isPlayerDead) && val3.isPlayerDead && ((Object)(object)val3.deadBody == (Object)null || !val3.deadBody.isInShip))
			{
				num4++;
			}
		}
		Terminal val4 = Object.FindObjectOfType<Terminal>();
		int num5 = (((Object)(object)val4 != (Object)null) ? val4.groupCredits : 0);
		int num6 = num5;
		for (int l = 0; l < num4; l++)
		{
			int num7 = Mathf.CeilToInt((float)num6 * 0.2f);
			num6 -= num7;
		}
		Plugin.TeamsPenalty = num5 - num6;
		Debug.Log((object)$"[GMO] ShipLeave Postfix. Scrap ramené: {Plugin.collectedScrapSurLune}. Corps manquants: {num4}. Pénalité: {Plugin.TeamsPenalty}");
		if (NetworkManager.Singleton.IsServer)
		{
			Networking.Instance.BroadcastEndGameStats();
		}
		Plugin.SaveData();
	}
}
[HarmonyPatch(typeof(StartOfRound))]
public class NetworkLifecycle
{
	[HarmonyPatch("Awake")]
	[HarmonyPostfix]
	public static void InitNetworking()
	{
		Networking.Init(Plugin.Instance.Log);
		Networking.Instance.RegisterHandlers();
	}

	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	public static void SyncOnStart()
	{
		if (NetworkManager.Singleton.IsClient && !NetworkManager.Singleton.IsServer)
		{
			Networking.Instance.RequestSync();
		}
	}
}
[HarmonyPatch(typeof(StartOfRound), "OnLocalDisconnect")]
public class MenuCleanupPatch
{
	[HarmonyPostfix]
	private static void Postfix()
	{
		Plugin.ChosenMoonIDs.Clear();
		Plugin.VisitedMoonIDs.Clear();
	}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class MasterPatch_ScrapReporter
{
	[HarmonyPostfix]
	[HarmonyPatch("openingDoorsSequence")]
	private static void Postfix_LevelGenerated()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.IsHost && Plugin.ScrapReporterEnabled.Value)
		{
			ScrapReporterModule.ResetReportFlag();
			GameObject val = new GameObject("ScrapReporter_Temp");
			ScrapReporterModule scrapReporterModule = val.AddComponent<ScrapReporterModule>();
			scrapReporterModule.Init();
			scrapReporterModule.StartScrapReport();
		}
	}
}
public class ScrapReporterModule : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <DelayedReport>d__4 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public ScrapReporterModule <>4__this;

		private (int interior, int exterior) <counts>5__1;

		private string <msg>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(<>4__this.delaySeconds);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (!HasReported)
				{
					HasReported = true;
					<counts>5__1 = ScanScrapInScene();
					<msg>5__2 = $"Indoor Scrap : {<counts>5__1.interior} | Outdoor Scrap : {<counts>5__1.exterior}";
					SendChatMessage(<msg>5__2);
					Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
					<msg>5__2 = null;
				}
				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();
		}
	}

	private float delaySeconds = 4f;

	private static bool HasReported;

	public void Init(float delay = 4f)
	{
		delaySeconds = delay;
	}

	public void StartScrapReport()
	{
		((MonoBehaviour)this).StartCoroutine(DelayedReport());
	}

	[IteratorStateMachine(typeof(<DelayedReport>d__4))]
	public IEnumerator DelayedReport()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedReport>d__4(0)
		{
			<>4__this = this
		};
	}

	public static (int interior, int exterior) ScanScrapInScene()
	{
		int num = 0;
		int num2 = 0;
		GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
		GrabbableObject[] array2 = array;
		foreach (GrabbableObject val in array2)
		{
			if (!((Object)(object)val == (Object)null) && val.itemProperties.isScrap && !val.isInShipRoom)
			{
				if (val.isInFactory && !val.itemProperties.itemName.Equals("Hive") && !val.itemProperties.itemName.Equals("Egg"))
				{
					num++;
				}
				else
				{
					num2++;
				}
			}
		}
		return (num, num2);
	}

	public static void SendChatMessage(string message)
	{
		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"))
		{
			instance.AddTextToChatOnServer(message, -1);
		}
	}

	public static void ResetReportFlag()
	{
		HasReported = false;
	}
}
[HarmonyPatch(typeof(StartMatchLever))]
public class LeverReworkPatch
{
	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void PostfixUpdate(StartMatchLever __instance)
	{
		if ((Object)(object)__instance.triggerScript != (Object)null)
		{
			__instance.triggerScript.timeToHold = 1f;
			if (Plugin.IsDiverting)
			{
				__instance.triggerScript.interactable = false;
				__instance.triggerScript.hoverTip = "";
				__instance.triggerScript.disabledHoverTip = "";
			}
			else if (StartOfRound.Instance.shipHasLanded)
			{
				__instance.triggerScript.interactable = true;
				__instance.triggerScript.hoverTip = "Leave " + StartOfRound.Instance.currentLevel.PlanetName + " : [E]";
			}
			else if (StartOfRound.Instance.inShipPhase)
			{
				__instance.triggerScript.interactable = true;
				__instance.triggerScript.hoverTip = "Land to " + StartOfRound.Instance.currentLevel.PlanetName + " : [E]";
			}
			else
			{
				__instance.triggerScript.hoverTip = "";
				__instance.triggerScript.disabledHoverTip = "";
				__instance.triggerScript.interactable = false;
			}
		}
	}
}
[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
public class TerminalDisplayPatch
{
	[HarmonyPostfix]
	private static void Postfix(ref string __result)
	{
		if (__result.Contains("Welcome to the exomoons catalogue"))
		{
			string text = "\n<color=red>[ COMPANY TARGETS ]</color>\n";
			text = text + "<color=yellow>> " + Plugin.GetTargetMoonsNames() + "</color>\n";
			text += "-------------------\n\n";
			__result = text + __result;
		}
	}
}
[HarmonyPatch(typeof(StartOfRound), "LoadShipGrabbableItems")]
public class SaveLoadPatch
{
	[HarmonyPostfix]
	private static void Postfix()
	{
		if (NetworkManager.Singleton.IsServer)
		{
			Plugin.LoadData();
		}
	}
}
[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 (int id in Plugin.ChosenMoonIDs)
		{
			SelectableLevel val = ((IEnumerable<SelectableLevel>)StartOfRound.Instance.levels).FirstOrDefault((Func<SelectableLevel, bool>)((SelectableLevel l) => l.levelID == id));
			if ((Object)(object)val != (Object)null)
			{
				float num3 = (float)(val.minScrap + val.maxScrap) / 2f;
				float num4 = 0.2f;
				num4 = ((val.PlanetName == "7 Dine") ? 0.6f : ((num3 >= 35f) ? 1.6f : ((num3 >= 30f) ? 1.4f : ((num3 >= 25f) ? 1.2f : ((num3 >= 20f) ? 1f : ((num3 >= 15f) ? 0.8f : ((num3 >= 10f) ? 0.6f : ((!(num3 >= 5f)) ? 0.2f : 0.4f))))))));
				float num5 = val.maxTotalScrapValue + val.minTotalScrapValue;
				float num6 = num5 * num4;
				num += num6;
				num2++;
			}
		}
		if (num2 > 0)
		{
			float num7 = num / (float)num2;
			float num8 = num7 * Plugin.CurrentRunMultiplier;
			__instance.profitQuota = Mathf.RoundToInt(num8);
		}
		__instance.quotaFulfilled = 0;
		__instance.timeUntilDeadline = __instance.totalTime * 3f;
		Plugin.SaveData();
		Networking.Instance.SendDataToAll();
		__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.ChosenMoonIDs.Clear();
		Plugin.VisitedMoonIDs.Clear();
		string[] excluded = (from s in Plugin.ExcludedMoons.Value.Split(new char[1] { ',' })
			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.ChosenMoonIDs.Add(list[index].levelID);
			list.RemoveAt(index);
		}
	}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.mrkixcat.gamemecanicoverhaul", "Game Mecanic Overhaul", "0.0.1")]
public class Plugin : BaseUnityPlugin
{
	public static Plugin Instance;

	internal ManualLogSource Log;

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

	public static ConfigEntry<string> ExcludedMoons;

	public static ConfigEntry<float> BaseMultiplier;

	public static ConfigEntry<float> MultiplierIncrement;

	public static ConfigEntry<bool> ScrapReporterEnabled;

	public static ConfigEntry<bool> EndOfRoundStatsRevampEnabled;

	public static ConfigEntry<bool> FreeMoonEnabled;

	public static float CurrentRunMultiplier = 1f;

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

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

	public static bool IsDiverting = false;

	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 IsCustomMenuOpen = false;

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

	private void Awake()
	{
		Instance = this;
		Log = Logger.CreateLogSource("Game Mecanic Overhaul");
		ExcludedMoons = ((BaseUnityPlugin)this).Config.Bind<string>("MoonRotation", "Excluded Moons", "Gordion,Liquidation", "These moons will not be chosen.");
		BaseMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Quota", "Base Multiplier", 1f, "Base multiplier of the first quota.");
		MultiplierIncrement = ((BaseUnityPlugin)this).Config.Bind<float>("Quota", "Multiplier Increment", 0.2f, "How much are increasing future quotas.");
		ScrapReporterEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("ScrapReporter", "Enable Scrap Reporter", true, "Each time you land on a moon, a number of indoor and outdoor scraps will be transmitted in the chat.");
		EndOfRoundStatsRevampEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("EndOfRoundStats", "Enable End Of Round Stats Revamp", true, "Enable the End Of Round Stats Revamp");
		FreeMoonEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("MoonRotation", "Enable Free Moon", true, "Enable the Free Moon module");
		CurrentRunMultiplier = BaseMultiplier.Value;
		try
		{
			harmony.PatchAll();
			Log.LogInfo((object)"Game Mecanic Overhaul loaded succesfully");
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Game Mecanic Overhaul can't load : " + ex.Message));
		}
	}

	public static void SaveData()
	{
		try
		{
			string path = Path.Combine(Application.persistentDataPath, GameNetworkManager.Instance.currentSaveFileName + "_gmo.txt");
			string contents = string.Format("{0};{1};{2}", CurrentRunMultiplier, string.Join(",", ChosenMoonIDs), string.Join(",", VisitedMoonIDs));
			File.WriteAllText(path, contents);
			Instance.Log.LogInfo((object)"[SAVED WITH SUCCESS]");
		}
		catch (Exception ex)
		{
			Instance.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 && TimeOfDay.Instance.timesFulfilledQuota <= 0)
				{
					GenerateInitialQuota();
				}
				return;
			}
			string text = File.ReadAllText(path);
			string[] array = text.Split(new char[1] { ';' });
			if (array.Length >= 1 && float.TryParse(array[0], out var result))
			{
				if (result > 50f)
				{
					CurrentRunMultiplier = BaseMultiplier.Value;
				}
				else
				{
					CurrentRunMultiplier = result;
				}
			}
			if (array.Length >= 2)
			{
				ChosenMoonIDs = array[1].Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
			}
			if (array.Length >= 3)
			{
				VisitedMoonIDs = array[2].Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
			}
			if (NetworkManager.Singleton.IsServer)
			{
				Networking.Instance.SendDataToAll();
			}
		}
		catch (Exception ex)
		{
			Instance.Log.LogError((object)("[LOAD ERROR] : " + ex.Message));
		}
	}

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

	public static string GetTargetMoonsNames()
	{
		if (ChosenMoonIDs == null || ChosenMoonIDs.Count == 0)
		{
			return "None";
		}
		IEnumerable<string> enumerable = from l in StartOfRound.Instance.levels
			where (Object)(object)l != (Object)null && ChosenMoonIDs.Contains(l.levelID)
			select l.PlanetName.Replace("\n", "");
		return enumerable.Any() ? string.Join(", ", enumerable) : "Unknow";
	}
}