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/CoreDifficultyPatch.cs
2024-05-21 19:10:17 +01:00

33 lines
978 B
C#

using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using SPT.Common.Http;
using System.Reflection;
using SPT.Custom.Utils;
namespace SPT.Custom.Patches
{
public class CoreDifficultyPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
var methodName = "LoadCoreByString";
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)
{
// fetch all bot difficulties to be used in BotDifficultyPatch
// this is called here since core difficulties are fetched before bot-specific difficulties are
DifficultyManager.Update();
// update core difficulty
__result = RequestHandler.GetJson("/singleplayer/settings/bot/difficulty/core/core");
return string.IsNullOrWhiteSpace(__result);
}
}
}