2024-04-20 22:32:28 +00:00
|
|
|
using Aki.Custom.Utils;
|
2023-03-03 18:52:31 +00:00
|
|
|
using Aki.Reflection.Patching;
|
|
|
|
using Aki.Reflection.Utils;
|
|
|
|
using EFT;
|
2023-10-10 10:58:33 +00:00
|
|
|
using EFT.UI;
|
2023-03-03 18:52:31 +00:00
|
|
|
using System.Reflection;
|
|
|
|
|
|
|
|
namespace Aki.Custom.Patches
|
|
|
|
{
|
|
|
|
public class BotDifficultyPatch : ModulePatch
|
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
{
|
|
|
|
var methodName = "LoadDifficultyStringInternal";
|
|
|
|
var flags = BindingFlags.Public | BindingFlags.Static;
|
|
|
|
|
2024-01-13 22:08:29 +00:00
|
|
|
return PatchConstants.EftTypes.SingleCustom(x => x.GetMethod(methodName, flags) != null)
|
2023-03-03 18:52:31 +00:00
|
|
|
.GetMethod(methodName, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
[PatchPrefix]
|
|
|
|
private static bool PatchPrefix(ref string __result, BotDifficulty botDifficulty, WildSpawnType role)
|
|
|
|
{
|
2024-04-20 22:32:28 +00:00
|
|
|
__result = DifficultyManager.Get(botDifficulty, role);
|
2023-10-10 10:58:33 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|