Decompiled source of GHBalancedMod v6.1.0

GH Balance Mod.dll

Decompiled 11 hours ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GHBalanceMod.Helpers;
using GHBalanceMod.Solo;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("GH Balance Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GHBalanceMod")]
[assembly: AssemblyCopyright("Copyright© 2026 GarnishHat, GNU GPL v3.0")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cbfbc84e-8fea-4184-aab4-6d942b3c950d")]
[assembly: AssemblyFileVersion("5.3.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace GHBalanceMod
{
	[BepInPlugin("GHBalances", "GH Balances", "6.1.0")]
	public class BalanceModBase : BaseUnityPlugin
	{
		private const string modGUID = "GHBalances";

		private const string modName = "GH Balances";

		private const string modVersion = "6.1.0";

		private readonly Harmony harmony = new Harmony("GHBalances");

		private static BalanceModBase Instance;

		public static void Log(string input)
		{
			ManualLogSource val = Logger.CreateLogSource("GH Balances");
			val.LogFatal((object)input);
		}

		public static void LogError(string input, Exception e)
		{
			ManualLogSource val = Logger.CreateLogSource("GH Balances");
			val.LogFatal((object)("ERROR while " + input + "! : " + e));
		}

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			Log("GH Balanced has awoken! These logs are only cosmetically red to discern between other mods.");
			try
			{
				harmony.PatchAll(typeof(Injection));
				harmony.PatchAll(typeof(PlayerNotes));
				harmony.PatchAll(typeof(Save));
				harmony.PatchAll(typeof(DisplayScrapPatch));
				harmony.PatchAll(typeof(BalanceModBase));
				harmony.PatchAll(typeof(LoggerPatch));
			}
			catch (Exception e)
			{
				LogError("patching notes", e);
			}
		}
	}
}
namespace GHBalanceMod.Solo
{
	[HarmonyPatch(typeof(Debug))]
	public static class LoggerPatch
	{
		[HarmonyPatch("Log", new Type[] { typeof(object) })]
		[HarmonyPrefix]
		public static bool PrefixLog()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class Save : NetworkBehaviour
	{
		[HarmonyPatch("SaveGame")]
		[HarmonyPostfix]
		public static void Data()
		{
			if (!StartOfRound.Instance.isChallengeFile)
			{
				SoloHelpers.Save();
			}
			SoloHelpers.ScrapCollected = 0;
			if (StartOfRound.Instance.currentLevel.planetHasTime)
			{
				SoloHelpers.DaysPassed++;
				BalanceModBase.Log("Days Passed: " + SoloHelpers.DaysPassed);
			}
			SoloHelpers.Bind();
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class Injection : NetworkBehaviour
	{
		[HarmonyPatch("ConnectClientToPlayerObject")]
		[HarmonyPostfix]
		public static void Start()
		{
			if (!StartOfRound.Instance.isChallengeFile)
			{
				SoloHelpers.Load();
			}
			SoloHelpers.ScrapCollected = 0;
			SoloHelpers.Bind();
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	internal class PlayerNotes : NetworkBehaviour
	{
		[HarmonyPatch("WritePlayerNotes")]
		[HarmonyPrefix]
		public static void Write(ref bool ___allPlayersDead)
		{
			SoloHelpers.DisplayNotes(___allPlayersDead);
		}

		[HarmonyPatch("FirePlayersAfterDeadlineClientRpc")]
		[HarmonyPostfix]
		public static void Start()
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				SoloHelpers.QuotasMet = TimeOfDay.Instance.timesFulfilledQuota;
				SoloHelpers.Clear();
				BalanceModBase.Log("Attempting to clear!");
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class DisplayScrapPatch : NetworkBehaviour
	{
		[HarmonyPatch("DisplayNewScrapFound")]
		[HarmonyPostfix]
		public static void Start()
		{
			if (StartOfRound.Instance.currentLevel.planetHasTime && !StartOfRound.Instance.inShipPhase && TimeOfDay.Instance.currentDayTime > 2f)
			{
				SoloHelpers.ScrapCollected++;
				BalanceModBase.Log("Scrap collected!");
				BalanceModBase.Log($"Current Scrap : {SoloHelpers.ScrapCollected}, Required : {TimeOfDay.Instance.timesFulfilledQuota + 1}-{(TimeOfDay.Instance.timesFulfilledQuota + 1) * 4 - 1}, Minimum for high profit: {(TimeOfDay.Instance.timesFulfilledQuota + 1) * 4}+");
			}
		}
	}
	internal class SoloHelpers : NetworkBehaviour
	{
		private enum GroupDayType
		{
			Unset,
			High,
			Low,
			Failed
		}

		public enum CurrentFileType
		{
			ChallengeHost,
			ChallengeClient,
			NormalHost,
			NormalClient
		}

		public static ulong HostSteamID = StartOfRound.Instance.allPlayerScripts[0].playerSteamId;

		public static int DaysPassed = 0;

		public static int QuotasMet = 0;

		public static int ScrapCollected;

		public static Dictionary<ulong, int> PersonalSuccessDays = new Dictionary<ulong, int>();

		public static int GroupSuccessDays = 0;

		public static int PermanentGroupSuccesses = 0;

		public static ulong[] Best = new ulong[4];

		private static GroupDayType Day = GroupDayType.Unset;

		public static void Bind()
		{
			Ensure();
			if (StartOfRound.Instance.connectedPlayersAmount > 0)
			{
				for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
				{
					int num = GroupSuccessDays + PermanentGroupSuccesses + PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[i].playerSteamId];
					try
					{
						ShowLoaded(previous: true);
						StartOfRound.Instance.allPlayerScripts[i].health = Mathf.Max(40 + num * 5, 40);
						StartOfRound.Instance.allPlayerScripts[i].sprintTime = Mathf.Max(2f + (float)num * 0.25f, 2f);
						StartOfRound.Instance.allPlayerScripts[i].climbSpeed = Mathf.Max(1f + (float)num * 0.25f, 1f);
						StartOfRound.Instance.allPlayerScripts[i].sprintMeter = 1f;
						BalanceModBase.Log("Successfully bound days to " + StartOfRound.Instance.allPlayerScripts[i].playerUsername + "!");
						ShowLoaded(previous: false);
					}
					catch (Exception e)
					{
						BalanceModBase.LogError("binding days to " + StartOfRound.Instance.allPlayerScripts[i].playerUsername, e);
					}
				}
				return;
			}
			int num2 = GroupSuccessDays + PermanentGroupSuccesses + PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[0].playerSteamId];
			try
			{
				ShowLoaded(previous: true);
				StartOfRound.Instance.allPlayerScripts[0].health = Mathf.Max(40 + num2 * 5, 40);
				StartOfRound.Instance.allPlayerScripts[0].sprintTime = Mathf.Max(2f + (float)num2 * 0.25f, 2f);
				StartOfRound.Instance.allPlayerScripts[0].climbSpeed = Mathf.Max(1f + (float)num2 * 0.25f, 1f);
				StartOfRound.Instance.allPlayerScripts[0].sprintMeter = 1f;
				BalanceModBase.Log("Successfully bound days to " + StartOfRound.Instance.allPlayerScripts[0].playerUsername + "!");
				ShowLoaded(previous: false);
			}
			catch (Exception e2)
			{
				BalanceModBase.LogError("binding days to " + StartOfRound.Instance.allPlayerScripts[0].playerUsername, e2);
			}
		}

		public static void Ensure()
		{
			if (StartOfRound.Instance.connectedPlayersAmount == 0)
			{
				ulong playerSteamId = StartOfRound.Instance.allPlayerScripts[0].playerSteamId;
				if (!PersonalSuccessDays.ContainsKey(playerSteamId))
				{
					PersonalSuccessDays.Add(playerSteamId, 0);
				}
			}
			else
			{
				for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
				{
					ulong playerSteamId2 = StartOfRound.Instance.allPlayerScripts[i].playerSteamId;
					if (!PersonalSuccessDays.ContainsKey(playerSteamId2))
					{
						PersonalSuccessDays.Add(playerSteamId2, 0);
					}
				}
			}
			int num = PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[0].playerSteamId];
			int num2 = 0;
			for (int j = 0; j < TimeOfDay.Instance.timesFulfilledQuota; j++)
			{
				num2 += j;
			}
			num2 *= 3;
			int num3 = 2 * DaysPassed;
			int num4 = num3 + num2;
			int num5 = 4 * DaysPassed;
			int num6 = num5 + num2;
			try
			{
				if (GroupSuccessDays < -10 || GroupSuccessDays > num4)
				{
					Mathf.Clamp(GroupSuccessDays, -10, num4);
					BalanceModBase.Log($"Clamped Group Days! ({num})");
				}
			}
			catch (Exception e)
			{
				BalanceModBase.LogError("clamping Group Days", e);
			}
			try
			{
				if (PermanentGroupSuccesses < -10 || PermanentGroupSuccesses > 20)
				{
					Mathf.Clamp(PermanentGroupSuccesses, -10, 20);
					BalanceModBase.Log($"Clamped Permanent Group Days! ({PermanentGroupSuccesses})");
				}
			}
			catch (Exception e2)
			{
				BalanceModBase.LogError("clamping Group Days", e2);
			}
			if (DaysPassed > StartOfRound.Instance.gameStats.daysSpent || DaysPassed < 0)
			{
				Mathf.Clamp(DaysPassed, 0, StartOfRound.Instance.gameStats.daysSpent - TimeOfDay.Instance.timesFulfilledQuota);
				BalanceModBase.Log($"Clamped Days Passed! ({DaysPassed})");
			}
			if (StartOfRound.Instance.connectedPlayersAmount == 0)
			{
				try
				{
					if (num < -20 || num > num6)
					{
						Mathf.Clamp(num, -20, num6);
						BalanceModBase.Log($"Clamped Personal Days for {StartOfRound.Instance.allPlayerScripts[0].playerUsername}! ({num})");
					}
					return;
				}
				catch (Exception e3)
				{
					BalanceModBase.LogError("clamping Personal Days for " + StartOfRound.Instance.allPlayerScripts[0].playerUsername, e3);
					return;
				}
			}
			for (int k = 0; k < StartOfRound.Instance.connectedPlayersAmount + 1; k++)
			{
				try
				{
					int num7 = PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[k].playerSteamId];
					if (num7 < -20 || num7 > num6)
					{
						Mathf.Clamp(num7, -20, num6);
						BalanceModBase.Log($"Clamped Personal Days for {StartOfRound.Instance.allPlayerScripts[k].playerUsername}! ({num7})");
					}
				}
				catch (Exception e4)
				{
					BalanceModBase.LogError("clamping Personal Days for " + StartOfRound.Instance.allPlayerScripts[k].playerUsername, e4);
				}
			}
		}

		public static void Load()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			if (!((NetworkBehaviour)StartOfRound.Instance).IsServer)
			{
				return;
			}
			string text = "online/" + GameNetworkManager.Instance.currentSaveFileName;
			ES3Settings val = new ES3Settings((EncryptionType)1, Encryption.Password);
			Ensure();
			ShowLoaded(previous: true);
			if (ES3.KeyExists("DaysPassed", text, val))
			{
				try
				{
					DaysPassed = ES3.Load<int>("DaysPassed", text, 0, val);
					BalanceModBase.Log("Loaded DaysPassed!");
				}
				catch (Exception e)
				{
					BalanceModBase.LogError("loading day count", e);
				}
			}
			if (ES3.KeyExists("PersistentDays", text, val))
			{
				try
				{
					PermanentGroupSuccesses = ES3.Load<int>("PersistentDays", text, 0, val);
					BalanceModBase.Log("Loaded Persistent!");
				}
				catch (Exception e2)
				{
					BalanceModBase.LogError("loading persistent days", e2);
				}
			}
			if (ES3.KeyExists("GSD", text, val))
			{
				try
				{
					GroupSuccessDays = ES3.Load<int>("GSD", text, 0, val);
					BalanceModBase.Log("Loaded GSD!");
				}
				catch (Exception e3)
				{
					BalanceModBase.LogError("loading GSD", e3);
				}
			}
			if (ES3.KeyExists("PSD", text, val))
			{
				try
				{
					PersonalSuccessDays = ES3.Load<Dictionary<ulong, int>>("PSD", text, new Dictionary<ulong, int>(), val);
					BalanceModBase.Log("Loaded PSD!");
				}
				catch (Exception e4)
				{
					BalanceModBase.LogError("loading PSD", e4);
				}
			}
			ShowLoaded(previous: false);
		}

		public static void Save()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			string text = "online/" + GameNetworkManager.Instance.currentSaveFileName;
			ES3Settings val = new ES3Settings((EncryptionType)1, Encryption.Password);
			Ensure();
			try
			{
				ES3.Save<int>("GSD", GroupSuccessDays, text, val);
				BalanceModBase.Log("Saved GSD!");
			}
			catch (Exception e)
			{
				BalanceModBase.LogError("saving GSD", e);
			}
			try
			{
				ES3.Save<int>("PersistentDays", PermanentGroupSuccesses, text, val);
				BalanceModBase.Log("Saved PersistentDays!");
			}
			catch (Exception e2)
			{
				BalanceModBase.LogError("saving PersistentDays", e2);
			}
			try
			{
				ES3.Save<int>("DaysPassed", DaysPassed, text, val);
				BalanceModBase.Log("Saved DaysPassed!");
			}
			catch (Exception e3)
			{
				BalanceModBase.LogError("saving DaysPassed", e3);
			}
			try
			{
				ES3.Save<Dictionary<ulong, int>>("PSD", PersonalSuccessDays, text, val);
				BalanceModBase.Log("Saved PSD!");
			}
			catch (Exception e4)
			{
				BalanceModBase.LogError("saving PSD", e4);
			}
		}

		public static void Clear()
		{
			int num = 0;
			for (int i = 0; i < QuotasMet; i++)
			{
				num += i;
			}
			num *= 3;
			int num2 = 2 * DaysPassed;
			int num3 = num2 + num;
			if (GroupSuccessDays == num3 && QuotasMet >= 5)
			{
				Buff(Object.FindObjectOfType<Terminal>());
			}
			else
			{
				if (PermanentGroupSuccesses > 0)
				{
					Buff(Object.FindObjectOfType<Terminal>());
				}
				else if (PermanentGroupSuccesses < 0)
				{
					Destroy(Object.FindObjectOfType<Terminal>());
				}
				try
				{
					GroupSuccessDays = 0;
					PersonalSuccessDays.Clear();
					Ensure();
					if (GroupSuccessDays == 0 && PersonalSuccessDays[HostSteamID] == 0)
					{
						BalanceModBase.Log("Successfully reset data!");
					}
				}
				catch (Exception e)
				{
					BalanceModBase.LogError("resetting stats", e);
				}
			}
			DaysPassed = 0;
			GameNetworkManager.Instance.SaveGame();
		}

		public static void Buff(Terminal terminal)
		{
			(int, int)[] values = new(int, int)[15]
			{
				(0, 0),
				(1, 0),
				(2, 0),
				(3, 0),
				(4, 0),
				(5, 0),
				(6, 0),
				(7, 0),
				(8, 1),
				(9, 0),
				(10, 2),
				(11, 1),
				(12, 0),
				(13, 2),
				(14, 0)
			};
			(int, bool)[] array = new(int, bool)[34];
			array[0] = (0, false);
			array[7] = (7, false);
			array[8] = (8, false);
			array[11] = (11, false);
			array[15] = (15, false);
			array[16] = (16, false);
			array[1] = (1, true);
			array[2] = (2, true);
			array[3] = (3, true);
			array[24] = (24, true);
			array[25] = (25, true);
			array[26] = (26, true);
			array[5] = (5, false);
			array[19] = (19, false);
			array[17] = (17, false);
			array[18] = (18, false);
			array[10] = (10, false);
			array[27] = (27, false);
			array[29] = (29, false);
			array[32] = (32, true);
			array[4] = (4, false);
			array[6] = (6, false);
			array[9] = (9, false);
			array[12] = (12, false);
			array[13] = (13, false);
			array[14] = (14, false);
			array[20] = (20, false);
			array[21] = (21, false);
			array[22] = (22, false);
			array[23] = (23, false);
			array[28] = (28, false);
			array[30] = (30, false);
			array[31] = (31, false);
			array[33] = (33, false);
			int num = Math.Abs(PermanentGroupSuccesses);
			List<int> list = new List<int>(num);
			list.Clear();
			for (int i = 0; i < num; i++)
			{
				Random random = new Random(87652 + i);
				Random random2 = new Random(2394853 + i);
				int num2 = random.Next(0, 9);
				if (list.Contains(num2))
				{
					continue;
				}
				if ((Object)(object)terminal != (Object)null)
				{
					switch (num2)
					{
					case 1:
						Perk.AddPermanentPoint();
						break;
					case 2:
						if (StartOfRound.Instance.magnetOn)
						{
							Perk.GiveWarranty(terminal);
						}
						else
						{
							Perk.GiveCar();
						}
						break;
					case 3:
						Perk.FreeTripToRendOrDine(terminal, random2);
						break;
					case 4:
						Neutral.Sale(terminal, 50);
						break;
					case 5:
						Perk.GiftItems(terminal, values);
						break;
					case 6:
						Perk.GiftFurniture(terminal, array);
						break;
					case 7:
						Neutral.ChangeSkies((LevelWeatherType)(-1));
						break;
					case 8:
						Perk.IncreaseStartingCredits(terminal);
						break;
					default:
						Neutral.ChangeQuota(65);
						break;
					}
				}
				list.Add(num2);
			}
			Perk.AddPermanentPoint();
		}

		public static void Destroy(Terminal terminal)
		{
			int num = Math.Abs(PermanentGroupSuccesses);
			List<int> list = new List<int>(num);
			list.Clear();
			for (int i = 0; i < num; i++)
			{
				Random random = new Random(87652 + i);
				Random random2 = new Random(2980283 + i);
				int num2 = random.Next(0, 7);
				if (list.Contains(num2) || !((Object)(object)terminal != (Object)null))
				{
					continue;
				}
				switch (num2)
				{
				case 1:
					if (StartOfRound.Instance.magnetOn)
					{
						Nerf.NoopCar();
					}
					else
					{
						Nerf.VoidWarranty(terminal);
					}
					break;
				case 2:
					Neutral.Sale(terminal, 225);
					break;
				case 3:
					Nerf.FreeTripToEmbrion(terminal);
					break;
				case 4:
					switch (random2.Next(0, 15))
					{
					case 1:
						Neutral.ChangeSkies((LevelWeatherType)5);
						break;
					case 2:
						Neutral.ChangeSkies((LevelWeatherType)4);
						break;
					case 3:
						Neutral.ChangeSkies((LevelWeatherType)2);
						break;
					default:
						Neutral.ChangeSkies((LevelWeatherType)5);
						break;
					}
					break;
				case 5:
					Nerf.DockPermanentPoint();
					break;
				case 6:
					Nerf.DecreaseStartingCredits(terminal);
					break;
				default:
					Neutral.ChangeQuota(260);
					break;
				}
				list.Add(num2);
			}
			Nerf.DockPermanentPoint();
		}

		public static void ShowLoaded(bool previous)
		{
			if (previous)
			{
				BalanceModBase.Log("Previous Group Success Days: " + GroupSuccessDays);
				for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
				{
					BalanceModBase.Log("Previous Personal Success Days (" + StartOfRound.Instance.allPlayerScripts[i].playerUsername + "): " + PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[i].playerSteamId]);
				}
			}
			else
			{
				BalanceModBase.Log("Current Group Success Days: " + GroupSuccessDays);
				for (int j = 0; j < StartOfRound.Instance.connectedPlayersAmount + 1; j++)
				{
					BalanceModBase.Log("Current Personal Success Days (" + StartOfRound.Instance.allPlayerScripts[j].playerUsername + "): " + PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[j].playerSteamId]);
				}
			}
		}

		public static bool CalculatedBest()
		{
			int[] array = new int[StartOfRound.Instance.allPlayerScripts.Length];
			int[] array2 = new int[StartOfRound.Instance.allPlayerScripts.Length];
			int[] array3 = new int[StartOfRound.Instance.allPlayerScripts.Length];
			int[] array4 = new int[StartOfRound.Instance.allPlayerScripts.Length];
			PlayerStats[] allPlayerStats = StartOfRound.Instance.gameStats.allPlayerStats;
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
			{
				array2[i] = allPlayerStats[i].profitable;
				array4[i] = allPlayerStats[i].damageTaken;
				array[i] = allPlayerStats[i].stepsTaken;
				array3[i] = allPlayerStats[i].turnAmount;
			}
			for (int j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++)
			{
				if (array2.Max() == allPlayerStats[j].profitable)
				{
					if (array.Max() == allPlayerStats[j].stepsTaken)
					{
						Best[1] = allPlayerScripts[j].playerSteamId;
					}
					else
					{
						Best[1] = 1uL;
					}
				}
				if (array2.Min() == allPlayerStats[j].profitable)
				{
					if (array.Min() == allPlayerStats[j].stepsTaken)
					{
						Best[2] = allPlayerScripts[j].playerSteamId;
					}
					else
					{
						Best[2] = 1uL;
					}
				}
				if (array4.Max() == allPlayerStats[j].damageTaken)
				{
					Best[3] = allPlayerScripts[j].playerSteamId;
				}
				if (array3.Max() == allPlayerStats[j].turnAmount)
				{
					Best[4] = allPlayerScripts[j].playerSteamId;
				}
			}
			if (Best[1] != 0L && Best[2] != 0L && Best[3] != 0L && Best[4] != 0)
			{
				return true;
			}
			return false;
		}

		public static bool CalculateNotes(bool AllDead)
		{
			BalanceModBase.Log("Total scrap this round : " + ScrapCollected);
			if (!AllDead && StartOfRound.Instance.connectedPlayersAmount > 0 && CalculatedBest())
			{
				for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount + 1; i++)
				{
					bool flag = !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead && !StartOfRound.Instance.allPlayerScripts[i].disconnectedMidGame;
					ulong playerSteamId = StartOfRound.Instance.allPlayerScripts[i].playerSteamId;
					if (playerSteamId == Best[2])
					{
						if (flag)
						{
							PersonalSuccessDays[playerSteamId] -= 4;
						}
						else
						{
							PersonalSuccessDays[playerSteamId] -= 5;
						}
					}
					else if (playerSteamId == Best[1])
					{
						if (flag)
						{
							PersonalSuccessDays[playerSteamId] += 4;
						}
						else
						{
							PersonalSuccessDays[playerSteamId]--;
						}
					}
					else if (flag)
					{
						PersonalSuccessDays[playerSteamId]++;
					}
					else
					{
						PersonalSuccessDays[playerSteamId]--;
					}
				}
			}
			int num = TimeOfDay.Instance.timesFulfilledQuota + 1;
			int num2 = num * 4;
			bool flag2 = ScrapCollected >= num;
			bool flag3 = ScrapCollected >= num2;
			int groupSuccessDays = GroupSuccessDays;
			int num3 = PersonalSuccessDays[HostSteamID];
			if (flag3)
			{
				Day = GroupDayType.High;
			}
			else if (flag2)
			{
				Day = GroupDayType.Low;
			}
			else
			{
				Day = GroupDayType.Failed;
			}
			bool flag4 = StartOfRound.Instance.connectedPlayersAmount == 0;
			for (int j = 0; j < StartOfRound.Instance.allPlayerScripts.Length; j++)
			{
				PlayerStats val = StartOfRound.Instance.gameStats.allPlayerStats[j];
				PlayerControllerB val2 = StartOfRound.Instance.allPlayerScripts[j];
				val.isActivePlayer = val2.disconnectedMidGame || val2.isPlayerDead || val2.isPlayerControlled;
			}
			if (AllDead)
			{
				if (!flag4)
				{
					for (int k = 0; k < StartOfRound.Instance.connectedPlayersAmount + 1; k++)
					{
						PersonalSuccessDays[StartOfRound.Instance.allPlayerScripts[k].playerSteamId] -= 5;
					}
				}
				else
				{
					GroupSuccessDays -= 5;
				}
				GroupSuccessDays -= 5;
			}
			else
			{
				switch (Day)
				{
				case GroupDayType.High:
					GroupSuccessDays += 2 + TimeOfDay.Instance.timesFulfilledQuota;
					break;
				case GroupDayType.Low:
					GroupSuccessDays += 2;
					break;
				case GroupDayType.Failed:
					GroupSuccessDays -= 4;
					break;
				}
			}
			if (PersonalSuccessDays[HostSteamID] != num3 && GroupSuccessDays != groupSuccessDays)
			{
				return true;
			}
			return false;
		}

		public static void DisplayNotes(bool AllDead)
		{
			int num = TimeOfDay.Instance.timesFulfilledQuota + 1;
			int num2 = num * 4;
			bool flag = ScrapCollected >= num;
			bool flag2 = ScrapCollected >= num2;
			CalculateNotes(AllDead);
			StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add($"Scrap: {ScrapCollected}/{num}");
			if (flag2)
			{
				StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add($"REALLY profitable!! ({2 + TimeOfDay.Instance.timesFulfilledQuota} points!!)");
			}
			else if (flag)
			{
				StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add("Profitable!! (2 points!!)");
			}
			else
			{
				StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add("Failed. (-4 points!!)");
			}
			if (StartOfRound.Instance.connectedPlayersAmount > 0)
			{
				for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
				{
					bool flag3 = !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead && !StartOfRound.Instance.allPlayerScripts[i].disconnectedMidGame;
					StartOfRound.Instance.gameStats.allPlayerStats[i].isActivePlayer = StartOfRound.Instance.allPlayerScripts[i].disconnectedMidGame || StartOfRound.Instance.allPlayerScripts[i].isPlayerDead || StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled;
					if (!StartOfRound.Instance.gameStats.allPlayerStats[i].isActivePlayer)
					{
						continue;
					}
					ulong playerSteamId = StartOfRound.Instance.allPlayerScripts[i].playerSteamId;
					if (AllDead)
					{
						StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("All players died. -10 points EACH!");
						continue;
					}
					if (playerSteamId == Best[1])
					{
						if (flag3)
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Most Profitable! (+4 points.)");
						}
						else
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Gave their life for the cause. (-1 point.)");
						}
					}
					else if (playerSteamId == Best[2])
					{
						if (flag3)
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Laziest! (-4 points!)");
						}
						else
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Wasn't too careful. (-5 points.)");
						}
					}
					if (playerSteamId == Best[3])
					{
						if (flag3)
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Most injured!");
						}
						else
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Gave in to their injuries.");
						}
					}
					if (playerSteamId == Best[4])
					{
						if (flag3)
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Wariest!");
						}
						else
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Most clueless.");
						}
					}
					if (playerSteamId != Best[1] && playerSteamId != Best[2])
					{
						if (flag3)
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Lived! (+1 point.)");
						}
						else
						{
							StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Died. (-1 point.)");
						}
					}
				}
			}
			if (StartOfRound.Instance.connectedPlayersAmount > 0)
			{
				for (int j = 0; j < StartOfRound.Instance.connectedPlayersAmount + 1; j++)
				{
					ulong playerSteamId2 = StartOfRound.Instance.allPlayerScripts[j].playerSteamId;
					StartOfRound.Instance.gameStats.allPlayerStats[j].playerNotes.Add($"Quota: {TimeOfDay.Instance.timesFulfilledQuota + 1}, GSD: {Mathf.Max(GroupSuccessDays, -10)}, PSD: {Mathf.Max(PersonalSuccessDays[playerSteamId2], -20)}, Permanent: {Mathf.Clamp(PermanentGroupSuccesses, -10, 20)}");
				}
			}
			else
			{
				ulong playerSteamId3 = StartOfRound.Instance.allPlayerScripts[0].playerSteamId;
				StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add($"Quota: {TimeOfDay.Instance.timesFulfilledQuota + 1}, GSD: {Mathf.Max(GroupSuccessDays, -10)}, PSD: {Mathf.Max(PersonalSuccessDays[playerSteamId3], -20)}, Permanent: {Mathf.Clamp(PermanentGroupSuccesses, -10, 20)}");
			}
		}
	}
	internal class Neutral
	{
		public static void ChangeSkies(LevelWeatherType type)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 13; i++)
			{
				if (StartOfRound.Instance.levels[i].planetHasTime)
				{
					StartOfRound.Instance.levels[i].currentWeather = type;
				}
			}
		}

		public static void Sale(Terminal terminal, int amount)
		{
			for (int i = 0; i < terminal.buyableItemsList.Length; i++)
			{
				terminal.itemSalesPercentages[i] = amount;
			}
		}

		public static void ChangeQuota(int Quota)
		{
			TimeOfDay.Instance.profitQuota = Quota;
		}
	}
	internal class Perk
	{
		public static void GiveCar()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!StartOfRound.Instance.magnetOn)
			{
				GameObject val = Object.Instantiate<GameObject>(StartOfRound.Instance.VehiclesList[0], StartOfRound.Instance.magnetPoint.position + StartOfRound.Instance.magnetPoint.forward * 5f, Quaternion.identity, RoundManager.Instance.VehiclesContainer);
				StartOfRound.Instance.attachedVehicle = val.GetComponent<VehicleController>();
				val.GetComponent<VehicleController>().ToggleHeadlightsServerRpc(false);
				StartOfRound.Instance.isObjectAttachedToMagnet = true;
				((NetworkBehaviour)StartOfRound.Instance.attachedVehicle).NetworkObject.Spawn(false);
				StartOfRound.Instance.magnetOn = true;
				StartOfRound.Instance.magnetLever.initialBoolState = true;
				StartOfRound.Instance.magnetLever.setInitialState = true;
				StartOfRound.Instance.magnetLever.SetInitialState();
			}
		}

		public static void GiveWarranty(Terminal terminal)
		{
			if (!terminal.hasWarrantyTicket)
			{
				terminal.hasWarrantyTicket = true;
			}
		}

		public static void FreeTripToRendOrDine(Terminal terminal, Random random)
		{
			if (random.Next(0, 3) >= 2)
			{
				StartOfRound.Instance.ChangeLevelServerRpc(7, terminal.groupCredits);
			}
			else
			{
				StartOfRound.Instance.ChangeLevelServerRpc(6, terminal.groupCredits);
			}
		}

		public static void GiftItems(Terminal terminal, (int, int)[] values)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			Transform val = StartOfRound.Instance.playerSpawnPositions[0];
			Transform elevatorTransform = StartOfRound.Instance.elevatorTransform;
			Vector3 position = val.position;
			position.y += 0.5f;
			for (int i = 0; i < 15; i++)
			{
				for (int j = 0; j < values[i].Item2; j++)
				{
					GameObject val2 = Object.Instantiate<GameObject>(terminal.buyableItemsList[values[i].Item1].spawnPrefab, position, Quaternion.identity, elevatorTransform);
					RadarBoosterItem component = val2.GetComponent<RadarBoosterItem>();
					if (component != null)
					{
						component.SetRadarBoosterNameLocal("Blessing");
					}
					if ((Object)(object)val2.GetComponent<RadarBoosterItem>() != (Object)null)
					{
						val2.GetComponent<RadarBoosterItem>().radarBoosterName = "Blessing";
					}
					val2.GetComponent<GrabbableObject>().fallTime = 0f;
					val2.GetComponent<GrabbableObject>().itemProperties.saveItemVariable = true;
					val2.GetComponent<GrabbableObject>().isInShipRoom = true;
					val2.GetComponent<GrabbableObject>().isInElevator = true;
					val2.GetComponent<GrabbableObject>().itemProperties.isScrap = false;
					val2.GetComponent<GrabbableObject>().scrapValue = 0;
					val2.GetComponent<NetworkObject>().Spawn(false);
				}
			}
		}

		public static void GiftFurniture(Terminal terminal, (int, bool)[] values)
		{
			if (StartOfRound.Instance.unlockablesList.unlockables.Count != 34)
			{
				return;
			}
			for (int i = 0; i < StartOfRound.Instance.unlockablesList.unlockables.Count; i++)
			{
				if (values[i].Item2)
				{
					StartOfRound.Instance.BuyShipUnlockableServerRpc(values[i].Item1, terminal.groupCredits);
				}
			}
		}

		public static void IncreaseStartingCredits(Terminal terminal)
		{
			terminal.startingCreditsAmount = 120;
		}

		public static void AddPermanentPoint()
		{
			SoloHelpers.PermanentGroupSuccesses++;
			SoloHelpers.Save();
		}
	}
	internal class Nerf
	{
		public static void NoopCar()
		{
			StartOfRound.Instance.magnetOn = false;
		}

		public static void VoidWarranty(Terminal terminal)
		{
			if (terminal.hasWarrantyTicket)
			{
				terminal.hasWarrantyTicket = false;
			}
		}

		public static void FreeTripToEmbrion(Terminal terminal)
		{
			StartOfRound.Instance.ChangeLevelServerRpc(12, terminal.groupCredits);
			Neutral.ChangeSkies((LevelWeatherType)5);
		}

		public static void DecreaseStartingCredits(Terminal terminal)
		{
			terminal.startingCreditsAmount = 30;
		}

		public static void DockPermanentPoint()
		{
			SoloHelpers.PermanentGroupSuccesses--;
			SoloHelpers.Save();
		}
	}
}
namespace GHBalanceMod.Helpers
{
	internal class Encryption
	{
		public static string Password = "ScpatehoiceREfgio#$loip45";
	}
}
namespace GHBalanceMod.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "18.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("GHBalanceMod.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal Resources()
		{
		}
	}
	[CompilerGenerated]
	[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "18.6.0.0")]
	internal sealed class Settings : ApplicationSettingsBase
	{
		private static Settings defaultInstance = (Settings)(object)SettingsBase.Synchronized((SettingsBase)(object)new Settings());

		public static Settings Default => defaultInstance;
	}
}