2024-05-21 19:10:17 +01:00
|
|
|
using SPT.Common.Http;
|
|
|
|
using SPT.Common.Utils;
|
|
|
|
using SPT.Reflection.Patching;
|
|
|
|
using SPT.Custom.Models;
|
2023-03-03 18:52:31 +00:00
|
|
|
using EFT.UI;
|
|
|
|
using EFT.UI.Matchmaker;
|
|
|
|
using System.Reflection;
|
|
|
|
using EFT;
|
2023-03-08 21:56:02 +03:00
|
|
|
using HarmonyLib;
|
2024-05-21 19:10:17 +01:00
|
|
|
using SPT.Reflection.Utils;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
namespace SPT.Custom.Patches
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
2024-07-08 14:57:24 +01:00
|
|
|
public class SetPreRaidSettingsScreenDefaultsPatch : ModulePatch
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
return AccessTools.GetDeclaredMethods(typeof(MatchmakerOfflineRaidScreen))
|
|
|
|
.SingleCustom(m => m.Name == nameof(MatchmakerOfflineRaidScreen.Show) && m.GetParameters().Length == 1);
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2024-08-02 16:57:59 +01:00
|
|
|
public static void PatchPrefix(object controller, UpdatableToggle ____offlineModeToggle)
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
2024-08-01 20:29:07 +01:00
|
|
|
//var raidSettings = Traverse.Create(controller).Field<RaidSettings>("RaidSettings").Value;
|
|
|
|
var offlineRaidSettings = Traverse.Create(controller).Field<RaidSettings>("OfflineRaidSettings").Value;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
2024-08-01 20:29:07 +01:00
|
|
|
// Default checkbox to be unchecked so we're in PvE
|
|
|
|
____offlineModeToggle.isOn = false;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
2024-07-08 14:31:04 +01:00
|
|
|
// Get settings from server
|
2023-03-03 18:52:31 +00:00
|
|
|
var json = RequestHandler.GetJson("/singleplayer/settings/raid/menu");
|
|
|
|
var settings = Json.Deserialize<DefaultRaidSettings>(json);
|
|
|
|
|
|
|
|
// TODO: Not all settings are used and they also don't cover all the new settings that are available client-side
|
2023-03-08 21:56:02 +03:00
|
|
|
if (settings == null)
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
2023-03-08 21:56:02 +03:00
|
|
|
return;
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
2023-03-08 21:56:02 +03:00
|
|
|
|
2024-08-01 20:29:07 +01:00
|
|
|
// We use PVE mode from Tarkov now we need to modify PVE MODE instead of ONLINE Mode
|
|
|
|
|
|
|
|
offlineRaidSettings.BotSettings.BotAmount = settings.AiAmount;
|
|
|
|
offlineRaidSettings.WavesSettings.BotAmount = settings.AiAmount;
|
|
|
|
offlineRaidSettings.WavesSettings.BotDifficulty = settings.AiDifficulty;
|
|
|
|
offlineRaidSettings.WavesSettings.IsBosses = settings.BossEnabled;
|
|
|
|
offlineRaidSettings.BotSettings.IsScavWars = false;
|
|
|
|
offlineRaidSettings.WavesSettings.IsTaggedAndCursed = settings.TaggedAndCursed;
|
|
|
|
offlineRaidSettings.TimeAndWeatherSettings.IsRandomWeather = settings.RandomWeather;
|
|
|
|
offlineRaidSettings.TimeAndWeatherSettings.IsRandomTime = settings.RandomTime;
|
|
|
|
}
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
|
|
[PatchPostfix]
|
2024-08-02 16:57:59 +01:00
|
|
|
public static void PatchPostfix(MatchmakerOfflineRaidScreen __instance, DefaultUIButton ____changeSettingsButton, UiElementBlocker ____onlineBlocker)
|
2023-03-03 18:52:31 +00:00
|
|
|
{
|
2024-07-06 00:15:58 +01:00
|
|
|
____onlineBlocker.gameObject.SetActive(false);
|
|
|
|
____changeSettingsButton.Interactable = true;
|
|
|
|
__instance.transform.Find("Content/WarningPanelHorLayout").gameObject.SetActive(false);
|
2023-03-03 18:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|