2024-01-03 16:06:50 +00:00
|
|
|
using System.Reflection;
|
|
|
|
using Aki.Reflection.Patching;
|
|
|
|
using Comfort.Common;
|
|
|
|
using EFT;
|
|
|
|
using EFT.UI;
|
2024-01-14 09:05:13 +00:00
|
|
|
using HarmonyLib;
|
2024-01-03 16:06:50 +00:00
|
|
|
|
|
|
|
namespace Aki.Debugging.BTR.Patches
|
|
|
|
{
|
2024-01-04 08:51:06 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Adds a BTRManager component to the GameWorld game object when raid starts.
|
|
|
|
/// </summary>
|
2024-01-03 16:06:50 +00:00
|
|
|
public class BTRPatch : ModulePatch
|
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
{
|
2024-01-14 09:05:13 +00:00
|
|
|
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
|
2024-01-03 16:06:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
public static void PatchPostfix()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
|
|
if (gameWorld.MainPlayer.Location.ToLower() != "tarkovstreets")
|
|
|
|
{
|
|
|
|
// only run patch on streets
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gameWorld.LocationId.IsNullOrEmpty())
|
|
|
|
{
|
|
|
|
// GameWorld's LocationId needs to be set otherwise BTR doesn't get spawned in automatically
|
|
|
|
gameWorld.LocationId = gameWorld.MainPlayer.Location;
|
|
|
|
}
|
|
|
|
|
|
|
|
gameWorld.gameObject.AddComponent<BTRManager>();
|
|
|
|
}
|
|
|
|
catch (System.Exception)
|
|
|
|
{
|
2024-01-04 08:51:06 +00:00
|
|
|
ConsoleScreen.LogError("[AKI-BTR]: Exception thrown, check logs.");
|
2024-01-03 16:06:50 +00:00
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|