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/RaidSettingsWindowPatch.cs

51 lines
1.8 KiB
C#
Raw Normal View History

2024-05-21 19:10:17 +01:00
using SPT.Common.Http;
using SPT.Common.Utils;
using SPT.Reflection.Patching;
using SPT.Custom.Models;
using EFT.UI;
using EFT.UI.Matchmaker;
using System.Reflection;
using HarmonyLib;
2024-05-21 19:10:17 +01:00
namespace SPT.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
{
/// <summary>
/// Target method should have ~20 .UpdateValue() calls in it
/// </summary>
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(RaidSettingsWindow), nameof(RaidSettingsWindow.method_8));
}
[PatchPrefix]
2024-01-07 13:01:49 +00:00
private static bool PatchPreFix(
UpdatableToggle ____enableBosses,
UpdatableToggle ____scavWars,
UpdatableToggle ____taggedAndCursed,
DropDownBox ____aiDifficultyDropdown,
DropDownBox ____aiAmountDropdown,
UpdatableToggle ____randomWeatherToggle,
UpdatableToggle ____randomTimeToggle)
{
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);
2024-01-07 13:01:49 +00:00
____aiAmountDropdown.UpdateValue((int)settings.AiAmount);
____randomWeatherToggle.UpdateValue(settings.RandomWeather);
____randomTimeToggle.UpdateValue(settings.RandomTime);
return false;
}
}
}