diff --git a/EXILED/Exiled.API/Enums/WarheadStatus.cs b/EXILED/Exiled.API/Enums/WarheadStatus.cs
index e839c0b8d..ed6f7d5a6 100644
--- a/EXILED/Exiled.API/Enums/WarheadStatus.cs
+++ b/EXILED/Exiled.API/Enums/WarheadStatus.cs
@@ -7,30 +7,38 @@
namespace Exiled.API.Enums
{
+ using System;
+
///
/// All the available warhead statuses.
///
///
+ [Flags]
public enum WarheadStatus
{
///
/// The warhead is not armed.
///
- NotArmed,
+ NotArmed = 0,
///
/// The warhead is armed.
///
- Armed,
+ Armed = 1,
///
/// The warhead detonation is in progress.
///
- InProgress,
+ InProgress = 2,
///
/// The warhead has detonated.
///
- Detonated,
+ Detonated = 4,
+
+ ///
+ /// The warhead is on cooldown.
+ ///
+ OnCooldown = 8,
}
}
\ No newline at end of file
diff --git a/EXILED/Exiled.API/Features/Warhead.cs b/EXILED/Exiled.API/Features/Warhead.cs
index f26157777..ac96d4f8e 100644
--- a/EXILED/Exiled.API/Features/Warhead.cs
+++ b/EXILED/Exiled.API/Features/Warhead.cs
@@ -7,12 +7,13 @@
namespace Exiled.API.Features
{
+ using System;
using System.Collections.Generic;
using Enums;
+ using Exiled.API.Extensions;
using Interactables.Interobjects.DoorUtils;
using Mirror;
-
using UnityEngine;
///
@@ -69,6 +70,15 @@ public static bool OpenDoors
set => Controller._openDoors = value;
}
+ ///
+ /// Gets or sets the remaining cooldown before the nuke can be triggered again.
+ ///
+ public static double RemainingCooldown
+ {
+ get => Math.Max(0, Controller.NetworkCooldownEndTime - NetworkTime.time);
+ set => Controller.NetworkCooldownEndTime = NetworkTime.time + Math.Max(0, value);
+ }
+
///
/// Gets all of the warhead blast doors.
///
@@ -97,25 +107,39 @@ public static bool IsKeycardActivated
///
public static WarheadStatus Status
{
- get => IsInProgress ? IsDetonated ? WarheadStatus.Detonated : WarheadStatus.InProgress : LeverStatus ? WarheadStatus.Armed : WarheadStatus.NotArmed;
+ get
+ {
+ WarheadStatus status = WarheadStatus.NotArmed;
+
+ if (IsDetonated)
+ status |= WarheadStatus.Detonated;
+
+ if (IsInProgress)
+ status |= WarheadStatus.InProgress;
+
+ if (IsOnCooldown)
+ status |= WarheadStatus.OnCooldown;
+
+ if (LeverStatus)
+ status |= WarheadStatus.Armed;
+
+ return status;
+ }
+
set
{
- switch (value)
- {
- case WarheadStatus.NotArmed:
- case WarheadStatus.Armed:
- Stop();
- LeverStatus = value is WarheadStatus.Armed;
- break;
-
- case WarheadStatus.InProgress:
- Start();
- break;
-
- case WarheadStatus.Detonated:
- Detonate();
- break;
- }
+ LeverStatus = value.HasFlagFast(WarheadStatus.Armed);
+
+ if (value.HasFlagFast(WarheadStatus.InProgress))
+ Start();
+ else
+ Stop();
+
+ if (value.HasFlagFast(WarheadStatus.Detonated))
+ Detonate();
+
+ if (value.HasFlagFast(WarheadStatus.OnCooldown))
+ RemainingCooldown = Controller._cooldown;
}
}
@@ -129,6 +153,11 @@ public static WarheadStatus Status
///
public static bool IsInProgress => Controller.Info.InProgress;
+ ///
+ /// Gets a value indicating whether the warhead detonation is on cooldown.
+ ///
+ public static bool IsOnCooldown => RemainingCooldown > 0;
+
///
/// Gets or sets the warhead detonation timer.
///
@@ -164,7 +193,7 @@ public static int Kills
///
/// Gets a value indicating whether the warhead can be started.
///
- public static bool CanBeStarted => !IsInProgress && !IsDetonated && Controller.CooldownEndTime <= NetworkTime.time;
+ public static bool CanBeStarted => !IsInProgress && !IsDetonated && !IsOnCooldown;
///
/// Closes the surface blast doors.