0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:10:44 -05:00
modules/project/Aki.Custom/Patches/RaidSettingsWindowPatch.cs
Kaeno f9e7681fec Add: New RaidSettingsWindowPatch to make Raidsettingswindow to not default inraid values to BSG defaults on game settings click. (!7)
Co-authored-by: Kaeno <>
Reviewed-on: SPT-AKI/Modules#7
Reviewed-by: Terkoiz <terkoiz@noreply.dev.sp-tarkov.com>
Co-authored-by: Kaeno <kaeno@noreply.dev.sp-tarkov.com>
Co-committed-by: Kaeno <kaeno@noreply.dev.sp-tarkov.com>
2023-04-01 10:39:12 +00:00

43 lines
1.7 KiB
C#

using Aki.Common.Http;
using Aki.Common.Utils;
using Aki.Reflection.Patching;
using Aki.Custom.Models;
using EFT.UI;
using EFT.UI.Matchmaker;
using System.Reflection;
namespace Aki.Custom.Patches
{
/// <summary>
/// The purpose of this patch is to make RaidSettingsWindow not reset the values to BSG default
/// Keeping our own from InRaid.json therefore not defaulting to bosses being disabled.
/// </summary>
public class RaidSettingsWindowPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
var desiredType = typeof(RaidSettingsWindow);
var desiredMethod = desiredType.GetMethod("method_9", BindingFlags.NonPublic | BindingFlags.Instance);
Logger.LogDebug($"{this.GetType().Name} Type: {desiredType?.Name}");
Logger.LogDebug($"{this.GetType().Name} Method: {desiredMethod?.Name}");
return desiredMethod;
}
[PatchPrefix]
private static bool PatchPreFix(UpdatableToggle ____enableBosses, UpdatableToggle ____scavWars, UpdatableToggle ____taggedAndCursed, DropDownBox ____aiDifficultyDropdown, DropDownBox ____aiAmountDropdown)
{
var json = RequestHandler.GetJson("/singleplayer/settings/raid/menu");
var settings = Json.Deserialize<DefaultRaidSettings>(json);
____enableBosses.UpdateValue(settings.BossEnabled);
____scavWars.UpdateValue(false);
____taggedAndCursed.UpdateValue(settings.TaggedAndCursed);
____aiDifficultyDropdown.UpdateValue((int)settings.AiDifficulty);
____aiAmountDropdown.UpdateValue((int)(settings.AiAmount));
return false;
}
}
}