0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Custom/Patches/BotDifficultyPatch.cs

35 lines
1.1 KiB
C#
Raw Normal View History

2024-05-21 19:10:17 +01:00
using SPT.Custom.Utils;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
2023-03-03 18:52:31 +00:00
using EFT;
using EFT.UI;
2023-03-03 18:52:31 +00:00
using System.Reflection;
2024-05-21 19:10:17 +01:00
namespace SPT.Custom.Patches
2023-03-03 18:52:31 +00:00
{
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)
2023-03-03 18:52:31 +00:00
.GetMethod(methodName, flags);
}
[PatchPrefix]
public static bool PatchPrefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role)
2023-03-03 18:52:31 +00:00
{
__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
2023-03-03 18:52:31 +00:00
}
}
}