2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2024-02-22 09:13:09 +00:00
|
|
|
|
using EFT;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2024-02-22 09:13:09 +00:00
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
*/
|
2024-08-01 21:01:25 +01:00
|
|
|
|
public class BotOwnerDisposePatch : ModulePatch
|
2024-02-22 09:13:09 +00:00
|
|
|
|
{
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|