mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 08:30:45 -05:00
29 lines
769 B
C#
29 lines
769 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
|
|
*/
|
|
public 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();
|
|
}
|
|
}
|
|
}
|
|
}
|