Decompiled source of SkipDropshipCompany v0.1.7

com.aoirint.SkipDropshipCompany.dll

Decompiled 6 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using SkipDropshipCompany.Helpers;
using SkipDropshipCompany.Managers;
using SkipDropshipCompany.Utils;
using Unity.Mathematics;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.aoirint.SkipDropshipCompany")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.7.0")]
[assembly: AssemblyInformationalVersion("0.1.7+e9729bfee3618530e6ce75a144cef8e3d5655f14")]
[assembly: AssemblyProduct("SkipDropshipCompany")]
[assembly: AssemblyTitle("com.aoirint.SkipDropshipCompany")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.7.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
}
namespace SkipDropshipCompany
{
	[BepInPlugin("com.aoirint.SkipDropshipCompany", "SkipDropshipCompany", "0.1.7")]
	[BepInProcess("Lethal Company.exe")]
	public class SkipDropshipCompany : BaseUnityPlugin
	{
		internal static Harmony harmony = new Harmony("com.aoirint.SkipDropshipCompany");

		internal static InstantPurchaseManager instantPurchaseManager = new InstantPurchaseManager();

		internal static LandingHistoryManager landingHistoryManager = new LandingHistoryManager();

		internal static ConfigEntry<bool>? EnabledConfig;

		internal static ConfigEntry<bool>? RequireReroutingOnFirstDayConfig;

		internal static ManualLogSource? Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			EnabledConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Set to false to disable this mod.");
			RequireReroutingOnFirstDayConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RequireReroutingOnFirstDay", false, "If true, rerouting to the company will be required to skip the dropship on the first day.");
			harmony.PatchAll();
			Logger.LogInfo((object)"Plugin SkipDropshipCompany v0.1.7 is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.aoirint.SkipDropshipCompany";

		public const string PLUGIN_NAME = "SkipDropshipCompany";

		public const string PLUGIN_VERSION = "0.1.7";
	}
}
namespace SkipDropshipCompany.Generated
{
	internal static class ModInfo
	{
		public const string GUID = "com.aoirint.SkipDropshipCompany";

		public const string NAME = "SkipDropshipCompany";

		public const string VERSION = "0.1.7";
	}
}
namespace SkipDropshipCompany.Utils
{
	internal static class ItemSpawnUtils
	{
		private static readonly Dictionary<int, float> cachedSpawnOffsetXByItemId = new Dictionary<int, float>();

		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public static Vector3? GetBaseSpawnPosition()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return null;
			}
			Transform[] playerSpawnPositions = instance.playerSpawnPositions;
			if (playerSpawnPositions == null)
			{
				Logger.LogError((object)"StartOfRound.Instance.playerSpawnPositions is null.");
				return null;
			}
			Transform val = playerSpawnPositions.ElementAtOrDefault(1);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Player spawn position is null for ID 1.");
				return null;
			}
			return val.position;
		}

		public static float GetSpawnOffsetXByItemId(int itemId)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (cachedSpawnOffsetXByItemId.TryGetValue(itemId, out var value))
			{
				return value;
			}
			uint num = math.hash(new uint4((uint)itemId, 3735928559u, 305419896u, 2271560481u));
			if (num == 0)
			{
				num = 1u;
			}
			Random val = default(Random);
			((Random)(ref val))..ctor(num);
			float num2 = ((Random)(ref val)).NextFloat(-0.7f, 0.7f);
			cachedSpawnOffsetXByItemId[itemId] = num2;
			Logger.LogDebug((object)$"Generated offset X for an item ID. itemId={itemId}, offsetX={num2}");
			return num2;
		}

		public static bool SpawnItemInShip(Item item)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return false;
			}
			GameObject spawnPrefab = item.spawnPrefab;
			if ((Object)(object)spawnPrefab == (Object)null)
			{
				Logger.LogError((object)"Item.spawnPrefab is null.");
				return false;
			}
			Transform elevatorTransform = instance.elevatorTransform;
			if ((Object)(object)elevatorTransform == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance.elevatorTransform is null.");
				return false;
			}
			Vector3? baseSpawnPosition = GetBaseSpawnPosition();
			if (!baseSpawnPosition.HasValue)
			{
				Logger.LogError((object)"Failed to get spawn position.");
				return false;
			}
			Vector3 value = baseSpawnPosition.Value;
			float spawnOffsetXByItemId = GetSpawnOffsetXByItemId(item.itemId);
			Vector3 val = value + new Vector3(spawnOffsetXByItemId, 0.5f, 1f);
			GameObject val2 = Object.Instantiate<GameObject>(spawnPrefab, val, Quaternion.identity, elevatorTransform);
			GrabbableObject component = val2.GetComponent<GrabbableObject>();
			if ((Object)(object)component == (Object)null)
			{
				Logger.LogError((object)"Failed to get GrabbableObject component from spawned item.");
				Object.Destroy((Object)(object)val2);
				return false;
			}
			component.fallTime = 0f;
			component.isInElevator = true;
			component.isInShipRoom = true;
			component.hasHitGround = true;
			NetworkObject component2 = val2.GetComponent<NetworkObject>();
			if ((Object)(object)component2 == (Object)null)
			{
				Logger.LogError((object)"Failed to get NetworkObject component from spawned item.");
				Object.Destroy((Object)(object)val2);
				return false;
			}
			component2.Spawn(false);
			return true;
		}
	}
	internal static class NetworkUtils
	{
		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public static bool IsServer()
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if ((Object)(object)singleton == (Object)null)
			{
				Logger.LogError((object)"NetworkManager.Singleton is null.");
				return false;
			}
			return singleton.IsServer;
		}
	}
	internal static class RoundUtils
	{
		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public static bool IsInOrbit()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return false;
			}
			if (!instance.inShipPhase)
			{
				return false;
			}
			return true;
		}

		public static bool IsFirstDay()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return false;
			}
			EndOfGameStats gameStats = instance.gameStats;
			if (gameStats == null)
			{
				Logger.LogError((object)"StartOfRound.Instance.gameStats is null.");
				return false;
			}
			int daysSpent = gameStats.daysSpent;
			Logger.LogDebug((object)$"daysSpent={daysSpent}");
			return daysSpent == 0;
		}

		public static bool IsSceneNameCompany(string sceneName)
		{
			Logger.LogDebug((object)("IsSceneNameCompany? sceneName=" + sceneName));
			return sceneName == "CompanyBuilding";
		}

		public static bool IsRoutingToCompany()
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return false;
			}
			SelectableLevel currentLevel = instance.currentLevel;
			if ((Object)(object)currentLevel == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance.currentLevel is null.");
				return false;
			}
			return IsSceneNameCompany(currentLevel.sceneName);
		}

		public static SelectableLevel? GetLevelById(int levelId)
		{
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.Instance is null.");
				return null;
			}
			SelectableLevel[] levels = instance.levels;
			if (levels == null)
			{
				Logger.LogError((object)"StartOfRound.Instance.levels is null.");
				return null;
			}
			SelectableLevel val = levels.ElementAtOrDefault(levelId);
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)$"Level not found. levelId={levelId}");
				return null;
			}
			return val;
		}
	}
	internal static class TerminalUtils
	{
		private static Terminal? cachedTerminal;

		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public static Terminal? GetTerminal()
		{
			if ((Object)(object)cachedTerminal != (Object)null)
			{
				return cachedTerminal;
			}
			Terminal val = Object.FindObjectOfType<Terminal>();
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to find Terminal instance in the scene.");
				return null;
			}
			cachedTerminal = val;
			return val;
		}

		public static Item? GetBuyableItemByIndex(int index)
		{
			Terminal terminal = GetTerminal();
			if ((Object)(object)terminal == (Object)null)
			{
				Logger.LogError((object)"Terminal is null.");
				return null;
			}
			Item[] buyableItemsList = terminal.buyableItemsList;
			if (buyableItemsList == null)
			{
				Logger.LogError((object)"Terminal.buyableItemsList is null.");
				return null;
			}
			return buyableItemsList.ElementAtOrDefault(index);
		}
	}
}
namespace SkipDropshipCompany.Patches
{
	[HarmonyPatch(typeof(StartOfRound))]
	internal class StartOfRoundPatch
	{
		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		public static void StartGamePostfix(StartOfRound __instance)
		{
			if (!NetworkUtils.IsServer())
			{
				Logger.LogDebug((object)"Not the server. Skipping landing history addition.");
				return;
			}
			SelectableLevel currentLevel = __instance.currentLevel;
			if ((Object)(object)currentLevel == (Object)null)
			{
				Logger.LogError((object)"StartOfRound.currentLevel is null.");
			}
			else
			{
				LandingHistoryHelpers.AddLandingHistory(currentLevel.sceneName);
			}
		}

		[HarmonyPatch("ResetShip")]
		[HarmonyPostfix]
		public static void ResetShipPostfix(StartOfRound __instance)
		{
			if (!NetworkUtils.IsServer())
			{
				Logger.LogDebug((object)"Not the server. Skipping landing history clear.");
			}
			else
			{
				LandingHistoryHelpers.ClearLandingHistory();
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class TerminalPatch
	{
		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		[HarmonyPatch("SyncGroupCreditsClientRpc")]
		[HarmonyPrefix]
		public static void SyncGroupCreditsClientRpcPrefix(Terminal __instance, int newGroupCredits, ref int numItemsInShip)
		{
			if (!NetworkUtils.IsServer())
			{
				Logger.LogDebug((object)"Not the server. Skipping instant purchase logic.");
				return;
			}
			InstantPurchaseManager instantPurchaseManager = SkipDropshipCompany.instantPurchaseManager;
			if (instantPurchaseManager == null)
			{
				Logger.LogError((object)"InstantPurchaseManager is null.");
				return;
			}
			List<int> orderedItemsFromTerminal = __instance.orderedItemsFromTerminal;
			if (orderedItemsFromTerminal == null)
			{
				Logger.LogError((object)"Terminal.orderedItemsFromTerminal is null.");
				return;
			}
			Logger.LogDebug((object)"Preparing instant purchase.");
			PrepareInstantPurchaseResult prepareInstantPurchaseResult = instantPurchaseManager.PrepareInstantPurchase(orderedItemsFromTerminal);
			if (prepareInstantPurchaseResult == null)
			{
				Logger.LogDebug((object)"Prepare instant purchase failed or not allowed. Skipping instant purchase logic.");
				return;
			}
			numItemsInShip = prepareInstantPurchaseResult.DropShipBoughtItemIndexes.Count;
			Logger.LogDebug((object)("Prepared instant purchase." + $" originalDropShipItemCount={orderedItemsFromTerminal.Count}" + $" preparedDropShipItemCount={numItemsInShip}" + $" preparedInstantPurchaseItemCount={prepareInstantPurchaseResult.InstantBoughtItemIndexes.Count}"));
		}

		[HarmonyPatch("SyncGroupCreditsClientRpc")]
		[HarmonyPostfix]
		public static void SyncGroupCreditsClientRpcPostfix(Terminal __instance, int newGroupCredits, ref int numItemsInShip)
		{
			if (!NetworkUtils.IsServer())
			{
				Logger.LogDebug((object)"Not the server. Skipping instant purchase logic.");
				return;
			}
			InstantPurchaseManager instantPurchaseManager = SkipDropshipCompany.instantPurchaseManager;
			if (instantPurchaseManager == null)
			{
				Logger.LogError((object)"InstantPurchaseManager is null.");
				return;
			}
			Logger.LogDebug((object)"Spawning prepared instant purchased items.");
			SpawnPreparedInstantPurchasedItemsResult spawnPreparedInstantPurchasedItemsResult = instantPurchaseManager.SpawnPreparedInstantPurchasedItems();
			if (spawnPreparedInstantPurchasedItemsResult == null)
			{
				Logger.LogDebug((object)"Spawning prepared instant purchased items failed or none to spawn.");
				return;
			}
			__instance.orderedItemsFromTerminal = spawnPreparedInstantPurchasedItemsResult.DropShipBoughtItemIndexes;
			Logger.LogDebug((object)"Spawned all prepared instant purchased items.");
		}
	}
}
namespace SkipDropshipCompany.Managers
{
	internal sealed class PrepareInstantPurchaseResult
	{
		public List<int> DropShipBoughtItemIndexes { get; }

		public List<int> InstantBoughtItemIndexes { get; }

		public PrepareInstantPurchaseResult(List<int> dropShipBoughtItemIndexes, List<int> instantBoughtItemIndexes)
		{
			DropShipBoughtItemIndexes = dropShipBoughtItemIndexes;
			InstantBoughtItemIndexes = instantBoughtItemIndexes;
		}
	}
	internal sealed class SpawnPreparedInstantPurchasedItemsResult
	{
		public List<int> DropShipBoughtItemIndexes { get; }

		public List<int> InstantBoughtItemIndexes { get; }

		public SpawnPreparedInstantPurchasedItemsResult(List<int> dropShipBoughtItemIndexes, List<int> instantBoughtItemIndexes)
		{
			DropShipBoughtItemIndexes = dropShipBoughtItemIndexes;
			InstantBoughtItemIndexes = instantBoughtItemIndexes;
		}
	}
	internal class InstantPurchaseManager
	{
		private PrepareInstantPurchaseResult? preparedInstantPurchaseResult;

		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		private static bool IsInstantPurchaseAllowed()
		{
			Logger.LogDebug((object)"Checking if instant purchase is allowed.");
			ConfigEntry<bool>? enabledConfig = SkipDropshipCompany.EnabledConfig;
			if (enabledConfig != null && !enabledConfig.Value)
			{
				Logger.LogDebug((object)"Not enabled.");
				return false;
			}
			bool flag = SkipDropshipCompany.RequireReroutingOnFirstDayConfig?.Value ?? false;
			Logger.LogDebug((object)$"Configs: isFirstDayRerouteRequired={flag}");
			bool flag2 = RoundHelpers.IsLandedOnCompany();
			bool flag3 = RoundHelpers.IsInFirstDayOrbit();
			bool flag4 = RoundHelpers.IsInFirstDayOrbitAndRoutingToCompany();
			bool flag5 = RoundHelpers.IsInOrbitAndLastLandedOnCompanyAndRoutingToCompany();
			Logger.LogDebug((object)("Flags:" + $" IsLandedOnCompany={flag2}" + $" IsInFirstDayOrbit={flag3}" + $" IsInFirstDayOrbitAndRoutingToCompany={flag4}" + $" isInOrbitAndLastLandedOnCompanyAndRoutingToCompany={flag5}"));
			return flag2 || (!flag && flag3) || flag4 || flag5;
		}

		public PrepareInstantPurchaseResult? PrepareInstantPurchase(List<int> boughtItemIndexes)
		{
			if (!IsInstantPurchaseAllowed())
			{
				Logger.LogDebug((object)"Instant purchase is not allowed in the current game state.");
				return null;
			}
			return PrepareInstantPurchaseUnchecked(boughtItemIndexes);
		}

		public PrepareInstantPurchaseResult? PrepareInstantPurchaseUnchecked(List<int> boughtItemIndexes)
		{
			return preparedInstantPurchaseResult = new PrepareInstantPurchaseResult(new List<int>(), boughtItemIndexes);
		}

		public PrepareInstantPurchaseResult? GetPreparedInstantPurchaseResult()
		{
			return preparedInstantPurchaseResult;
		}

		public SpawnPreparedInstantPurchasedItemsResult? SpawnPreparedInstantPurchasedItems()
		{
			if (preparedInstantPurchaseResult == null)
			{
				Logger.LogDebug((object)"No prepared instant purchase to spawn.");
				return null;
			}
			foreach (int instantBoughtItemIndex in preparedInstantPurchaseResult.InstantBoughtItemIndexes)
			{
				Item buyableItemByIndex = TerminalUtils.GetBuyableItemByIndex(instantBoughtItemIndex);
				if ((Object)(object)buyableItemByIndex == (Object)null)
				{
					Logger.LogError((object)$"Failed to get bought item. buyableItemIndex={instantBoughtItemIndex}");
					return null;
				}
				if (!ItemSpawnUtils.SpawnItemInShip(buyableItemByIndex))
				{
					Logger.LogError((object)("Failed to spawn instant purchased item. item.name=" + ((Object)buyableItemByIndex).name));
					return null;
				}
			}
			SpawnPreparedInstantPurchasedItemsResult result = new SpawnPreparedInstantPurchasedItemsResult(preparedInstantPurchaseResult.DropShipBoughtItemIndexes, preparedInstantPurchaseResult.InstantBoughtItemIndexes);
			preparedInstantPurchaseResult = null;
			return result;
		}
	}
	internal class LandingHistoryManager
	{
		private const int LANDING_HISTORY_SIZE = 1;

		private List<string> landingEntries = new List<string>();

		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public bool AddLandingHistory(string sceneName)
		{
			if (string.IsNullOrEmpty(sceneName))
			{
				Logger.LogError((object)"Scene name is null or empty. Cannot add to landing history.");
				return false;
			}
			landingEntries.Add(sceneName);
			landingEntries = landingEntries.TakeLast(1).ToList();
			Logger.LogDebug((object)("Updated landing history. landingEntries=" + string.Join(", ", landingEntries)));
			return true;
		}

		public List<string> GetLandingHistory()
		{
			return landingEntries.ToList();
		}

		public bool ClearLandingHistory()
		{
			landingEntries.Clear();
			return true;
		}
	}
}
namespace SkipDropshipCompany.Helpers
{
	internal static class LandingHistoryHelpers
	{
		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public static bool AddLandingHistory(string sceneName)
		{
			LandingHistoryManager landingHistoryManager = SkipDropshipCompany.landingHistoryManager;
			if (landingHistoryManager == null)
			{
				Logger.LogError((object)"LandingHistoryManager is null.");
				return false;
			}
			Logger.LogDebug((object)("Adding landing history. sceneName=" + sceneName));
			if (!landingHistoryManager.AddLandingHistory(sceneName))
			{
				Logger.LogError((object)("Failed to add landing history. sceneName=" + sceneName));
				return false;
			}
			Logger.LogDebug((object)("Added landing history. sceneName=" + sceneName));
			return true;
		}

		public static bool ClearLandingHistory()
		{
			LandingHistoryManager landingHistoryManager = SkipDropshipCompany.landingHistoryManager;
			if (landingHistoryManager == null)
			{
				Logger.LogError((object)"LandingHistoryManager is null.");
				return false;
			}
			Logger.LogDebug((object)"Clearing landing history.");
			if (!landingHistoryManager.ClearLandingHistory())
			{
				Logger.LogError((object)"Failed to clear landing history.");
				return false;
			}
			Logger.LogDebug((object)"Cleared landing history.");
			return true;
		}

		public static bool IsLastLandedOnCompany()
		{
			LandingHistoryManager landingHistoryManager = SkipDropshipCompany.landingHistoryManager;
			if (landingHistoryManager == null)
			{
				Logger.LogError((object)"LandingHistoryManager is null.");
				return false;
			}
			List<string> landingHistory = landingHistoryManager.GetLandingHistory();
			if (landingHistory == null)
			{
				Logger.LogError((object)"Landing history is null.");
				return false;
			}
			string text = landingHistory.LastOrDefault();
			if (text == null)
			{
				Logger.LogDebug((object)"Last landed scene name is null.");
				return false;
			}
			if (!RoundUtils.IsSceneNameCompany(text))
			{
				Logger.LogDebug((object)"Last landed scene is not company.");
				return false;
			}
			return true;
		}
	}
	internal static class RoundHelpers
	{
		internal static ManualLogSource Logger => SkipDropshipCompany.Logger;

		public static bool IsInFirstDayOrbit()
		{
			if (!RoundUtils.IsInOrbit())
			{
				Logger.LogDebug((object)"Not in orbit.");
				return false;
			}
			if (!RoundUtils.IsFirstDay())
			{
				Logger.LogDebug((object)"Not first day.");
				return false;
			}
			return true;
		}

		public static bool IsInFirstDayOrbitAndRoutingToCompany()
		{
			if (!IsInFirstDayOrbit())
			{
				Logger.LogDebug((object)"Not in first day orbit.");
				return false;
			}
			if (!RoundUtils.IsRoutingToCompany())
			{
				Logger.LogDebug((object)"Not routing to company.");
				return false;
			}
			return true;
		}

		public static bool IsLandedOnCompany()
		{
			if (RoundUtils.IsInOrbit())
			{
				Logger.LogDebug((object)"In orbit.");
				return false;
			}
			if (!RoundUtils.IsRoutingToCompany())
			{
				Logger.LogDebug((object)"Not routing to company.");
				return false;
			}
			return true;
		}

		public static bool IsInOrbitAndLastLandedOnCompanyAndRoutingToCompany()
		{
			if (!RoundUtils.IsInOrbit())
			{
				Logger.LogDebug((object)"Not in orbit.");
				return false;
			}
			if (!LandingHistoryHelpers.IsLastLandedOnCompany())
			{
				Logger.LogDebug((object)"Last landed level is not company.");
				return false;
			}
			if (!RoundUtils.IsRoutingToCompany())
			{
				Logger.LogDebug((object)"Not routing to company.");
				return false;
			}
			return true;
		}
	}
}