From a0f2bb92610eaa72988a0085d2a9ab660b44e4ef Mon Sep 17 00:00:00 2001 From: Kaeno Date: Thu, 18 Jan 2024 20:59:33 +0000 Subject: [PATCH] Added new patch to fix bots spawning on Sandbox( Ground Zero ) --- project/Aki.Custom/AkiCustomPlugin.cs | 1 + .../Patches/FixBrokenSpawnOnSandboxPatch.cs | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs diff --git a/project/Aki.Custom/AkiCustomPlugin.cs b/project/Aki.Custom/AkiCustomPlugin.cs index 5822310..ddc4a51 100644 --- a/project/Aki.Custom/AkiCustomPlugin.cs +++ b/project/Aki.Custom/AkiCustomPlugin.cs @@ -48,6 +48,7 @@ namespace Aki.Custom //new RankPanelPatch().Enable(); new RagfairFeePatch().Enable(); new ScavQuestPatch().Enable(); + new FixBrokenSpawnOnSandboxPatch().Enable(); } catch (Exception ex) { diff --git a/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs b/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs new file mode 100644 index 0000000..ae0e74c --- /dev/null +++ b/project/Aki.Custom/Patches/FixBrokenSpawnOnSandboxPatch.cs @@ -0,0 +1,39 @@ +using Aki.Reflection.Patching; +using Comfort.Common; +using EFT; +using HarmonyLib; +using System.Linq; +using System.Reflection; +using UnityEngine; + +namespace Aki.Custom.Patches +{ + /// + /// Fixes the map sandbox from only spawning 1 bot at start of game as well as fixing no spawns till all bots are dead. + /// Remove once BSG decides to fix their map + /// + public class FixBrokenSpawnOnSandboxPatch : ModulePatch + { + protected override MethodBase GetTargetMethod() + { + return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted)); + } + + [PatchPrefix] + private static void PatchPrefix() + { + var gameWorld = Singleton.Instance; + if (gameWorld == null) + { + return; + } + + var playerLocation = gameWorld.MainPlayer.Location; + + if (playerLocation == "Sandbox") + { + Object.FindObjectsOfType().ToList().First(x => x.name == "ZoneSandbox").MaxPersonsOnPatrol = 10; + } + } + } +}