Decompiled source of LunarRework v0.0.1

Nachito.LunarRework.dll

Decompiled 4 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Nachito.LunarRework.Patches;
using StaticNetcodeLib;
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("Nachito.LunarRework")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1")]
[assembly: AssemblyProduct("Nachito.LunarRework")]
[assembly: AssemblyTitle("Nachito.LunarRework")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 Nachito.LunarRework
{
	[BepInPlugin("Nachito.LunarRework", "Nachito.LunarRework", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Nachito_LunarRework : BaseUnityPlugin
	{
		public static Nachito_LunarRework Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"Nachito.LunarRework v0.0.1 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Nachito.LunarRework");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	[StaticNetcode]
	public class ServerStuff
	{
		public static int exp;

		public static int ass;

		public static int vow;

		public static int off;

		public static int mar;

		public static int ada;

		public static int rend;

		public static int dine;

		public static int tit;

		public static int emb;

		public static int art;

		[ClientRpc]
		public static void SyncVarsClientRpc(int timesNotVisitedExp, int timesNotVisitedAss, int timesNotVisitedVow, int timesNotVisitedOff, int timesNotVisitedMarch, int timesNotVisitedAda, int timesNotVisitedRend, int timesNotVisitedDine, int timesNotVisitedTitan, int timesNotVisitedEmb, int timesNotVisitedArtifice)
		{
			exp = timesNotVisitedExp;
			ass = timesNotVisitedAss;
			vow = timesNotVisitedVow;
			off = timesNotVisitedOff;
			mar = timesNotVisitedMarch;
			ada = timesNotVisitedAda;
			rend = timesNotVisitedRend;
			dine = timesNotVisitedDine;
			tit = timesNotVisitedTitan;
			emb = timesNotVisitedEmb;
			art = timesNotVisitedArtifice;
			SyncVars();
		}

		private static void SyncVars()
		{
			MoonPenaltyPatch.timesNotVisitedExp = exp;
			MoonPenaltyPatch.timesNotVisitedAss = ass;
			MoonPenaltyPatch.timesNotVisitedVow = vow;
			MoonPenaltyPatch.timesNotVisitedOff = off;
			MoonPenaltyPatch.timesNotVisitedMarch = mar;
			MoonPenaltyPatch.timesNotVisitedAda = ada;
			MoonPenaltyPatch.timesNotVisitedRend = rend;
			MoonPenaltyPatch.timesNotVisitedDine = dine;
			MoonPenaltyPatch.timesNotVisitedTitan = tit;
			MoonPenaltyPatch.timesNotVisitedEmb = emb;
			MoonPenaltyPatch.timesNotVisitedArtifice = art;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Nachito.LunarRework";

		public const string PLUGIN_NAME = "Nachito.LunarRework";

		public const string PLUGIN_VERSION = "0.0.1";
	}
}
namespace Nachito.LunarRework.Patches
{
	[HarmonyPatch(typeof(DepositItemsDesk))]
	internal class DepositItemsDeskPatch
	{
		[HarmonyPatch("SellAndDisplayItemProfits")]
		[HarmonyPostfix]
		private static void CreditsPatch(ref int newGroupCredits)
		{
			MoonPricePatch.terminal.groupCredits = (int)((float)newGroupCredits / StartOfRound.Instance.companyBuyingRate);
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class MoonPenaltyPatch
	{
		public static int timesNotVisitedTitan;

		private static int TitanMinScrap = StartOfRound.Instance.levels[9].minScrap;

		private static int TitanMaxScrap = StartOfRound.Instance.levels[9].maxScrap;

		public static int timesNotVisitedArtifice;

		private static int ArtMinScrap = StartOfRound.Instance.levels[10].minScrap;

		private static int ArtMaxScrap = StartOfRound.Instance.levels[10].maxScrap;

		public static int timesNotVisitedDine;

		private static int DineMinScrap = StartOfRound.Instance.levels[7].minScrap;

		private static int DineMaxScrap = StartOfRound.Instance.levels[7].maxScrap;

		public static int timesNotVisitedRend;

		private static int RendMinScrap = StartOfRound.Instance.levels[6].minScrap;

		private static int RendMaxScrap = StartOfRound.Instance.levels[6].maxScrap;

		public static int timesNotVisitedEmb;

		private static int EmbMinScrap = StartOfRound.Instance.levels[12].minScrap;

		private static int EmbMaxScrap = StartOfRound.Instance.levels[12].maxScrap;

		public static int timesNotVisitedAda;

		private static int AdaMinScrap = StartOfRound.Instance.levels[5].minScrap;

		private static int AdaMaxScrap = StartOfRound.Instance.levels[5].maxScrap;

		public static int timesNotVisitedMarch;

		private static int MarchMinScrap = StartOfRound.Instance.levels[4].minScrap;

		private static int MarchMaxScrap = StartOfRound.Instance.levels[4].maxScrap;

		public static int timesNotVisitedOff;

		private static int OffMinScrap = StartOfRound.Instance.levels[8].minScrap;

		private static int OffMaxScrap = StartOfRound.Instance.levels[8].maxScrap;

		public static int timesNotVisitedVow;

		private static int VowMinScrap = StartOfRound.Instance.levels[2].minScrap;

		private static int VowMaxScrap = StartOfRound.Instance.levels[2].maxScrap;

		public static int timesNotVisitedAss;

		private static int AssMinScrap = StartOfRound.Instance.levels[1].minScrap;

		private static int AssMaxScrap = StartOfRound.Instance.levels[1].maxScrap;

		public static int timesNotVisitedExp;

		private static int ExpMinScrap = StartOfRound.Instance.levels[0].minScrap;

		private static int ExpMaxScrap = StartOfRound.Instance.levels[0].maxScrap;

		public static int titanScrapMultiplier = 3;

		public static int titanHardCap = 12;

		public static int titanBasePrice = 550;

		public static int artScrapMultiplier = 1;

		public static int artHardCap = 3;

		public static int artBasePrice = 800;

		public static int dineScrapMultiplier = 2;

		public static int dineHardCap = 18;

		public static int dineBasePrice = 450;

		public static int rendScrapMultiplier = 2;

		public static int rendHardCap = 10;

		public static int rendBasePrice = 400;

		public static int embScrapMultiplier = 3;

		public static int embHardCap = 30;

		public static int embBasePrice = 100;

		public static int adaScrapMultiplier = 3;

		public static int adaHardCap = 18;

		public static int marchScrapMultiplier = 2;

		public static int marchHardCap = 20;

		public static int offScrapMultiplier = 2;

		public static int offHardCap = 18;

		public static int vowScrapMultiplier = 1;

		public static int vowHardCap = 12;

		public static int assScrapMultiplier = 1;

		public static int assHardCap = 15;

		public static int expScrapMultiplier = 1;

		public static int expHardCap = 20;

		[HarmonyPatch("SetShipReadyToLand")]
		[HarmonyPostfix]
		private static void IncreaseMoonScrap(StartOfRound __instance)
		{
			if (__instance.currentLevelID != 3 && ((NetworkBehaviour)__instance).IsHost)
			{
				if (__instance.currentLevelID != 9 && ES3.Load<int>("TitanScrap", RoundManagerPatch.currentSave) < titanHardCap)
				{
					ES3.Save<int>("TitanScrap", ES3.Load<int>("TitanScrap", RoundManagerPatch.currentSave) + titanScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedTitan = ES3.Load<int>("TitanScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 10 && ES3.Load<int>("ArtScrap", RoundManagerPatch.currentSave) < artHardCap)
				{
					ES3.Save<int>("ArtScrap", ES3.Load<int>("ArtScrap", RoundManagerPatch.currentSave) + artScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedArtifice = ES3.Load<int>("ArtScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 7 && ES3.Load<int>("DineScrap", RoundManagerPatch.currentSave) < dineHardCap)
				{
					ES3.Save<int>("DineScrap", ES3.Load<int>("DineScrap", RoundManagerPatch.currentSave) + dineScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedDine = ES3.Load<int>("DineScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 6 && ES3.Load<int>("RendScrap", RoundManagerPatch.currentSave) < rendHardCap)
				{
					ES3.Save<int>("RendScrap", ES3.Load<int>("RendScrap", RoundManagerPatch.currentSave) + rendScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedRend = ES3.Load<int>("RendScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 12 && ES3.Load<int>("EmbrionScrap", RoundManagerPatch.currentSave) < embHardCap)
				{
					ES3.Save<int>("EmbrionScrap", ES3.Load<int>("EmbrionScrap", RoundManagerPatch.currentSave) + embScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedEmb = ES3.Load<int>("EmbrionScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 5 && ES3.Load<int>("AdaScrap", RoundManagerPatch.currentSave) < adaHardCap)
				{
					ES3.Save<int>("AdaScrap", ES3.Load<int>("AdaScrap", RoundManagerPatch.currentSave) + adaScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedAda = ES3.Load<int>("AdaScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 4 && ES3.Load<int>("MarchScrap", RoundManagerPatch.currentSave) < marchHardCap)
				{
					ES3.Save<int>("MarchScrap", ES3.Load<int>("MarchScrap", RoundManagerPatch.currentSave) + marchScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedMarch = ES3.Load<int>("MarchScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 8 && ES3.Load<int>("OffScrap", RoundManagerPatch.currentSave) < offHardCap)
				{
					ES3.Save<int>("OffScrap", ES3.Load<int>("OffScrap", RoundManagerPatch.currentSave) + offScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedOff = ES3.Load<int>("OffScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 2 && ES3.Load<int>("VowScrap", RoundManagerPatch.currentSave) < vowHardCap)
				{
					ES3.Save<int>("VowScrap", ES3.Load<int>("VowScrap", RoundManagerPatch.currentSave) + vowScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedVow = ES3.Load<int>("VowScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 1 && ES3.Load<int>("AssScrap", RoundManagerPatch.currentSave) < assHardCap)
				{
					ES3.Save<int>("AssScrap", ES3.Load<int>("AssScrap", RoundManagerPatch.currentSave) + assScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedAss = ES3.Load<int>("AssScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevelID != 0 && ES3.Load<int>("ExpScrap", RoundManagerPatch.currentSave) < expHardCap)
				{
					ES3.Save<int>("ExpScrap", ES3.Load<int>("ExpScrap", RoundManagerPatch.currentSave) + expScrapMultiplier, RoundManagerPatch.currentSave);
					timesNotVisitedExp = ES3.Load<int>("ExpScrap", RoundManagerPatch.currentSave);
				}
				if (__instance.currentLevel.levelID != 3)
				{
					__instance.ChangeLevel(3);
					__instance.ChangeLevelServerRpc(3, MoonPricePatch.terminal.groupCredits);
				}
				ServerStuff.SyncVarsClientRpc(timesNotVisitedExp, timesNotVisitedAss, timesNotVisitedVow, timesNotVisitedOff, timesNotVisitedMarch, timesNotVisitedAda, timesNotVisitedRend, timesNotVisitedDine, timesNotVisitedTitan, timesNotVisitedEmb, timesNotVisitedArtifice);
			}
		}

		[HarmonyPatch("StartGame")]
		[HarmonyPostfix]
		private static void ChangeScrap(StartOfRound __instance)
		{
			switch (__instance.currentLevelID)
			{
			case 9:
				__instance.currentLevel.minScrap = TitanMinScrap + timesNotVisitedTitan;
				__instance.currentLevel.maxScrap = TitanMaxScrap + timesNotVisitedTitan;
				ES3.Save<int>("TitanScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedTitan = 0;
				break;
			case 10:
				__instance.currentLevel.minScrap = ArtMinScrap + timesNotVisitedArtifice + 5;
				__instance.currentLevel.maxScrap = ArtMaxScrap + timesNotVisitedArtifice + 7;
				ES3.Save<int>("ArtScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedArtifice = 0;
				break;
			case 7:
				__instance.currentLevel.minScrap = DineMinScrap + timesNotVisitedDine;
				__instance.currentLevel.maxScrap = DineMaxScrap + timesNotVisitedDine;
				ES3.Save<int>("DineScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedDine = 0;
				break;
			case 6:
				__instance.currentLevel.minScrap = RendMinScrap + timesNotVisitedRend;
				__instance.currentLevel.maxScrap = RendMaxScrap + timesNotVisitedRend;
				ES3.Save<int>("RendScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedRend = 0;
				break;
			case 12:
				__instance.currentLevel.minScrap = EmbMinScrap + timesNotVisitedEmb;
				__instance.currentLevel.maxScrap = EmbMaxScrap + timesNotVisitedEmb;
				ES3.Save<int>("EmbrionScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedEmb = 0;
				break;
			case 5:
				__instance.currentLevel.minScrap = AdaMinScrap + timesNotVisitedAda;
				__instance.currentLevel.maxScrap = AdaMaxScrap + timesNotVisitedAda;
				ES3.Save<int>("AdaScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedAda = 0;
				break;
			case 4:
				__instance.currentLevel.minScrap = MarchMinScrap + timesNotVisitedMarch;
				__instance.currentLevel.maxScrap = MarchMaxScrap + timesNotVisitedMarch;
				ES3.Save<int>("MarchScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedMarch = 0;
				break;
			case 8:
				__instance.currentLevel.minScrap = OffMinScrap + timesNotVisitedOff;
				__instance.currentLevel.maxScrap = OffMaxScrap + timesNotVisitedOff;
				ES3.Save<int>("OffScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedOff = 0;
				break;
			case 2:
				__instance.currentLevel.minScrap = VowMinScrap + timesNotVisitedVow;
				__instance.currentLevel.maxScrap = VowMaxScrap + timesNotVisitedVow;
				ES3.Save<int>("VowScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedVow = 0;
				break;
			case 1:
				__instance.currentLevel.minScrap = AssMinScrap + timesNotVisitedAss;
				__instance.currentLevel.maxScrap = AssMaxScrap + timesNotVisitedAss;
				ES3.Save<int>("AssScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedAss = 0;
				break;
			case 0:
				__instance.currentLevel.minScrap = ExpMinScrap + timesNotVisitedExp;
				__instance.currentLevel.maxScrap = ExpMaxScrap + timesNotVisitedExp;
				ES3.Save<int>("ExpScrap", 0, RoundManagerPatch.currentSave);
				timesNotVisitedExp = 0;
				break;
			case 3:
			case 11:
				break;
			}
		}

		[HarmonyPatch("OnPlayerConnectedClientRpc")]
		[HarmonyPostfix]
		private static void SyncVars(StartOfRound __instance)
		{
			if (((NetworkBehaviour)__instance).IsHost)
			{
				ServerStuff.SyncVarsClientRpc(timesNotVisitedExp, timesNotVisitedAss, timesNotVisitedVow, timesNotVisitedOff, timesNotVisitedMarch, timesNotVisitedAda, timesNotVisitedRend, timesNotVisitedDine, timesNotVisitedTitan, timesNotVisitedEmb, timesNotVisitedArtifice);
			}
		}
	}
	[HarmonyPatch(typeof(Terminal))]
	internal class MoonPricePatch
	{
		public static Terminal terminal = null;

		public static string og = string.Empty;

		public static bool stop;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void FindTerminal()
		{
			terminal = Object.FindObjectOfType<Terminal>();
		}

		[HarmonyPatch("LoadNewNode")]
		[HarmonyPrefix]
		private static void LoadNewNodePatchBefore(ref TerminalNode node)
		{
			if (!((Object)(object)terminal != (Object)null) || !((Object)(object)node != (Object)null))
			{
				return;
			}
			switch (((Object)node).name)
			{
			case "8route":
			{
				Traverse val5 = Traverse.Create((object)terminal).Field("totalCostOfItems");
				val5.SetValue((object)MoonPenaltyPatch.titanBasePrice);
				break;
			}
			case "68route":
			{
				Traverse val4 = Traverse.Create((object)terminal).Field("totalCostOfItems");
				val4.SetValue((object)MoonPenaltyPatch.artBasePrice);
				break;
			}
			case "7route":
			{
				Traverse val3 = Traverse.Create((object)terminal).Field("totalCostOfItems");
				val3.SetValue((object)MoonPenaltyPatch.dineBasePrice);
				break;
			}
			case "85route":
			{
				Traverse val2 = Traverse.Create((object)terminal).Field("totalCostOfItems");
				val2.SetValue((object)MoonPenaltyPatch.rendBasePrice);
				break;
			}
			case "5route":
			{
				Traverse val = Traverse.Create((object)terminal).Field("totalCostOfItems");
				val.SetValue((object)MoonPenaltyPatch.embBasePrice);
				break;
			}
			}
			if (stop && ((Object)node).name.Equals("MoonsCatalogue"))
			{
				node.displayText = og;
				stop = false;
			}
			if (((Object)node).name.Equals("MoonsCatalogue"))
			{
				og = node.displayText;
				if (MoonPenaltyPatch.timesNotVisitedTitan != 0)
				{
					string text = " (+" + MoonPenaltyPatch.timesNotVisitedTitan + "/" + MoonPenaltyPatch.titanHardCap + ")";
					node.displayText = node.displayText.Replace("Titan [planetTime]", "Titan [planetTime]" + text);
				}
				if (MoonPenaltyPatch.timesNotVisitedDine != 0)
				{
					string text2 = " (+" + MoonPenaltyPatch.timesNotVisitedDine + "/" + MoonPenaltyPatch.dineHardCap + ")";
					node.displayText = node.displayText.Replace("Dine [planetTime]", "Dine [planetTime]" + text2);
				}
				if (MoonPenaltyPatch.timesNotVisitedRend != 0)
				{
					string text3 = " (+" + MoonPenaltyPatch.timesNotVisitedRend + "/" + MoonPenaltyPatch.rendHardCap + ")";
					node.displayText = node.displayText.Replace("Rend [planetTime]", "Rend [planetTime]" + text3);
				}
				if (MoonPenaltyPatch.timesNotVisitedAda != 0)
				{
					string text4 = " (+" + MoonPenaltyPatch.timesNotVisitedAda + "/" + MoonPenaltyPatch.adaHardCap + ")";
					node.displayText = node.displayText.Replace("Adamance [planetTime]", "Adamance [planetTime]" + text4);
				}
				if (MoonPenaltyPatch.timesNotVisitedMarch != 0)
				{
					string text5 = " (+" + MoonPenaltyPatch.timesNotVisitedMarch + "/" + MoonPenaltyPatch.marchHardCap + ")";
					node.displayText = node.displayText.Replace("March [planetTime]", "March [planetTime]" + text5);
				}
				if (MoonPenaltyPatch.timesNotVisitedOff != 0)
				{
					string text6 = " (+" + MoonPenaltyPatch.timesNotVisitedOff + "/" + MoonPenaltyPatch.offHardCap + ")";
					node.displayText = node.displayText.Replace("Offense [planetTime]", "Offense [planetTime]" + text6);
				}
				if (MoonPenaltyPatch.timesNotVisitedVow != 0)
				{
					string text7 = " (+" + MoonPenaltyPatch.timesNotVisitedVow + "/" + MoonPenaltyPatch.vowHardCap + ")";
					node.displayText = node.displayText.Replace("Vow [planetTime]", "Vow [planetTime]" + text7);
				}
				if (MoonPenaltyPatch.timesNotVisitedAss != 0)
				{
					string text8 = " (+" + MoonPenaltyPatch.timesNotVisitedAss + "/" + MoonPenaltyPatch.assHardCap + ")";
					node.displayText = node.displayText.Replace("Assurance [planetTime]", "Assurance [planetTime]" + text8);
				}
				if (MoonPenaltyPatch.timesNotVisitedExp != 0)
				{
					string text9 = " (+" + MoonPenaltyPatch.timesNotVisitedExp + "/" + MoonPenaltyPatch.expHardCap + ")";
					node.displayText = node.displayText.Replace("Experimentation [planetTime]", "Experimentation [planetTime]" + text9);
				}
				stop = true;
			}
		}

		[HarmonyPatch("LoadNewNodeIfAffordable")]
		[HarmonyPrefix]
		private static void LoadNewNodeIfAffordablePatch(ref TerminalNode node)
		{
			if (!((Object)(object)node == (Object)null))
			{
				switch (((Object)node).name)
				{
				case "8routeConfirm":
					node.itemCost = MoonPenaltyPatch.titanBasePrice;
					break;
				case "68routeConfirm":
					node.itemCost = MoonPenaltyPatch.artBasePrice;
					break;
				case "7routeConfirm":
					node.itemCost = MoonPenaltyPatch.dineBasePrice;
					break;
				case "85routeConfirm":
					node.itemCost = MoonPenaltyPatch.rendBasePrice;
					break;
				case "5routeConfirm":
					node.itemCost = MoonPenaltyPatch.embBasePrice;
					break;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class RoundManagerPatch
	{
		public static string currentSave;

		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		private static void SaveStuff(PlayerControllerB __instance)
		{
			if (!((NetworkBehaviour)__instance).IsHost)
			{
				return;
			}
			currentSave = GameNetworkManager.Instance.currentSaveFileName;
			ES3.Save<int>("NachitoCertifiedSave", 1, currentSave);
			if (ES3.KeyExists("TitanScrap", currentSave))
			{
				if (ES3.Load<int>("TitanScrap", currentSave) < MoonPenaltyPatch.titanHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedTitan = ES3.Load<int>("TitanScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("TitanScrap", MoonPenaltyPatch.titanHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedTitan = MoonPenaltyPatch.titanHardCap;
				}
			}
			else
			{
				ES3.Save<int>("TitanScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedTitan = 0;
			}
			if (ES3.KeyExists("ArtScrap", currentSave))
			{
				if (ES3.Load<int>("ArtScrap", currentSave) < MoonPenaltyPatch.artHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedArtifice = ES3.Load<int>("ArtScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("ArtScrap", MoonPenaltyPatch.artHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedArtifice = MoonPenaltyPatch.artHardCap;
				}
			}
			else
			{
				ES3.Save<int>("ArtScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedArtifice = 0;
			}
			if (ES3.KeyExists("DineScrap", currentSave))
			{
				if (ES3.Load<int>("DineScrap", currentSave) < MoonPenaltyPatch.dineHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedDine = ES3.Load<int>("DineScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("DineScrap", MoonPenaltyPatch.dineHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedDine = MoonPenaltyPatch.dineHardCap;
				}
			}
			else
			{
				ES3.Save<int>("DineScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedDine = 0;
			}
			if (ES3.KeyExists("RendScrap", currentSave))
			{
				if (ES3.Load<int>("RendScrap", currentSave) < MoonPenaltyPatch.rendHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedRend = ES3.Load<int>("RendScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("RendScrap", MoonPenaltyPatch.rendHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedRend = MoonPenaltyPatch.rendHardCap;
				}
			}
			else
			{
				ES3.Save<int>("RendScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedRend = 0;
			}
			if (ES3.KeyExists("EmbrionScrap", currentSave))
			{
				if (ES3.Load<int>("EmbrionScrap", currentSave) < MoonPenaltyPatch.embHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedEmb = ES3.Load<int>("EmbrionScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("EmbrionScrap", MoonPenaltyPatch.embHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedEmb = MoonPenaltyPatch.embHardCap;
				}
			}
			else
			{
				ES3.Save<int>("EmbrionScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedEmb = 0;
			}
			if (ES3.KeyExists("AdaScrap", currentSave))
			{
				if (ES3.Load<int>("AdaScrap", currentSave) < MoonPenaltyPatch.adaHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedAda = ES3.Load<int>("AdaScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("AdaScrap", MoonPenaltyPatch.adaHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedAda = MoonPenaltyPatch.adaHardCap;
				}
			}
			else
			{
				ES3.Save<int>("AdaScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedAda = 0;
			}
			if (ES3.KeyExists("MarchScrap", currentSave))
			{
				if (ES3.Load<int>("MarchScrap", currentSave) < MoonPenaltyPatch.marchHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedMarch = ES3.Load<int>("MarchScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("MarchScrap", MoonPenaltyPatch.marchHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedMarch = MoonPenaltyPatch.marchHardCap;
				}
			}
			else
			{
				ES3.Save<int>("MarchScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedMarch = 0;
			}
			if (ES3.KeyExists("OffScrap", currentSave))
			{
				if (ES3.Load<int>("OffScrap", currentSave) < MoonPenaltyPatch.offHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedOff = ES3.Load<int>("OffScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("OffScrap", MoonPenaltyPatch.offHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedOff = MoonPenaltyPatch.offHardCap;
				}
			}
			else
			{
				ES3.Save<int>("OffScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedOff = 0;
			}
			if (ES3.KeyExists("VowScrap", currentSave))
			{
				if (ES3.Load<int>("VowScrap", currentSave) < MoonPenaltyPatch.vowHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedVow = ES3.Load<int>("VowScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("VowScrap", MoonPenaltyPatch.vowHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedVow = MoonPenaltyPatch.vowHardCap;
				}
			}
			else
			{
				ES3.Save<int>("VowScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedVow = 0;
			}
			if (ES3.KeyExists("AssScrap", currentSave))
			{
				if (ES3.Load<int>("AssScrap", currentSave) < MoonPenaltyPatch.assHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedAss = ES3.Load<int>("AssScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("AssScrap", MoonPenaltyPatch.assHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedAss = MoonPenaltyPatch.assHardCap;
				}
			}
			else
			{
				ES3.Save<int>("AssScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedAss = 0;
			}
			if (ES3.KeyExists("AssScrap", currentSave))
			{
				if (ES3.Load<int>("AssScrap", currentSave) < MoonPenaltyPatch.assHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedAss = ES3.Load<int>("AssScrap", currentSave);
				}
				else
				{
					ES3.Save<int>("AssScrap", MoonPenaltyPatch.assHardCap, currentSave);
					MoonPenaltyPatch.timesNotVisitedAss = MoonPenaltyPatch.assHardCap;
				}
			}
			else
			{
				ES3.Save<int>("ExpScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedExp = 0;
			}
			if (ES3.KeyExists("ExpScrap", currentSave))
			{
				if (ES3.Load<int>("ExpScrap", currentSave) < MoonPenaltyPatch.expHardCap)
				{
					MoonPenaltyPatch.timesNotVisitedExp = ES3.Load<int>("ExpScrap", currentSave);
					return;
				}
				ES3.Save<int>("ExpScrap", MoonPenaltyPatch.expHardCap, currentSave);
				MoonPenaltyPatch.timesNotVisitedExp = MoonPenaltyPatch.expHardCap;
			}
			else
			{
				ES3.Save<int>("ExpScrap", 0, currentSave);
				MoonPenaltyPatch.timesNotVisitedExp = 0;
			}
		}
	}
}