From b85c27c8a8f2500cae1f065598b5805c46876da6 Mon Sep 17 00:00:00 2001 From: DanW Date: Thu, 30 Nov 2023 08:28:17 +0000 Subject: [PATCH] Add Util to Allow Modders to Access Changes for Scav Raids (!38) Added `Utils.ScavMode.ScavRaidChangesUtil` class so mods can easily access the change in map settings (currently just escape time) for Scav raids. This will allow mods like Questing Bots, DONUTS, etc. easily be able to alter spawn settings based on "real" raid time. Currently, each mod has to cache original raid settings and calculate the difference in escape times, which is performing redundant work. I'm not sure what your conventions are for naming and stuff, so feel free to hack this up. Co-authored-by: dwesterwick Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Modules/pulls/38 Co-authored-by: DanW Co-committed-by: DanW --- .../Patches/ScavMode/ScavLateStartPatch.cs | 1 + .../Utils/ScavMode/ScavRaidChangesUtil.cs | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 project/Aki.SinglePlayer/Utils/ScavMode/ScavRaidChangesUtil.cs diff --git a/project/Aki.SinglePlayer/Patches/ScavMode/ScavLateStartPatch.cs b/project/Aki.SinglePlayer/Patches/ScavMode/ScavLateStartPatch.cs index cb6920b..79d9a8d 100644 --- a/project/Aki.SinglePlayer/Patches/ScavMode/ScavLateStartPatch.cs +++ b/project/Aki.SinglePlayer/Patches/ScavMode/ScavLateStartPatch.cs @@ -62,6 +62,7 @@ namespace Aki.SinglePlayer.Patches.ScavMode var serverResult = Json.Deserialize(json); // Set new raid time + Utils.ScavMode.ScavRaidChangesUtil.SetRaidTimeReduction(____raidSettings.SelectedLocation.EscapeTimeLimit - serverResult.RaidTimeMinutes); ____raidSettings.SelectedLocation.EscapeTimeLimit = serverResult.RaidTimeMinutes; // Handle survival time changes diff --git a/project/Aki.SinglePlayer/Utils/ScavMode/ScavRaidChangesUtil.cs b/project/Aki.SinglePlayer/Utils/ScavMode/ScavRaidChangesUtil.cs new file mode 100644 index 0000000..5bc5e32 --- /dev/null +++ b/project/Aki.SinglePlayer/Utils/ScavMode/ScavRaidChangesUtil.cs @@ -0,0 +1,29 @@ +namespace Aki.SinglePlayer.Utils.ScavMode +{ + /// + /// Allow mods to access changes made to map settings for Scav raids + /// + public static class ScavRaidChangesUtil + { + /// + /// The reduction in the escape time for the most recently loaded map, in minutes + /// + public static int RaidTimeReductionMinutes { get; private set; } = 0; + + /// + /// The reduction in the escape time for the most recently loaded map, in seconds + /// + public static int RaidTimeReductionSeconds => RaidTimeReductionMinutes * 60; + + /// + /// Updates the most recent raid-time reduction so it can be accessed by mods. + /// + /// This should be internal because mods shouldn't be able to call it. + /// + /// The raid-time reduction applied to the most recent Scav raid, in minutes + internal static void SetRaidTimeReduction(int raidTimeReduction) + { + RaidTimeReductionMinutes = raidTimeReduction; + } + } +}