From 865a1966d0e076a2e0faefcf539d1e4786cc1204 Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 1 Jan 2024 17:18:11 +0000 Subject: [PATCH] Reworked debug patch into single post-patch Create singleton instance of 2911 if it doesnt exist --- project/Aki.Debugging/Patches/BtrTestPatch.cs | 48 +++++++------------ 1 file changed, 17 insertions(+), 31 deletions(-) diff --git a/project/Aki.Debugging/Patches/BtrTestPatch.cs b/project/Aki.Debugging/Patches/BtrTestPatch.cs index 50137aa..2a512d7 100644 --- a/project/Aki.Debugging/Patches/BtrTestPatch.cs +++ b/project/Aki.Debugging/Patches/BtrTestPatch.cs @@ -13,34 +13,6 @@ namespace Aki.Debugging.Patches return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted)); } - [PatchPrefix] - public static void PatchPrefix() - { - try - { - var gameWorld = Singleton.Instance; - if (gameWorld.MainPlayer.Location.ToLower() != "tarkovstreets") - { - // only run patch on streets - return; - } - - if (gameWorld.BtrController == null) - { - ConsoleScreen.LogWarning($"[AKI-BTR] pre GClass2911 instance is null: {Singleton.Instance == null}"); - gameWorld.BtrController = Singleton.Instance; - - ConsoleScreen.LogWarning($"[AKI-BTR] pre BtrController instance is null: {gameWorld.BtrController == null}"); - ConsoleScreen.LogWarning($"[AKI-BTR] pre BtrController.BotShooterBtr instance is null: {gameWorld.BtrController?.BotShooterBtr == null}"); - } - } - catch (System.Exception) - { - ConsoleScreen.LogError("[AKI-BTR] Prepatch Exception thrown, check logs"); - throw; - } - } - [PatchPostfix] public static void PatchPostfix() { @@ -55,9 +27,23 @@ namespace Aki.Debugging.Patches var botGame = Singleton.Instance; - ConsoleScreen.LogWarning("[AKI-BTR] Post patch, spawning btr"); + if (gameWorld.BtrController == null) + { + if (!Singleton.Instantiated) + { + Singleton.Create(new GClass2911()); + } + gameWorld.BtrController = Singleton.Instance; + + ConsoleScreen.LogWarning($"[AKI-BTR] BtrController instance is null: {gameWorld.BtrController == null}"); + ConsoleScreen.LogWarning($"[AKI-BTR] Singleton GClass2911 is null: {Singleton.Instance == null}"); + ConsoleScreen.LogWarning($"[AKI-BTR] BtrController.BotShooterBtr instance is null: {gameWorld.BtrController?.BotShooterBtr == null}"); + ConsoleScreen.LogWarning($"[AKI-BTR] BtrController.BtrVehicle instance is null: {gameWorld.BtrController?.BtrVehicle == null}"); + } ConsoleScreen.LogWarning($"[AKI-BTR] botspawner is enabled: {botGame.BotsController.IsEnable}"); + + ConsoleScreen.LogWarning("[AKI-BTR] Post patch, spawning btr"); botGame.BotsController.BotSpawner.SpawnBotBTR(); ConsoleScreen.LogWarning($"[AKI-BTR] btr vehicle is null: {gameWorld.BtrController?.BtrVehicle == null}"); @@ -65,11 +51,11 @@ namespace Aki.Debugging.Patches ConsoleScreen.LogWarning($"[AKI-BTR] BtrController.BotShooterBtr instance is null: {gameWorld.BtrController?.BotShooterBtr == null}"); var btrTransform = gameWorld.BtrController?.BtrVehicle?.gameObject?.transform; - if (btrTransform != null) { ConsoleScreen.LogWarning($"[AKI-BTR] Btr Location {btrTransform}"); - } else { + } else + { ConsoleScreen.LogWarning($"[AKI-BTR] wasnt able to get BTR location"); } }