diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
index f0bd0c2127..6d36f7457b 100644
--- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
+++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
@@ -547,6 +547,10 @@ namespace Content.Server.Kitchen.EntitySystems
var ev = new BeingMicrowavedEvent(uid, user);
RaiseLocalEvent(item, ev);
+ // TODO MICROWAVE SPARKS & EFFECTS
+ // Various microwaveable entities should probably spawn a spark, play a sound, and generate a pop=up.
+ // This should probably be handled by the microwave system, with fields in BeingMicrowavedEvent.
+
if (ev.Handled)
{
UpdateUserInterfaceState(uid, component);
diff --git a/Content.Server/Nuke/NukeComponent.cs b/Content.Server/Nuke/NukeComponent.cs
index e1a117f4bd..b14ad9c165 100644
--- a/Content.Server/Nuke/NukeComponent.cs
+++ b/Content.Server/Nuke/NukeComponent.cs
@@ -21,8 +21,7 @@ namespace Content.Server.Nuke
///
/// Default bomb timer value in seconds.
///
- [DataField("timer")]
- [ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public int Timer = 300;
///
@@ -36,7 +35,7 @@ namespace Content.Server.Nuke
/// How long until the bomb can arm again after deactivation.
/// Used to prevent announcements spam.
///
- [DataField("cooldown")]
+ [DataField]
public int Cooldown = 30;
///
@@ -143,32 +142,32 @@ namespace Content.Server.Nuke
///
public (MapId, EntityUid?)? OriginMapGrid;
- [DataField("codeLength")] public int CodeLength = 6;
- [ViewVariables] public string Code = string.Empty;
+ [DataField] public int CodeLength = 6;
+ [DataField] public string Code = string.Empty;
///
/// Time until explosion in seconds.
///
- [ViewVariables(VVAccess.ReadWrite)]
+ [DataField]
public float RemainingTime;
///
/// Time until bomb cooldown will expire in seconds.
///
- [ViewVariables]
+ [DataField]
public float CooldownTime;
///
/// Current nuclear code buffer. Entered manually by players.
/// If valid it will allow arm/disarm bomb.
///
- [ViewVariables]
+ [DataField]
public string EnteredCode = "";
///
/// Current status of a nuclear bomb.
///
- [ViewVariables]
+ [DataField]
public NukeStatus Status = NukeStatus.AWAIT_DISK;
///
diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs
index aa1fe32401..77be71f7bc 100644
--- a/Content.Server/Nuke/NukeSystem.cs
+++ b/Content.Server/Nuke/NukeSystem.cs
@@ -2,6 +2,7 @@ using Content.Server.AlertLevel;
using Content.Server.Audio;
using Content.Server.Chat.Systems;
using Content.Server.Explosion.EntitySystems;
+using Content.Server.Kitchen.Components;
using Content.Server.Pinpointer;
using Content.Server.Popups;
using Content.Server.Station.Systems;
@@ -79,11 +80,12 @@ public sealed class NukeSystem : EntitySystem
// Doafter events
SubscribeLocalEvent(OnDoAfter);
+
+ SubscribeLocalEvent(OnMicrowaved);
}
private void OnInit(EntityUid uid, NukeComponent component, ComponentInit args)
{
- component.RemainingTime = component.Timer;
_itemSlots.AddItemSlot(uid, SharedNukeComponent.NukeDiskSlotId, component.DiskSlot);
UpdateStatus(uid, component);
@@ -111,11 +113,13 @@ public sealed class NukeSystem : EntitySystem
private void OnMapInit(EntityUid uid, NukeComponent nuke, MapInitEvent args)
{
+ nuke.RemainingTime = nuke.Timer;
var originStation = _station.GetOwningStation(uid);
if (originStation != null)
+ {
nuke.OriginStation = originStation;
-
+ }
else
{
var transform = Transform(uid);
@@ -125,6 +129,19 @@ public sealed class NukeSystem : EntitySystem
nuke.Code = GenerateRandomNumberString(nuke.CodeLength);
}
+ ///
+ /// Slightly randomize nuke countdown timer
+ ///
+ private void OnMicrowaved(Entity ent, ref BeingMicrowavedEvent args)
+ {
+ if (ent.Comp.TimeModifier != null)
+ return;
+
+ var seconds = _random.NextGaussian(ent.Comp.MicrowaveMean.TotalSeconds, ent.Comp.MicrowaveStd.TotalSeconds);
+ ent.Comp.TimeModifier = TimeSpan.FromSeconds(seconds);
+ _popups.PopupEntity(Loc.GetString("nuke-disk-component-microwave"), ent.Owner, PopupType.Medium);
+ }
+
private void OnRemove(EntityUid uid, NukeComponent component, ComponentRemove args)
{
_itemSlots.RemoveItemSlot(uid, component.DiskSlot);
@@ -346,11 +363,11 @@ public sealed class NukeSystem : EntitySystem
break;
}
- // var isValid = _codes.IsCodeValid(uid, component.EnteredCode);
if (component.EnteredCode == component.Code)
{
component.Status = NukeStatus.AWAIT_ARM;
- component.RemainingTime = component.Timer;
+ var modifier = CompOrNull(component.DiskSlot.Item)?.TimeModifier ?? TimeSpan.Zero;
+ component.RemainingTime = MathF.Max(component.Timer + (float)modifier.TotalSeconds, component.MinimumTime);
_audio.PlayPvs(component.AccessGrantedSound, uid);
}
else
diff --git a/Content.Shared/Nuke/NukeDiskComponent.cs b/Content.Shared/Nuke/NukeDiskComponent.cs
index 2f99d68918..8185b15f31 100644
--- a/Content.Shared/Nuke/NukeDiskComponent.cs
+++ b/Content.Shared/Nuke/NukeDiskComponent.cs
@@ -8,5 +8,16 @@ namespace Content.Shared.Nuke;
[RegisterComponent, NetworkedComponent]
public sealed partial class NukeDiskComponent : Component
{
+ ///
+ /// Used to modify the nuke's countdown timer.
+ ///
+ [DataField]
+ public TimeSpan? TimeModifier;
+ [DataField]
+ public TimeSpan MicrowaveMean = TimeSpan.Zero;
+
+ [DataField]
+ public TimeSpan MicrowaveStd = TimeSpan.FromSeconds(27.35);
+ // STD of 27.36s means theres an 90% chance the time is between +-45s, and a ~99% chance its between +-70s
}
diff --git a/Resources/Locale/en-US/nuke/nuke-component.ftl b/Resources/Locale/en-US/nuke/nuke-component.ftl
index dfd56347ca..64c67e2e04 100644
--- a/Resources/Locale/en-US/nuke/nuke-component.ftl
+++ b/Resources/Locale/en-US/nuke/nuke-component.ftl
@@ -6,6 +6,8 @@ nuke-component-announcement-unarmed = The station's self-destruct was deactivate
nuke-component-announcement-send-codes = Attention! Self-destruction codes have been sent to designated fax machines.
nuke-component-doafter-warning = You start fiddling with wires and knobs in order to disarm the nuke.. This may take a while.
+nuke-disk-component-microwave = The disk sparks and fizzles a bit, but seems mostly unharmed?
+
# Nuke UI
nuke-user-interface-title = Nuclear Fission Explosive
nuke-user-interface-arm-button = ARM