2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
using EFT;
|
|
|
|
|
using System.Reflection;
|
2024-01-13 22:08:29 +00:00
|
|
|
|
using HarmonyLib;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Goal: patch removes the current bot from its own enemy list - occurs when adding bots type to its enemy array in difficulty settings
|
|
|
|
|
/// </summary>
|
|
|
|
|
internal class BotSelfEnemyPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
return AccessTools.Method(typeof(BotOwner), nameof(BotOwner.PreActivate));
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2023-10-10 10:58:33 +00:00
|
|
|
|
private static bool PatchPrefix(BotOwner __instance, BotsGroup group)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
2023-10-10 10:58:33 +00:00
|
|
|
|
IPlayer selfToRemove = null;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
|
|
|
|
foreach (var enemy in group.Enemies)
|
|
|
|
|
{
|
|
|
|
|
if (enemy.Key.Id == __instance.Id)
|
|
|
|
|
{
|
|
|
|
|
selfToRemove = enemy.Key;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (selfToRemove != null)
|
|
|
|
|
{
|
|
|
|
|
group.Enemies.Remove(selfToRemove);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|