using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using GHBalanceMod.Patches; using GameNetcodeStuff; using HarmonyLib; 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("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace GHBalanceMod { [BepInPlugin("GHBalanceMod", "GH Balance Mod", "4.0.0")] public class BalanceModBase : BaseUnityPlugin { private const string modGUID = "GHBalanceMod"; private const string modName = "GH Balance Mod"; private const string modVersion = "4.0.0"; private readonly Harmony harmony = new Harmony("GHBalanceMod"); private static BalanceModBase Instance; internal ManualLogSource LOGGER; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } LOGGER = Logger.CreateLogSource("GHBalanceMod"); LOGGER.LogInfo((object)"GH Balanced has awoken!!"); harmony.PatchAll(typeof(BalanceModBase)); harmony.PatchAll(typeof(PlayerControllerBPatch)); harmony.PatchAll(typeof(PlayerNotesPatch)); } } } namespace GHBalanceMod.Patches { [HarmonyPatch(typeof(PlayerControllerB))] internal class PlayerControllerBPatch { [HarmonyPatch("Update")] [HarmonyPostfix] public static void ChangeSpeed(ref float ___sprintTime) { if (StartOfRound.Instance.connectedPlayersAmount > 0) { for (int i = 0; i < StartOfRound.Instance.connectedPlayersAmount; i++) { if (2f + (float)PlayerNotesPatch.personalSuccessDays[i] * 0.25f + PlayerNotesPatch.groupSuccessDays * 0.25f < 2f) { StartOfRound.Instance.allPlayerScripts[i].sprintTime = 2f; } else { StartOfRound.Instance.allPlayerScripts[i].sprintTime = 2f + (float)PlayerNotesPatch.personalSuccessDays[i] * 0.25f + PlayerNotesPatch.groupSuccessDays * 0.25f; } } } else if (2f + PlayerNotesPatch.groupSuccessDays * 0.25f < 2f) { ___sprintTime = 2f; } else { ___sprintTime = 2f + PlayerNotesPatch.groupSuccessDays * 0.25f; } } } [HarmonyPatch(typeof(StartOfRound))] internal class PlayerNotesPatch { public static int onlinePeoples = StartOfRound.Instance.allPlayerScripts.Length; public static int[] personalSuccessDays = new int[onlinePeoples]; public static float groupSuccessDays = 0f; [HarmonyPatch("WritePlayerNotes")] [HarmonyPrefix] public static void WritePlayerNotes() { int num = 0; PlayerStats[] allPlayerStats = StartOfRound.Instance.gameStats.allPlayerStats; int num2 = TimeOfDay.Instance.daysUntilDeadline switch { 0 => 4, 1 => 3, 2 => 2, 3 => 1, _ => 0, }; int num3 = TimeOfDay.Instance.timesFulfilledQuota * 4 + num2; bool flag = num3 == 1; int num4 = 4 * (TimeOfDay.Instance.timesFulfilledQuota + 1); int num5 = 8 * (TimeOfDay.Instance.timesFulfilledQuota + 1) + 5; bool flag2 = StartOfRound.Instance.scrapCollectedLastRound >= num4; bool flag3 = StartOfRound.Instance.scrapCollectedLastRound >= num5; bool flag4 = TimeOfDay.Instance.daysUntilDeadline == 3 && !flag; if (flag) { ResetArray(personalSuccessDays); groupSuccessDays = 0f; } if (!flag4) { if (flag2) { groupSuccessDays += 1f; string text = " (" + StartOfRound.Instance.allPlayerScripts[0].sprintTime / 5f * 100f + "% normal duration)"; if (StartOfRound.Instance.connectedPlayersAmount == 0) { StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add("Profitable! +8.33% Sprint duration!" + text); } } else { groupSuccessDays -= 1f; string text2 = " (" + StartOfRound.Instance.allPlayerScripts[0].sprintTime / 5f * 100f + "% normal duration)"; if (StartOfRound.Instance.connectedPlayersAmount == 0) { StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add("Failed! -16.66% Sprint duration!" + text2); } } if (flag3) { groupSuccessDays += 2f; string text3 = " (" + StartOfRound.Instance.allPlayerScripts[0].sprintTime / 5f * 100f + "% normal duration)"; if (StartOfRound.Instance.connectedPlayersAmount == 0) { StartOfRound.Instance.gameStats.allPlayerStats[0].playerNotes.Add("Super profitable! +16.66% Sprint duration!" + text3); } } } for (int i = 0; i < onlinePeoples; i++) { for (int j = 0; j < onlinePeoples; j++) { bool flag5 = !StartOfRound.Instance.allPlayerScripts[i].isPlayerDead && !StartOfRound.Instance.allPlayerScripts[i].disconnectedMidGame; bool flag6 = num == onlinePeoples && flag5; bool flag7 = num == onlinePeoples; float[] array = new float[onlinePeoples]; StartOfRound.Instance.gameStats.allPlayerStats[i].isActivePlayer = StartOfRound.Instance.allPlayerScripts[i].disconnectedMidGame || StartOfRound.Instance.allPlayerScripts[i].isPlayerDead || StartOfRound.Instance.allPlayerScripts[i].isPlayerControlled; string[] array2 = new string[2]; if (StartOfRound.Instance.connectedPlayersAmount <= 0 || !allPlayerStats[i].isActivePlayer || allPlayerStats[j].isActivePlayer) { continue; } if (allPlayerStats[i].profitable > allPlayerStats[j].profitable) { num = j; if (flag6) { personalSuccessDays[i] += 2; array[i] = StartOfRound.Instance.allPlayerScripts[i].sprintTime; string text4 = " (" + array[i] / 5f * 100f + "% normal duration)"; StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Most profitable! +16.66% Sprint duration!" + text4); array2[1] = StartOfRound.Instance.allPlayerScripts[i].playerUsername; num = 0; } else if (flag7) { array[i] = StartOfRound.Instance.allPlayerScripts[i].sprintTime; string text5 = " (" + array[i] / 5f * 100f + "% normal duration)"; StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Most profitable, but you died. Duration normal." + text5); array2[1] = StartOfRound.Instance.allPlayerScripts[i].playerUsername; num = 0; } } if (allPlayerStats[i].stepsTaken >= allPlayerStats[j].stepsTaken || allPlayerStats[i].profitable >= allPlayerStats[j].profitable) { continue; } num = j; if (flag6) { personalSuccessDays[i] -= 2; array[i] = StartOfRound.Instance.allPlayerScripts[i].sprintTime; string text6 = " (" + array[i] / 5f * 100f + "% normal duration)"; StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("The laziest employee. -16.66% Sprint duration!" + text6); array2[2] = StartOfRound.Instance.allPlayerScripts[i].playerUsername; num = 0; } else if (flag7) { personalSuccessDays[i] -= 4; array[i] = StartOfRound.Instance.allPlayerScripts[i].sprintTime; string text7 = " (" + array[i] / 5f * 100f + "% normal duration)"; StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("The laziest employee... died. -33.32% Sprint duration!" + text7); array2[2] = StartOfRound.Instance.allPlayerScripts[i].playerUsername; num = 0; } if (allPlayerStats[i].damageTaken > allPlayerStats[j].damageTaken) { num = j; if (flag7) { StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("Sustained the most injuries."); num = 0; } } if (allPlayerStats[i].profitable > allPlayerStats[j].turnAmount) { num = j; if (flag7) { StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("The most paranoid employee."); num = 0; } } if (array2[1] != null && array2[2] != null) { if (!(StartOfRound.Instance.allPlayerScripts[i].playerUsername == array2[1]) && !(StartOfRound.Instance.allPlayerScripts[i].playerUsername == array2[2]) && !flag5) { personalSuccessDays[i]++; array[i] = StartOfRound.Instance.allPlayerScripts[i].sprintTime; string text8 = " (" + array[i] / 5f * 100f + "% normal duration)"; StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("You did alright! +8.33% Sprint duration!" + text8); } else if (!(StartOfRound.Instance.allPlayerScripts[i].playerUsername == array2[1]) && !(StartOfRound.Instance.allPlayerScripts[i].playerUsername == array2[2])) { personalSuccessDays[i]--; array[i] = StartOfRound.Instance.allPlayerScripts[i].sprintTime; string text9 = " (" + array[i] / 5f * 100f + "% normal duration)"; StartOfRound.Instance.gameStats.allPlayerStats[i].playerNotes.Add("You did alright... until you died. -8.33% Sprint duration!" + text9); array2[2] = StartOfRound.Instance.allPlayerScripts[i].playerUsername; num = 0; } } } } } private static void ResetArray(int[] x) { for (int i = 0; i < x.Length; i++) { x[i] = 0; } } } }