mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
fixed bot difficulties model to match server response for `/singleplayer/settings/bot/difficulties` also bumps up the sptBear and sptUsec enums so they don't collide with new pmcUSEC and pmcBEAR Reviewed-on: SPT-AKI/Modules#113 Co-authored-by: kiobu <kiobu@sdf.org> Co-committed-by: kiobu <kiobu@sdf.org>
33 lines
978 B
C#
33 lines
978 B
C#
using Aki.Reflection.Patching;
|
|
using Aki.Reflection.Utils;
|
|
using Aki.Common.Http;
|
|
using System.Reflection;
|
|
using Aki.Custom.Utils;
|
|
|
|
namespace Aki.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);
|
|
}
|
|
}
|
|
}
|