using SPT.SinglePlayer.Patches.ScavMode; using EFT; using System; using SPT.SinglePlayer.Models.ScavMode; namespace SPT.SinglePlayer.Utils.InRaid { /// /// Allow modders to access changes made to the current (or most recent) raid /// public static class RaidChangesUtil { /// /// The UTC time when raid changes were last applied /// public static DateTime RaidChangesAppliedUtcTime { get; private set; } = DateTime.MinValue; /// /// If raid changes have been completed /// public static bool HaveChangesBeenApplied => RaidChangesAppliedUtcTime != DateTime.MinValue; /// /// If the most recent raid was a Scav run /// public static bool IsScavRaid { get; private set; } = false; /// /// The location ID of the map for the current (or most recent) raid /// public static string LocationId { get; private set; } = string.Empty; /// /// The original escape time for the current (or most recent) raid, in minutes /// public static int OriginalEscapeTimeMinutes { get; private set; } = int.MaxValue; /// /// The original escape time for the current (or most recent) raid, in seconds /// public static int OriginalEscapeTimeSeconds => OriginalEscapeTimeMinutes * 60; /// /// The updated escape time for the current (or most recent) raid, in minutes /// public static int NewEscapeTimeMinutes { get; private set; } = int.MaxValue; /// /// The updated escape time for the current (or most recent) raid, in seconds /// public static int NewEscapeTimeSeconds => NewEscapeTimeMinutes * 60; /// /// The reduction in the escape time for the current (or most recent) raid, in minutes /// public static int RaidTimeReductionMinutes => OriginalEscapeTimeMinutes - NewEscapeTimeMinutes; /// /// The reduction in the escape time for the current (or most recent) raid, in seconds /// public static int RaidTimeReductionSeconds => RaidTimeReductionMinutes * 60; /// /// The fraction of raid time that will be remaining when you spawn into the map /// public static float RaidTimeRemainingFraction => (float)NewEscapeTimeMinutes / OriginalEscapeTimeMinutes; /// /// The original minimum time (in seconds) you must stay in the raid to get a "Survived" status (unless your XP is high enough) for the current (or most recent) raid /// public static int OriginalSurvivalTimeSeconds { get; private set; } = int.MaxValue; /// /// The updated minimum time (in seconds) you must stay in the raid to get a "Survived" status (unless your XP is high enough) for the current (or most recent) raid /// public static int NewSurvivalTimeSeconds { get; private set; } = int.MaxValue; /// /// The reduction in the minimum time you must stay in the raid to get a "Survived" status (unless your XP is high enough) for the current (or most recent) raid /// public static int SurvivalTimeReductionSeconds => OriginalSurvivalTimeSeconds - NewSurvivalTimeSeconds; /// /// Update the changes that will be made for the raid. This should be called just before applying changes. /// /// The raid settings for the raid that will be altered /// The changes that will be made to the raid internal static void UpdateRaidChanges(RaidSettings raidSettings, RaidTimeResponse raidChanges) { // Reset so HaveChangesBeenApplied=false while changes are being applied RaidChangesAppliedUtcTime = DateTime.MinValue; IsScavRaid = raidSettings.IsScav; LocationId = raidSettings.SelectedLocation.Id; OriginalEscapeTimeMinutes = raidSettings.SelectedLocation.EscapeTimeLimit; NewEscapeTimeMinutes = raidChanges.RaidTimeMinutes; OriginalSurvivalTimeSeconds = raidChanges.OriginalSurvivalTimeSeconds; NewSurvivalTimeSeconds = raidChanges.NewSurviveTimeSeconds ?? OriginalSurvivalTimeSeconds; } /// /// This should be called just after all raid changes have been completed /// internal static void ConfirmRaidChanges() { // This will also set HaveChangesBeenApplied=true RaidChangesAppliedUtcTime = DateTime.UtcNow; } } }