Add microwave-nukedisk interaction (#36114)
* Add microwave-nukedisk interaction * popup * Fix UninitializedSaveTest
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -21,8 +21,7 @@ namespace Content.Server.Nuke
|
||||
/// <summary>
|
||||
/// Default bomb timer value in seconds.
|
||||
/// </summary>
|
||||
[DataField("timer")]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public int Timer = 300;
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +35,7 @@ namespace Content.Server.Nuke
|
||||
/// How long until the bomb can arm again after deactivation.
|
||||
/// Used to prevent announcements spam.
|
||||
/// </summary>
|
||||
[DataField("cooldown")]
|
||||
[DataField]
|
||||
public int Cooldown = 30;
|
||||
|
||||
/// <summary>
|
||||
@@ -143,32 +142,32 @@ namespace Content.Server.Nuke
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Time until explosion in seconds.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
public float RemainingTime;
|
||||
|
||||
/// <summary>
|
||||
/// Time until bomb cooldown will expire in seconds.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField]
|
||||
public float CooldownTime;
|
||||
|
||||
/// <summary>
|
||||
/// Current nuclear code buffer. Entered manually by players.
|
||||
/// If valid it will allow arm/disarm bomb.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField]
|
||||
public string EnteredCode = "";
|
||||
|
||||
/// <summary>
|
||||
/// Current status of a nuclear bomb.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField]
|
||||
public NukeStatus Status = NukeStatus.AWAIT_DISK;
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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<NukeComponent, NukeDisarmDoAfterEvent>(OnDoAfter);
|
||||
|
||||
SubscribeLocalEvent<NukeDiskComponent, BeingMicrowavedEvent>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Slightly randomize nuke countdown timer
|
||||
/// </summary>
|
||||
private void OnMicrowaved(Entity<NukeDiskComponent> 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<NukeDiskComponent>(component.DiskSlot.Item)?.TimeModifier ?? TimeSpan.Zero;
|
||||
component.RemainingTime = MathF.Max(component.Timer + (float)modifier.TotalSeconds, component.MinimumTime);
|
||||
_audio.PlayPvs(component.AccessGrantedSound, uid);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -8,5 +8,16 @@ namespace Content.Shared.Nuke;
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class NukeDiskComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Used to modify the nuke's countdown timer.
|
||||
/// </summary>
|
||||
[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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user