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

35 lines
1.1 KiB
C#

using SPT.Custom.Utils;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using EFT;
using EFT.UI;
using System.Reflection;
namespace SPT.Custom.Patches
{
public class BotDifficultyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
var methodName = "LoadDifficultyStringInternal";
var flags = BindingFlags.Public | BindingFlags.Static;
return PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null)
.GetMethod(methodName, flags);
}
[PatchPrefix]
private static bool PatchPrefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role)
{
__result = DifficultyManager.Get(botDifficulty, role);
var resultIsNullEmpty = string.IsNullOrWhiteSpace(__result);
if (resultIsNullEmpty)
{
ConsoleScreen.LogError($"Unable to get difficulty settings for {role} {botDifficulty}");
}
return resultIsNullEmpty; // Server data returned = false = skip original method
}
}
}