0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Custom/BTR/Patches/BTRDestroyAtRaidEndPatch.cs

35 lines
973 B
C#
Raw Normal View History

2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using HarmonyLib;
using System.Reflection;
using Object = UnityEngine.Object;
2024-05-21 19:10:17 +01:00
namespace SPT.Custom.BTR.Patches
{
public class BTRDestroyAtRaidEndPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
2024-04-03 15:38:14 +01:00
return AccessTools.Method(typeof(BaseLocalGame<EftGamePlayerOwner>), nameof(BaseLocalGame<EftGamePlayerOwner>.Stop));
}
[PatchPrefix]
private static void PatchPrefix()
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
return;
}
var btrManager = gameWorld.GetComponent<BTRManager>();
if (btrManager != null)
{
Logger.LogWarning("[SPT-BTR] BTRDestroyAtRaidEndPatch - Raid Ended: Destroying BTRManager");
Object.Destroy(btrManager);
}
}
}
}