0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00

Reworked debug patch into single post-patch

Create singleton instance of 2911 if it doesnt exist
This commit is contained in:
Dev 2024-01-01 17:18:11 +00:00
parent 20af3f6a73
commit 865a1966d0

View File

@ -13,34 +13,6 @@ namespace Aki.Debugging.Patches
return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted)); return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
} }
[PatchPrefix]
public static void PatchPrefix()
{
try
{
var gameWorld = Singleton<GameWorld>.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<GClass2911>.Instance == null}");
gameWorld.BtrController = Singleton<GClass2911>.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] [PatchPostfix]
public static void PatchPostfix() public static void PatchPostfix()
{ {
@ -55,9 +27,23 @@ namespace Aki.Debugging.Patches
var botGame = Singleton<IBotGame>.Instance; var botGame = Singleton<IBotGame>.Instance;
ConsoleScreen.LogWarning("[AKI-BTR] Post patch, spawning btr"); if (gameWorld.BtrController == null)
{
if (!Singleton<GClass2911>.Instantiated)
{
Singleton<GClass2911>.Create(new GClass2911());
}
gameWorld.BtrController = Singleton<GClass2911>.Instance;
ConsoleScreen.LogWarning($"[AKI-BTR] BtrController instance is null: {gameWorld.BtrController == null}");
ConsoleScreen.LogWarning($"[AKI-BTR] Singleton GClass2911 is null: {Singleton<GClass2911>.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] botspawner is enabled: {botGame.BotsController.IsEnable}");
ConsoleScreen.LogWarning("[AKI-BTR] Post patch, spawning btr");
botGame.BotsController.BotSpawner.SpawnBotBTR(); botGame.BotsController.BotSpawner.SpawnBotBTR();
ConsoleScreen.LogWarning($"[AKI-BTR] btr vehicle is null: {gameWorld.BtrController?.BtrVehicle == null}"); 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}"); ConsoleScreen.LogWarning($"[AKI-BTR] BtrController.BotShooterBtr instance is null: {gameWorld.BtrController?.BotShooterBtr == null}");
var btrTransform = gameWorld.BtrController?.BtrVehicle?.gameObject?.transform; var btrTransform = gameWorld.BtrController?.BtrVehicle?.gameObject?.transform;
if (btrTransform != null) if (btrTransform != null)
{ {
ConsoleScreen.LogWarning($"[AKI-BTR] Btr Location {btrTransform}"); ConsoleScreen.LogWarning($"[AKI-BTR] Btr Location {btrTransform}");
} else { } else
{
ConsoleScreen.LogWarning($"[AKI-BTR] wasnt able to get BTR location"); ConsoleScreen.LogWarning($"[AKI-BTR] wasnt able to get BTR location");
} }
} }