Decompiled source of VersionNine v0.9.9

VersionNine.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LobbyCompatibility.Attributes;
using Newtonsoft.Json;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using VersionNine.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("VersionNine")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VersionNine")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d2d1a9ed-39c9-4b7b-845b-db7f6f9c0431")]
[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 VersionNine
{
	[BepInPlugin("Swaggies.VersionNine", "VersionNine", "0.9.9")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class VersionNine : BaseUnityPlugin
	{
		private const string _GUID = "Swaggies.VersionNine";

		private const string _NAME = "VersionNine";

		private const string _VER = "0.9.9";

		private readonly Harmony harmony = new Harmony("Swaggies.VersionNine");

		private static VersionNine Instance;

		public static ManualLogSource loggins;

		public static ConfigEntry<bool> TerminalColors;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			loggins = Logger.CreateLogSource("Swaggies.VersionNine");
			harmony.PatchAll(typeof(VersionNine));
			harmony.PatchAll(typeof(CompanyBuyingRate));
			harmony.PatchAll(typeof(QuotaPatches));
			harmony.PatchAll(typeof(ScrapPatches));
			harmony.PatchAll(typeof(LevelCostAdjustments));
			harmony.PatchAll(typeof(PlayerPatches));
			harmony.PatchAll(typeof(RandomizedTime));
			harmony.PatchAll(typeof(Saving));
			harmony.PatchAll(typeof(BodiesInsured));
			harmony.PatchAll(typeof(DoorLockPatch));
			harmony.PatchAll(typeof(LungPropPatches));
			harmony.PatchAll(typeof(MonitorPatches));
			harmony.PatchAll(typeof(LeverPatch));
			harmony.PatchAll(typeof(TimeSync));
			harmony.PatchAll(typeof(RoundManagerPatches));
			harmony.PatchAll(typeof(WeatherPatches));
			harmony.PatchAll(typeof(MenuManagerPatches));
			loggins.LogInfo((object)"VersionNine up and running.");
			TerminalColors = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Terminal Colors", false, "Adds colors to the local planet time, planet costs, and planet weathers on the exomoons catalogue list and ship map monitor.");
		}
	}
}
namespace VersionNine.Patches
{
	internal class BodiesInsured
	{
		[HarmonyPatch(typeof(HUDManager), "ApplyPenalty")]
		[HarmonyPrefix]
		private static bool NewPenalty(ref HUDManager __instance, ref int playersDead, ref int bodiesInsured)
		{
			bool flag = StartOfRound.Instance.currentLevelID == 3;
			int num = (flag ? 3 : 10);
			int num2 = ((!flag) ? 3 : 0);
			int num3 = playersDead - bodiesInsured;
			int num4 = num3 * num;
			int num5 = bodiesInsured * num2;
			Terminal val = Object.FindObjectOfType<Terminal>();
			int num6 = (int)((float)(val.groupCredits * num4) / 100f);
			int num7 = (int)((float)(val.groupCredits * num5) / 100f);
			int num8 = Math.Max(0, num7 + num6);
			string text = "";
			if (num3 > 0)
			{
				text = text + "Missing bodies:\n" + $"{num3} x {num}% = ${num6}\n\n";
			}
			if (bodiesInsured > 0)
			{
				text = text + "Recovered bodies:\n" + $"{bodiesInsured} x {num2}% = ${num7}";
			}
			((TMP_Text)__instance.statsUIElements.penaltyAddition).text = text;
			((TMP_Text)__instance.statsUIElements.penaltyTotal).text = $"DUE: ${num8}";
			val.groupCredits = Math.Max(val.groupCredits - num8, 0);
			return false;
		}
	}
	internal class CompanyBuyingRate
	{
		public static float trajectory = -0.002f;

		private static readonly float speed = 0.05f;

		private static float lastBuyingRate = 0.3f;

		private static float previousBuyingRate = 0.3f;

		public static int buyingRateChangePercent = 0;

		public static void FluctuateCompanyBuyingRate()
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				float num = speed * (0.9f - StartOfRound.Instance.companyBuyingRate);
				float num2 = num + Random.Range(-0.03f, 0.03f);
				float num3 = Random.Range(0.4f, 1.6f);
				trajectory = Mathf.Clamp(trajectory + num2 * num3, -0.2f, 0.2f);
				StartOfRound.Instance.companyBuyingRate = Mathf.Clamp(StartOfRound.Instance.companyBuyingRate + trajectory, 0.3f, 1.5f);
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetBuyingRateForDay")]
		[HarmonyPrefix]
		private static bool SetBuyRate(ref TimeOfDay __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			CompareBuyingRate(StartOfRound.Instance.companyBuyingRate);
			StartOfRound.Instance.SyncCompanyBuyingRateServerRpc();
			return false;
		}

		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		[HarmonyPostfix]
		private static void ResetShip()
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				trajectory = -0.002f;
				StartOfRound.Instance.companyBuyingRate = 1f;
				CompareBuyingRate(StartOfRound.Instance.companyBuyingRate);
				StartOfRound.Instance.SyncCompanyBuyingRateServerRpc();
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SyncNewProfitQuotaClientRpc")]
		[HarmonyPrefix]
		private static void NewProfitQuotaPrefix()
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				previousBuyingRate = StartOfRound.Instance.companyBuyingRate;
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SyncNewProfitQuotaClientRpc")]
		[HarmonyPostfix]
		private static void NewProfitQuota()
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				trajectory = Random.Range(-0.15f, 0.05f);
				StartOfRound.Instance.companyBuyingRate = Mathf.Clamp(previousBuyingRate + Random.Range(-0.9f, 0.3f), 0.3f, 1.5f);
				CompareBuyingRate(StartOfRound.Instance.companyBuyingRate);
				StartOfRound.Instance.SyncCompanyBuyingRateServerRpc();
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SyncCompanyBuyingRateClientRpc")]
		[HarmonyPostfix]
		private static void OnNewCompanyBuyRate(ref float buyingRate)
		{
			CompareBuyingRate(buyingRate);
		}

		public static void CompareBuyingRate(float old)
		{
			if (old != lastBuyingRate)
			{
				buyingRateChangePercent = Mathf.RoundToInt((old - lastBuyingRate) * 100f);
				if (!GameNetworkManager.Instance.gameHasStarted)
				{
					buyingRateChangePercent = 0;
				}
				lastBuyingRate = old;
			}
		}
	}
	internal class DoorLockPatch
	{
		[HarmonyPatch(typeof(DoorLock), "LockDoor")]
		[HarmonyPostfix]
		private static void AllowLockpick(ref DoorLock __instance)
		{
			Traverse.Create((object)__instance).Field("doorTrigger").GetValue<InteractTrigger>()
				.interactable = true;
		}
	}
	internal class LevelCostAdjustments
	{
		public enum Planet
		{
			Gordion = 3,
			Experimentation = 0,
			Assurance = 1,
			Vow = 2,
			Offense = 8,
			March = 4,
			Adamance = 5,
			Rend = 6,
			Dine = 7,
			Titan = 9,
			Artifice = 10,
			Embrion = 12,
			Liquidation = 11
		}

		[HarmonyPatch(typeof(Terminal), "LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		private static bool LoadNewNode(ref TerminalNode node)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Invalid comparison between Unknown and I4
			if (node.buyRerouteToMoon == -1 || node.buyRerouteToMoon == -2)
			{
				return true;
			}
			Planet buyRerouteToMoon = (Planet)node.buyRerouteToMoon;
			int planetCost = GetPlanetCost(buyRerouteToMoon);
			node.itemCost = planetCost;
			SelectableLevel val = StartOfRound.Instance.levels[node.buyRerouteToMoon];
			if (val.planetHasTime)
			{
				float num = RandomizedTime.CalculatePlanetTimeNormalized(val);
				if ((int)TimeOfDay.Instance.GetDayPhase(num) == 3)
				{
					TerminalNode val2 = Object.FindObjectOfType<Terminal>().terminalNodes.specialNodes[8];
					string text = JsonConvert.SerializeObject((object)val2);
					TerminalNode val3 = JsonConvert.DeserializeObject<TerminalNode>(text);
					val3.displayText = "It is too late to land on this moon! To minimize risk of damages, the Company autopilot ship refuses to land after dark.\n\n";
					Object.FindObjectOfType<Terminal>().LoadNewNode(val3);
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
		[HarmonyPrefix]
		private static void PostProcess(ref string modifiedDisplayText, ref TerminalNode node)
		{
			if (node.buyRerouteToMoon != -1 && node.buyRerouteToMoon != -2)
			{
				TryPatchNode(node, node.buyRerouteToMoon);
			}
			else if (node.buyRerouteToMoon == -2)
			{
				TryPatchNode(node, node.displayPlanetInfo);
				modifiedDisplayText = modifiedDisplayText.Replace("[totalCost]", $"${node.itemCost}");
			}
		}

		private static void TryPatchNode(TerminalNode node, int id)
		{
			int planetCost = GetPlanetCost((Planet)id);
			node.itemCost = planetCost;
		}

		public static int GetPlanetCost(Planet planet)
		{
			return planet switch
			{
				Planet.Assurance => 15, 
				Planet.Vow => 5, 
				Planet.March => 10, 
				Planet.Adamance => 25, 
				Planet.Rend => 350, 
				Planet.Dine => 400, 
				Planet.Titan => 550, 
				Planet.Artifice => 1250, 
				Planet.Embrion => 80, 
				_ => 0, 
			};
		}
	}
	internal class LeverPatch
	{
		public static bool displayedTimeWarning;

		public static bool displayedDeadlineWarning;

		[HarmonyPatch(typeof(StartMatchLever), "BeginHoldingInteractOnLever")]
		[HarmonyPrefix]
		private static bool LeverHold(ref StartMatchLever __instance)
		{
			if (!StartOfRound.Instance.inShipPhase || !StartOfRound.Instance.currentLevel.planetHasTime)
			{
				return false;
			}
			if (!displayedDeadlineWarning && TimeOfDay.Instance.daysUntilDeadline <= 0)
			{
				displayedDeadlineWarning = true;
				if (TimeOfDay.Instance.hoursUntilDeadline <= 6)
				{
					HUDManager.Instance.DisplayTip("HALT!", "You have less than 6 hours until the deadline. Use the terminal to route to the company building and sell.", true, false, "LC_Tip1");
					__instance.triggerScript.timeToHold = 4f;
					return false;
				}
				if (TimeOfDay.Instance.hoursUntilDeadline <= 18)
				{
					HUDManager.Instance.DisplayTip("Warning!", "You have less than 18 hours until the deadline. You may use the terminal to route to the company building and sell.", false, false, "LC_Tip1");
					__instance.triggerScript.timeToHold = 1.5f;
					return false;
				}
			}
			float num = RandomizedTime.CalculatePlanetTimeNormalized(__instance.playersManager.currentLevel);
			if (!displayedTimeWarning && num >= 0.63f)
			{
				string planetTime = RandomizedTime.GetPlanetTime(__instance.playersManager.currentLevel);
				displayedTimeWarning = true;
				if (num > 0.805f)
				{
					HUDManager.Instance.DisplayTip("HALT!", "It is " + planetTime + " on the current moon. Landing is very dangerous. Use the terminal to route to another moon.", true, false, "LC_Tip1");
					__instance.triggerScript.timeToHold = 2.5f;
					return false;
				}
				HUDManager.Instance.DisplayTip("Warning!", "It is " + planetTime + " on the current moon. Landing is unsafe. You may use the terminal to route to another moon.", false, false, "LC_Tip1");
				return false;
			}
			return false;
		}

		[HarmonyPatch(typeof(StartOfRound), "ArriveAtLevel")]
		[HarmonyPostfix]
		private static void ArrivedAtLevel()
		{
			StartMatchLever val = Object.FindObjectOfType<StartMatchLever>();
			val.triggerScript.timeToHold = 0.7f;
			displayedTimeWarning = false;
			displayedDeadlineWarning = false;
		}

		[HarmonyPatch(typeof(StartOfRound), "openingDoorsSequence")]
		[HarmonyPostfix]
		private static void StartedGame()
		{
			StartMatchLever val = Object.FindObjectOfType<StartMatchLever>();
			val.triggerScript.timeToHold = 0.7f;
			displayedTimeWarning = false;
			displayedDeadlineWarning = false;
		}
	}
	internal class LungPropPatches
	{
		[HarmonyPatch(typeof(LungProp), "Start")]
		[HarmonyPostfix]
		private static void LungStart(ref LungProp __instance)
		{
			if (((GrabbableObject)__instance).scrapValue == 80)
			{
				int num = Mathf.RoundToInt(StartOfRound.Instance.currentLevel.factorySizeMultiplier * 200f);
				((GrabbableObject)__instance).scrapValue = num;
				RoundManagerPatches.additionToTotalValue += num;
			}
		}
	}
	internal class MenuManagerPatches
	{
		[HarmonyPatch(typeof(MenuManager), "Awake")]
		[HarmonyPostfix]
		private static void MenuAwake(ref MenuManager __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)GameNetworkManager.Instance == (Object)null) && !((Object)(object)__instance.versionNumberText == (Object)null))
			{
				((TMP_Text)__instance.versionNumberText).text = $"v9 ({GameNetworkManager.Instance.gameVersionNum})";
			}
		}
	}
	internal class MonitorPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "SetMapScreenInfoToCurrentLevel")]
		[HarmonyPrefix]
		private static bool MapMonitorDetails(ref StartOfRound __instance)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Invalid comparison between Unknown and I4
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			((Behaviour)__instance.screenLevelVideoReel).enabled = false;
			((Component)__instance.screenLevelVideoReel).gameObject.SetActive(false);
			__instance.screenLevelVideoReel.clip = __instance.currentLevel.videoReel;
			TimeOfDay instance = TimeOfDay.Instance;
			if (instance != null && instance.totalTime == 0f)
			{
				TimeOfDay.Instance.totalTime = (float)TimeOfDay.Instance.numberOfHours * TimeOfDay.Instance.lengthOfHours;
			}
			string text = (((int)__instance.currentLevel.currentWeather == -1) ? "" : ("Weather: " + PlanetInfo.GetColoredWeather(__instance.currentLevel.currentWeather) + "\n"));
			string text2 = "Local Time: " + PlanetInfo.GetColoredPlanetTime(RandomizedTime.CalculatePlanetTimeNormalized(__instance.currentLevel)) + "\n";
			string text3 = "";
			string text4 = (__instance.isChallengeFile ? GameNetworkManager.Instance.GetNameForWeekNumber(-1) : __instance.currentLevel.PlanetName);
			string levelDescription = __instance.currentLevel.LevelDescription;
			if (!__instance.currentLevel.planetHasTime)
			{
				text2 = "";
				text3 = "Buy rate: " + RandomizedTime.GetColoredBuyingRate() + "\n";
			}
			((TMP_Text)__instance.screenLevelDescription).text = "Orbiting: " + text4 + "\n" + text3 + text + text2 + levelDescription;
			__instance.mapScreen.overrideCameraForOtherUse = true;
			((Component)__instance.mapScreen.cam).transform.position = new Vector3(0f, 100f, 0f);
			((Behaviour)__instance.screenLevelDescription).enabled = true;
			if ((Object)(object)__instance.currentLevel.videoReel != (Object)null && !__instance.isChallengeFile)
			{
				((Behaviour)__instance.screenLevelVideoReel).enabled = true;
				((Component)__instance.screenLevelVideoReel).gameObject.SetActive(true);
				__instance.screenLevelVideoReel.Play();
			}
			return false;
		}
	}
	internal class PlanetInfo
	{
		public class Moon
		{
			public string name;

			public int planetId;

			public int orderId;

			public int tier;

			public float LocalNormalizedTime => CalculatePlanetTimeNormalizedFromId(planetId);

			public int Cost => LevelCostAdjustments.GetPlanetCost((LevelCostAdjustments.Planet)planetId);

			public LevelWeatherType LocalWeather => StartOfRound.Instance.levels.First((SelectableLevel m) => m.levelID == planetId).currentWeather;

			public Moon(LevelCostAdjustments.Planet planetId, int orderId, int tier)
			{
				name = planetId.ToString();
				this.orderId = orderId;
				this.tier = tier;
				this.planetId = (int)planetId;
			}
		}

		private static float CalculatePlanetTimeNormalizedFromId(int id)
		{
			return RandomizedTime.CalculatePlanetTimeNormalized(StartOfRound.Instance.levels.First((SelectableLevel m) => m.levelID == id));
		}

		public static Moon[] GetAllPlanets()
		{
			return new Moon[11]
			{
				new Moon(LevelCostAdjustments.Planet.Experimentation, 1, 1),
				new Moon(LevelCostAdjustments.Planet.Assurance, 2, 1),
				new Moon(LevelCostAdjustments.Planet.Vow, 3, 1),
				new Moon(LevelCostAdjustments.Planet.Offense, 4, 2),
				new Moon(LevelCostAdjustments.Planet.March, 5, 2),
				new Moon(LevelCostAdjustments.Planet.Adamance, 6, 2),
				new Moon(LevelCostAdjustments.Planet.Rend, 7, 3),
				new Moon(LevelCostAdjustments.Planet.Dine, 8, 3),
				new Moon(LevelCostAdjustments.Planet.Titan, 9, 3),
				new Moon(LevelCostAdjustments.Planet.Artifice, 10, 4),
				new Moon(LevelCostAdjustments.Planet.Embrion, 11, 4)
			};
		}

		public static string GetAllMoonInformationForTerminal()
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			Moon[] array = (from m in GetAllPlanets()
				orderby m.orderId
				select m).ToArray();
			string text = "";
			int num = 1;
			Moon[] array2 = array;
			foreach (Moon moon in array2)
			{
				if (moon.tier > num)
				{
					num = moon.tier;
					text += "\n";
				}
				text = text + "* " + MaximizeStringLength(moon.name, 16) + " ";
				text += ((moon.Cost <= 0 && VersionNine.TerminalColors.Value) ? ("<color=#696969>" + MaximizeStringLength("$0", 7) + "</color>") : MaximizeStringLength($"${moon.Cost}", 7));
				text = text + " " + GetColoredPlanetTime(moon.LocalNormalizedTime) + ", ";
				text += GetColoredWeather(moon.LocalWeather);
				text += "\n";
			}
			return text + "\n";
		}

		public static string GetColoredWeather(LevelWeatherType weather)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected I4, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			if (!VersionNine.TerminalColors.Value)
			{
				return ((int)weather == -1) ? "Clear" : ((object)(LevelWeatherType)(ref weather)).ToString();
			}
			LevelWeatherType val = weather;
			LevelWeatherType val2 = val;
			return (val2 - -1) switch
			{
				0 => "<color=#696969>Clear</color>", 
				2 => "<color=#26aaff>Rainy</color>", 
				5 => "<color=#aa26ff>Flooded</color>", 
				4 => "<color=#ccccbb>Foggy</color>", 
				6 => "<color=#ff2626>Eclipsed</color>", 
				3 => "<color=#ffaa26>Stormy</color>", 
				_ => "", 
			};
		}

		public static string GetColoredPlanetTime(float time)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected I4, but got Unknown
			string planetTime = RandomizedTime.GetPlanetTime(time);
			if (!VersionNine.TerminalColors.Value)
			{
				return MaximizeStringLength(planetTime, 8, spacesBefore: true);
			}
			string text = "#696969";
			DayMode dayPhase = RandomizedTime.GetDayPhase(time);
			DayMode val = dayPhase;
			switch ((int)val)
			{
			case 0:
				text = "#ffff00";
				break;
			case 1:
				text = "#00ff00";
				break;
			case 2:
				text = "#006900";
				break;
			case 3:
				text = "#550000";
				break;
			}
			return "<color=" + text + ">" + MaximizeStringLength(planetTime, 8, spacesBefore: true) + "</color>";
		}

		public static string MaximizeStringLength(string text, int targetCharacterCount, bool spacesBefore = false)
		{
			if (text.Length >= targetCharacterCount)
			{
				return text;
			}
			string text2 = "";
			if (spacesBefore)
			{
				while (text2.Length < targetCharacterCount - text.Length)
				{
					text2 += " ";
				}
				return text2 + text;
			}
			text2 = text;
			while (text2.Length < targetCharacterCount)
			{
				text2 += " ";
			}
			return text2;
		}
	}
	internal class PlayerPatches
	{
		[HarmonyPatch(typeof(PlayerControllerB), "PlayJumpAudio")]
		[HarmonyPostfix]
		private static void PlayerJump(ref PlayerControllerB __instance)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController))
			{
				__instance.sprintMeter = Mathf.Clamp(__instance.sprintMeter + 0.08f, 0f, 1f);
				bool flag = __instance.isInHangarShipRoom && __instance.playersManager.hangarDoorsClosed;
				RoundManager.Instance.PlayAudibleNoise(((Component)__instance).transform.position, 18f, 0.6f, 0, flag, 6);
			}
		}
	}
	internal class QuotaPatches
	{
		public static bool displayedOneDayWarning = false;

		private static readonly int OVERTIME_BONUS_PER_HOUR = 3;

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static void NewQuotaSettings(ref QuotaSettings __instance)
		{
			__instance.startingQuota = 300;
			__instance.deadlineDaysAmount = 4;
			__instance.increaseSteepness = 4f;
			__instance.baseIncrease = 200f;
		}

		[HarmonyPatch(typeof(TimeOfDay), "Awake")]
		[HarmonyPostfix]
		private static void TODAwake(ref TimeOfDay __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001c: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0031: Expected O, but got Unknown
			AnimationCurve val = new AnimationCurve();
			val.CopyFrom(__instance.quotaVariables.randomizerCurve);
			__instance.quotaVariables = new QuotaSettings
			{
				randomizerCurve = new AnimationCurve()
			};
			__instance.quotaVariables.randomizerCurve.CopyFrom(val);
		}

		[HarmonyPatch(typeof(TimeOfDay), "UpdateProfitQuotaCurrentTime")]
		[HarmonyPostfix]
		private static void UpdateMonitors(ref TimeOfDay __instance)
		{
			if (__instance.timeUntilDeadline <= 0f)
			{
				((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\n NOW";
				return;
			}
			string arg = ((__instance.daysUntilDeadline == 1) ? "Day" : "Days");
			string arg2 = ((__instance.hoursUntilDeadline == 1) ? "Hour" : "Hours");
			((TMP_Text)StartOfRound.Instance.deadlineMonitorText).text = "DEADLINE:\n" + $"{__instance.daysUntilDeadline} {arg},\n" + $"{__instance.hoursUntilDeadline} {arg2}";
			if (!displayedOneDayWarning && __instance.daysUntilDeadline <= 0)
			{
				if (!(StartOfRound.Instance.fearLevel >= 0.4f) && !HUDManager.Instance.displayingNewQuota)
				{
					displayedOneDayWarning = true;
					HUDManager.Instance.DisplayDaysLeft(1);
				}
			}
			else if (__instance.daysUntilDeadline >= 1)
			{
				displayedOneDayWarning = false;
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "OnHourChanged")]
		[HarmonyPostfix]
		private static void HourChanged(ref TimeOfDay __instance)
		{
			if (((NetworkBehaviour)__instance).IsServer)
			{
				CompanyBuyingRate.FluctuateCompanyBuyingRate();
				CompanyBuyingRate.CompareBuyingRate(StartOfRound.Instance.companyBuyingRate);
				StartOfRound.Instance.SyncCompanyBuyingRateServerRpc();
			}
			__instance.UpdateProfitQuotaCurrentTime();
		}

		[HarmonyPatch(typeof(DepositItemsDesk), "SellItemsOnServer")]
		[HarmonyPrefix]
		private static bool SellItems(ref DepositItemsDesk __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			Traverse.Create((object)__instance).Field("inSellingItemsAnimation").SetValue((object)true);
			int num = 0;
			for (int i = 0; i < __instance.itemsOnCounter.Count; i++)
			{
				if (__instance.itemsOnCounter[i].itemProperties.isScrap)
				{
					num += __instance.itemsOnCounter[i].scrapValue;
				}
			}
			num = Mathf.RoundToInt((float)num * StartOfRound.Instance.companyBuyingRate);
			Terminal val = Object.FindObjectOfType<Terminal>();
			val.groupCredits += num;
			__instance.SellItemsClientRpc(num, val.groupCredits, __instance.itemsOnCounterAmount, StartOfRound.Instance.companyBuyingRate);
			Traverse.Create((object)__instance).Method("SellAndDisplayItemProfits", new object[2] { num, val.groupCredits }).GetValue();
			return false;
		}

		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		[HarmonyPostfix]
		private static void ShipReset(ref StartOfRound __instance)
		{
			__instance.companyBuyingRate = 1f;
			CompanyBuyingRate.trajectory = -0.002f;
		}

		[HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
		[HarmonyPrefix]
		private static void FinishDay(ref StartOfRound __instance)
		{
			if (TimeOfDay.Instance.CalculatePlanetTime(__instance.currentLevel) / TimeOfDay.Instance.totalTime < 0.8f && TimeOfDay.Instance.timeUntilDeadline > TimeOfDay.Instance.lengthOfHours * 1f)
			{
				TimeOfDay.Instance.globalTime = Mathf.Clamp(TimeOfDay.Instance.globalTime + TimeOfDay.Instance.lengthOfHours * 1f, 0f, TimeOfDay.Instance.globalTimeAtEndOfDay);
				TimeOfDay.Instance.OnHourChanged(1);
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "PassTimeToNextDay")]
		[HarmonyPrefix]
		private static bool PassTimeNextDay(ref StartOfRound __instance)
		{
			if (__instance.isChallengeFile)
			{
				TimeOfDay.Instance.globalTime = 100f;
				__instance.SetMapScreenInfoToCurrentLevel();
				return false;
			}
			if (__instance.currentLevel.planetHasTime || TimeOfDay.Instance.daysUntilDeadline <= 0)
			{
				TimeOfDay.Instance.OnDayChanged();
			}
			TimeOfDay.Instance.globalTime = TimeOfDay.Instance.globalTime % TimeOfDay.Instance.totalTime;
			TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
			Object.FindObjectOfType<Terminal>().SetItemSales();
			__instance.SetMapScreenInfoToCurrentLevel();
			RoundManagerPatches.additionToTotalValue = 0;
			TimeOfDay.Instance.shipLeaveAutomaticallyTime = 0.998f;
			if (!GameNetworkManager.Instance.isHostingGame)
			{
				return false;
			}
			Traverse.Create((object)TimeOfDay.Instance).Method("SyncGlobalTimeOnNetwork", Array.Empty<object>()).GetValue();
			return false;
		}

		[HarmonyPatch(typeof(TimeOfDay), "SetNewProfitQuota")]
		[HarmonyPrefix]
		private static bool NewProfitQuota(ref TimeOfDay __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			int profitQuota = __instance.profitQuota;
			TimeOfDay obj = __instance;
			obj.timesFulfilledQuota++;
			int num = __instance.quotaFulfilled - __instance.profitQuota;
			float num2 = (float)__instance.timesFulfilledQuota * ((float)__instance.timesFulfilledQuota / __instance.quotaVariables.increaseSteepness);
			float num3 = Mathf.Clamp(1f + num2, 0f, 10000f);
			float num4 = __instance.quotaVariables.randomizerCurve.Evaluate(Random.Range(0f, 1f)) * __instance.quotaVariables.randomizerMultiplier + 1f;
			float num5 = __instance.quotaVariables.baseIncrease * num3 * num4;
			int num6 = (int)((float)__instance.quotaFulfilled / 1.33f) + 100 * __instance.timesFulfilledQuota;
			__instance.profitQuota = (int)Mathf.Clamp((float)__instance.profitQuota + num5, (float)num6, 1E+09f);
			__instance.quotaFulfilled = 0;
			__instance.timeUntilDeadline = __instance.totalTime * (float)__instance.quotaVariables.deadlineDaysAmount;
			int num7 = num / 5;
			int num8 = OVERTIME_BONUS_PER_HOUR * __instance.hoursUntilDeadline;
			int num9 = 0;
			if (__instance.daysUntilDeadline > 0)
			{
				float num10 = (float)__instance.daysUntilDeadline / (float)__instance.quotaVariables.deadlineDaysAmount;
				int num11 = OVERTIME_BONUS_PER_HOUR * __instance.numberOfHours * __instance.daysUntilDeadline;
				int num12 = (int)(num10 * (float)profitQuota);
				num9 = num11 + num12;
			}
			int num13 = num7 + num9 + num8;
			__instance.SyncNewProfitQuotaClientRpc(__instance.profitQuota, num13, __instance.timesFulfilledQuota);
			return false;
		}

		[HarmonyPatch(typeof(HUDManager), "rackUpNewQuotaText")]
		[HarmonyPrefix]
		private static bool ReplaceRackUpQuota(ref IEnumerator __result)
		{
			__result = NewRackUpQuota();
			return false;
		}

		private static IEnumerator NewRackUpQuota()
		{
			float rackUpPerSecond = Mathf.Clamp((float)TimeOfDay.Instance.profitQuota / 5f, 200f, 1000f);
			yield return (object)new WaitForSeconds(3.5f);
			float quotaDisplay = 0f;
			while (quotaDisplay < (float)TimeOfDay.Instance.profitQuota)
			{
				quotaDisplay = Mathf.Clamp(quotaDisplay + rackUpPerSecond * Time.deltaTime, 0f, (float)TimeOfDay.Instance.profitQuota);
				((TMP_Text)HUDManager.Instance.newProfitQuotaText).text = $"${(int)quotaDisplay}";
				yield return null;
			}
			TimeOfDay.Instance.UpdateProfitQuotaCurrentTime();
			HUDManager.Instance.UIAudio.PlayOneShot(HUDManager.Instance.newProfitQuotaSFX);
			yield return (object)new WaitForSeconds(1.25f);
			HUDManager.Instance.displayingNewQuota = false;
			HUDManager.Instance.reachedProfitQuotaAnimator.SetBool("display", false);
		}
	}
	internal class RandomizedTime
	{
		public static DayMode GetDayPhase(float time)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return TimeOfDay.Instance.GetDayPhase(time);
		}

		public static DayMode GetDayPhase(SelectableLevel level)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return GetDayPhase(CalculatePlanetTimeNormalized(level));
		}

		public static float CalculatePlanetTime(SelectableLevel level)
		{
			return TimeOfDay.Instance.CalculatePlanetTime(level);
		}

		public static float CalculatePlanetTimeNormalized(SelectableLevel level)
		{
			return CalculatePlanetTime(level) / TimeOfDay.Instance.totalTime;
		}

		public static float CalculatePlanetTimeNormalized(int levelId)
		{
			return CalculatePlanetTimeNormalized(StartOfRound.Instance.levels[levelId]);
		}

		[HarmonyPatch(typeof(Terminal), "TextPostProcess")]
		[HarmonyPrefix]
		private static void TerminalProcess(ref Terminal __instance, ref string __result, ref string modifiedDisplayText, ref TerminalNode node)
		{
			if (node.displayPlanetInfo != -1)
			{
				modifiedDisplayText = modifiedDisplayText.Replace("this moon.", "this moon. The current local time is " + GetPlanetTime(StartOfRound.Instance.levels[node.displayPlanetInfo]) + ".");
				__result = modifiedDisplayText;
			}
			else if (modifiedDisplayText.Contains("[planetTime]"))
			{
				modifiedDisplayText = "Welcome to the exomoons catalogue.\nTo route the autopilot to a moon, use the word ROUTE.\nTo learn about any moon, use INFO.\n____________________________\n\n";
				string arg = ((CompanyBuyingRate.buyingRateChangePercent < 0) ? "-" : "+");
				string text = ((CompanyBuyingRate.buyingRateChangePercent == 0) ? "" : $"<color=#696969>{arg}{Mathf.Abs(CompanyBuyingRate.buyingRateChangePercent)}</color>");
				modifiedDisplayText = modifiedDisplayText + "* Company building   //  Buying at " + GetColoredBuyingRate() + "  " + text + "\n\n";
				modifiedDisplayText += PlanetInfo.GetAllMoonInformationForTerminal();
				__result = modifiedDisplayText;
			}
		}

		public static string GetPlanetTime(SelectableLevel level)
		{
			return GetPlanetTime(CalculatePlanetTimeNormalized(level));
		}

		public static string GetColoredBuyingRate()
		{
			int num = Mathf.RoundToInt(StartOfRound.Instance.companyBuyingRate * 100f);
			string text = $"{num}%";
			if (!VersionNine.TerminalColors.Value)
			{
				return text;
			}
			string text2 = "#696969";
			if (num > 30)
			{
				text2 = "#ff2626";
			}
			if (num > 50)
			{
				text2 = "#ff8626";
			}
			if (num > 70)
			{
				text2 = "#ffff00";
			}
			if (num > 90)
			{
				text2 = "#00ff00";
			}
			if (num > 100)
			{
				text2 = "#00ff69";
			}
			if (num > 120)
			{
				text2 = "#00ffff";
			}
			if (num > 140)
			{
				text2 = "#ff36ff";
			}
			return "<color=" + text2 + ">" + text + "</color>";
		}

		public static string GetPlanetTime(float timeNormalized)
		{
			int numberOfHours = TimeOfDay.Instance.numberOfHours;
			int num = (int)(timeNormalized * (60f * (float)numberOfHours)) + 360;
			int num2 = (int)Mathf.Floor((float)num / 60f);
			if (num2 >= 24)
			{
				return "12:00 AM";
			}
			string text = ((num2 < 12) ? "AM" : "PM");
			if (num2 > 12)
			{
				num2 %= 12;
			}
			int num3 = num % 60;
			return $"{num2:00}:{num3:00}".TrimStart(new char[1] { '0' }) + " " + text;
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void SORStart(ref StartOfRound __instance)
		{
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Invalid comparison between Unknown and I4
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				switch ((LevelCostAdjustments.Planet)val.levelID)
				{
				case LevelCostAdjustments.Planet.Embrion:
					val.OffsetFromGlobalTime = 852f;
					break;
				case LevelCostAdjustments.Planet.Dine:
					val.OffsetFromGlobalTime = 933f;
					break;
				case LevelCostAdjustments.Planet.Titan:
					val.OffsetFromGlobalTime = 1011f;
					break;
				case LevelCostAdjustments.Planet.Adamance:
					val.OffsetFromGlobalTime = 1f;
					break;
				case LevelCostAdjustments.Planet.Offense:
					val.OffsetFromGlobalTime = 21f;
					break;
				case LevelCostAdjustments.Planet.Experimentation:
					val.OffsetFromGlobalTime = 112f;
					break;
				case LevelCostAdjustments.Planet.Liquidation:
					val.OffsetFromGlobalTime = 147f;
					break;
				case LevelCostAdjustments.Planet.Vow:
					val.OffsetFromGlobalTime = 277f;
					break;
				case LevelCostAdjustments.Planet.March:
					val.OffsetFromGlobalTime = 353f;
					break;
				case LevelCostAdjustments.Planet.Artifice:
					val.OffsetFromGlobalTime = 459f;
					break;
				case LevelCostAdjustments.Planet.Rend:
					val.OffsetFromGlobalTime = 611f;
					break;
				case LevelCostAdjustments.Planet.Assurance:
					val.OffsetFromGlobalTime = 768f;
					break;
				default:
					val.OffsetFromGlobalTime = 0f;
					break;
				}
			}
			__instance.SetMapScreenInfoToCurrentLevel();
			LeverPatch.displayedTimeWarning = false;
			LeverPatch.displayedDeadlineWarning = false;
			if (!((Object)(object)GameNetworkManager.Instance == (Object)null) && GameNetworkManager.Instance.isHostingGame)
			{
				bool flag = __instance.currentLevel.planetHasTime && (int)TimeOfDay.Instance.GetDayPhase(TimeOfDay.Instance.CalculatePlanetTime(TimeOfDay.Instance.currentLevel) / TimeOfDay.Instance.totalTime) == 3;
				StartMatchLever val2 = Object.FindObjectOfType<StartMatchLever>();
				if (flag)
				{
					val2.triggerScript.disabledHoverTip = "Too late on moon to land!";
				}
				val2.triggerScript.interactable = !flag && ((NetworkBehaviour)__instance).IsServer;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		[HarmonyPostfix]
		private static void ResetTime1()
		{
			TimeOfDay.Instance.globalTime = 0f;
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void ResetTime2()
		{
			if (GameNetworkManager.Instance.isHostingGame)
			{
				TimeOfDay.Instance.globalTime = ES3.Load<float>("V9GlobalTime", GameNetworkManager.Instance.currentSaveFileName, 0f);
			}
		}
	}
	internal class RoundManagerPatches
	{
		public static int additionToTotalValue;

		private static bool hasHalvedMineshaftRateThisSession;

		[HarmonyPatch(typeof(StartOfRound), "OnShipLandedMiscEvents")]
		[HarmonyPostfix]
		private static void ShipLandedFully()
		{
			RoundManager instance = RoundManager.Instance;
			instance.totalScrapValueInLevel += (float)additionToTotalValue;
			additionToTotalValue = 0;
		}

		[HarmonyPatch(typeof(StartOfRound), "Awake")]
		[HarmonyPostfix]
		private static void HalveMineshaftRate(ref StartOfRound __instance)
		{
			if (hasHalvedMineshaftRateThisSession)
			{
				return;
			}
			hasHalvedMineshaftRateThisSession = true;
			SelectableLevel[] levels = __instance.levels;
			foreach (SelectableLevel val in levels)
			{
				IntWithRarity[] dungeonFlowTypes = val.dungeonFlowTypes;
				foreach (IntWithRarity val2 in dungeonFlowTypes)
				{
					if (val2.id == 4)
					{
						val2.rarity = Math.Max(1, (int)((float)val2.rarity / 3f));
					}
				}
			}
		}
	}
	internal class Saving
	{
		[HarmonyPatch(typeof(GameNetworkManager), "SaveGame")]
		[HarmonyPostfix]
		private static void SaveExtras(ref GameNetworkManager __instance)
		{
			SaveV9Values(__instance.currentSaveFileName);
		}

		public static void SaveV9Values(string file)
		{
			ES3.Save<float>("V9GlobalTime", TimeOfDay.Instance.globalTime, file);
			ES3.Save<float>("V9CompanyBuyRate", StartOfRound.Instance.companyBuyingRate, file);
			ES3.Save<float>("V9CompanyBuyTrajectory", CompanyBuyingRate.trajectory, file);
		}

		[HarmonyPatch(typeof(StartOfRound), "SetTimeAndPlanetToSavedSettings")]
		[HarmonyPostfix]
		private static void LoadExtras()
		{
			string currentSaveFileName = GameNetworkManager.Instance.currentSaveFileName;
			TimeOfDay.Instance.globalTime = ES3.Load<float>("V9GlobalTime", currentSaveFileName, 0f);
			StartOfRound.Instance.companyBuyingRate = ES3.Load<float>("V9CompanyBuyRate", currentSaveFileName, 1f);
			CompanyBuyingRate.CompareBuyingRate(StartOfRound.Instance.companyBuyingRate);
			CompanyBuyingRate.trajectory = ES3.Load<float>("V9CompanyBuyTrajectory", currentSaveFileName, -0.002f);
			StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
		}
	}
	internal class ScrapPatches
	{
		[HarmonyPatch(typeof(RoundManager), "Start")]
		[HarmonyPostfix]
		private static void RMStart(ref RoundManager __instance)
		{
			RoundManager obj = __instance;
			obj.scrapValueMultiplier *= 2.5f;
		}

		[HarmonyPatch(typeof(GrabbableObject), "Start")]
		[HarmonyPostfix]
		private static void GrabObjectStart(ref GrabbableObject __instance)
		{
			if (__instance is KeyItem)
			{
				__instance.itemProperties.isScrap = true;
				__instance.SetScrapValue(10);
			}
		}

		[HarmonyPatch(typeof(RoundManager), "SetLockedDoors")]
		[HarmonyPostfix]
		private static void LockedDoors()
		{
			DoorLock[] array = Object.FindObjectsOfType<DoorLock>();
			int num = 0;
			DoorLock[] array2 = array;
			foreach (DoorLock val in array2)
			{
				if (val.isLocked)
				{
					num++;
					val.maxTimeLeft = Traverse.Create((object)val).Field("doorTrigger").GetValue<InteractTrigger>()
						.timeToHold / 3.3f;
					val.lockPickTimeLeft = val.maxTimeLeft;
				}
			}
		}

		[HarmonyPatch(typeof(RedLocustBees), "SpawnHiveNearEnemy")]
		[HarmonyPrefix]
		private static bool HiveSpawn(ref RedLocustBees __instance)
		{
			//IL_0048: 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)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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_006d: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 1314 + ((EnemyAI)__instance).enemyType.numberSpawned);
			Vector3 randomNavMeshPositionInBoxPredictable = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(((Component)__instance).transform.position, 10f, RoundManager.Instance.navHit, random, -5);
			GameObject val = Object.Instantiate<GameObject>(__instance.hivePrefab, randomNavMeshPositionInBoxPredictable + Vector3.up * 0.2f, Quaternion.Euler(Vector3.zero), RoundManager.Instance.spawnedScrapContainer);
			val.SetActive(true);
			val.GetComponent<NetworkObject>().Spawn(false);
			int num = random.Next(160, 405);
			if (Vector3.Distance(randomNavMeshPositionInBoxPredictable, ((Component)StartOfRound.Instance.elevatorTransform).transform.position) < 40f)
			{
				num = random.Next(160, 255);
			}
			__instance.SpawnHiveClientRpc(NetworkObjectReference.op_Implicit(val.GetComponent<NetworkObject>()), num, randomNavMeshPositionInBoxPredictable + Vector3.up * 0.2f);
			return false;
		}

		[HarmonyPatch(typeof(RedLocustBees), "SpawnHiveClientRpc")]
		[HarmonyPostfix]
		private static void AddHiveValueToTotal(ref int hiveScrapValue)
		{
			RoundManagerPatches.additionToTotalValue += hiveScrapValue;
		}
	}
	internal class TimeSync
	{
		[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
		[HarmonyPostfix]
		private static void PlayerConnected()
		{
			CompanyBuyingRate.buyingRateChangePercent = 0;
			if (GameNetworkManager.Instance.isHostingGame)
			{
				Traverse.Create((object)TimeOfDay.Instance).Field("nextTimeSync").SetValue((object)float.MinValue);
				Traverse.Create((object)TimeOfDay.Instance).Method("SyncGlobalTimeOnNetwork", Array.Empty<object>()).GetValue();
				CompanyBuyingRate.CompareBuyingRate(StartOfRound.Instance.companyBuyingRate);
				StartOfRound.Instance.SyncCompanyBuyingRateServerRpc();
			}
		}

		[HarmonyPatch(typeof(TimeOfDay), "SyncTimeClientRpc")]
		[HarmonyPostfix]
		private static void SyncedTime()
		{
			if ((Object)(object)StartOfRound.Instance != (Object)null && StartOfRound.Instance.inShipPhase)
			{
				StartOfRound.Instance.SetMapScreenInfoToCurrentLevel();
			}
		}
	}
	internal class WeatherPatches
	{
		[HarmonyPatch(typeof(FloodWeather), "OnGlobalTimeSync")]
		[HarmonyPrefix]
		private static bool FloodTimeSync(ref FloodWeather __instance)
		{
			float num = RandomizedTime.CalculatePlanetTimeNormalized(StartOfRound.Instance.currentLevel) * TimeOfDay.Instance.currentWeatherVariable2;
			Traverse.Create((object)__instance).Field("floodLevelOffset").SetValue((object)num);
			return false;
		}

		[HarmonyPatch(typeof(TimeOfDay), "DecideRandomDayEvents")]
		[HarmonyPrefix]
		private static bool DayEvents(ref TimeOfDay __instance)
		{
			if (!((NetworkBehaviour)__instance).IsServer)
			{
				return false;
			}
			Random random = new Random(StartOfRound.Instance.randomMapSeed + 28);
			int num = 7;
			if (__instance.overrideMeteorChance != -1)
			{
				num = __instance.overrideMeteorChance;
			}
			float num2 = RandomizedTime.CalculatePlanetTimeNormalized(StartOfRound.Instance.currentLevel);
			if (random.Next(0, 1000) < num && num2 < 0.75f)
			{
				int minValue = Mathf.RoundToInt(num2 * 100f) + 5;
				__instance.meteorShowerAtTime = (float)random.Next(minValue, 80) / 100f;
				return false;
			}
			__instance.meteorShowerAtTime = -1f;
			return false;
		}
	}
}