mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 08:10:45 -05:00
![Lacyway](/assets/img/avatar_default.png)
Some patches are `internal` that should be `public` so that mods can disable them when altering AI. Co-authored-by: Lacyway <20912169+Lacyway@users.noreply.github.com> Reviewed-on: SPT/Modules#152 Co-authored-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com> Co-committed-by: Lacyway <lacyway@noreply.dev.sp-tarkov.com>
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();
|
|
}
|
|
}
|
|
}
|
|
}
|