0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Custom/Patches/BotOwnerDisposePatch.cs
2024-05-21 19:10:17 +01:00

29 lines
771 B
C#

using SPT.Reflection.Patching;
using EFT;
using HarmonyLib;
using System.Reflection;
namespace SPT.Custom.Patches
{
/**
* BotOwner doesn't call SetOff on the CalledData object when a bot is disposed, this can result
* in bots that are no longer alive having their `OnEnemyAdd` method called
*/
internal class BotOwnerDisposePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BotOwner), nameof(BotOwner.Dispose));
}
[PatchPrefix]
private static void PatchPrefix(BotOwner __instance)
{
if (__instance.CalledData != null)
{
__instance.CalledData.SetOff();
}
}
}
}