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);
|
var ev = new BeingMicrowavedEvent(uid, user);
|
||||||
RaiseLocalEvent(item, ev);
|
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)
|
if (ev.Handled)
|
||||||
{
|
{
|
||||||
UpdateUserInterfaceState(uid, component);
|
UpdateUserInterfaceState(uid, component);
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ namespace Content.Server.Nuke
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Default bomb timer value in seconds.
|
/// Default bomb timer value in seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("timer")]
|
[DataField]
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
|
||||||
public int Timer = 300;
|
public int Timer = 300;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -36,7 +35,7 @@ namespace Content.Server.Nuke
|
|||||||
/// How long until the bomb can arm again after deactivation.
|
/// How long until the bomb can arm again after deactivation.
|
||||||
/// Used to prevent announcements spam.
|
/// Used to prevent announcements spam.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("cooldown")]
|
[DataField]
|
||||||
public int Cooldown = 30;
|
public int Cooldown = 30;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -143,32 +142,32 @@ namespace Content.Server.Nuke
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public (MapId, EntityUid?)? OriginMapGrid;
|
public (MapId, EntityUid?)? OriginMapGrid;
|
||||||
|
|
||||||
[DataField("codeLength")] public int CodeLength = 6;
|
[DataField] public int CodeLength = 6;
|
||||||
[ViewVariables] public string Code = string.Empty;
|
[DataField] public string Code = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time until explosion in seconds.
|
/// Time until explosion in seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[DataField]
|
||||||
public float RemainingTime;
|
public float RemainingTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Time until bomb cooldown will expire in seconds.
|
/// Time until bomb cooldown will expire in seconds.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public float CooldownTime;
|
public float CooldownTime;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current nuclear code buffer. Entered manually by players.
|
/// Current nuclear code buffer. Entered manually by players.
|
||||||
/// If valid it will allow arm/disarm bomb.
|
/// If valid it will allow arm/disarm bomb.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public string EnteredCode = "";
|
public string EnteredCode = "";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Current status of a nuclear bomb.
|
/// Current status of a nuclear bomb.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables]
|
[DataField]
|
||||||
public NukeStatus Status = NukeStatus.AWAIT_DISK;
|
public NukeStatus Status = NukeStatus.AWAIT_DISK;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using Content.Server.AlertLevel;
|
|||||||
using Content.Server.Audio;
|
using Content.Server.Audio;
|
||||||
using Content.Server.Chat.Systems;
|
using Content.Server.Chat.Systems;
|
||||||
using Content.Server.Explosion.EntitySystems;
|
using Content.Server.Explosion.EntitySystems;
|
||||||
|
using Content.Server.Kitchen.Components;
|
||||||
using Content.Server.Pinpointer;
|
using Content.Server.Pinpointer;
|
||||||
using Content.Server.Popups;
|
using Content.Server.Popups;
|
||||||
using Content.Server.Station.Systems;
|
using Content.Server.Station.Systems;
|
||||||
@@ -79,11 +80,12 @@ public sealed class NukeSystem : EntitySystem
|
|||||||
|
|
||||||
// Doafter events
|
// Doafter events
|
||||||
SubscribeLocalEvent<NukeComponent, NukeDisarmDoAfterEvent>(OnDoAfter);
|
SubscribeLocalEvent<NukeComponent, NukeDisarmDoAfterEvent>(OnDoAfter);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<NukeDiskComponent, BeingMicrowavedEvent>(OnMicrowaved);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInit(EntityUid uid, NukeComponent component, ComponentInit args)
|
private void OnInit(EntityUid uid, NukeComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
component.RemainingTime = component.Timer;
|
|
||||||
_itemSlots.AddItemSlot(uid, SharedNukeComponent.NukeDiskSlotId, component.DiskSlot);
|
_itemSlots.AddItemSlot(uid, SharedNukeComponent.NukeDiskSlotId, component.DiskSlot);
|
||||||
|
|
||||||
UpdateStatus(uid, component);
|
UpdateStatus(uid, component);
|
||||||
@@ -111,11 +113,13 @@ public sealed class NukeSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnMapInit(EntityUid uid, NukeComponent nuke, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, NukeComponent nuke, MapInitEvent args)
|
||||||
{
|
{
|
||||||
|
nuke.RemainingTime = nuke.Timer;
|
||||||
var originStation = _station.GetOwningStation(uid);
|
var originStation = _station.GetOwningStation(uid);
|
||||||
|
|
||||||
if (originStation != null)
|
if (originStation != null)
|
||||||
|
{
|
||||||
nuke.OriginStation = originStation;
|
nuke.OriginStation = originStation;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var transform = Transform(uid);
|
var transform = Transform(uid);
|
||||||
@@ -125,6 +129,19 @@ public sealed class NukeSystem : EntitySystem
|
|||||||
nuke.Code = GenerateRandomNumberString(nuke.CodeLength);
|
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)
|
private void OnRemove(EntityUid uid, NukeComponent component, ComponentRemove args)
|
||||||
{
|
{
|
||||||
_itemSlots.RemoveItemSlot(uid, component.DiskSlot);
|
_itemSlots.RemoveItemSlot(uid, component.DiskSlot);
|
||||||
@@ -346,11 +363,11 @@ public sealed class NukeSystem : EntitySystem
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// var isValid = _codes.IsCodeValid(uid, component.EnteredCode);
|
|
||||||
if (component.EnteredCode == component.Code)
|
if (component.EnteredCode == component.Code)
|
||||||
{
|
{
|
||||||
component.Status = NukeStatus.AWAIT_ARM;
|
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);
|
_audio.PlayPvs(component.AccessGrantedSound, uid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -8,5 +8,16 @@ namespace Content.Shared.Nuke;
|
|||||||
[RegisterComponent, NetworkedComponent]
|
[RegisterComponent, NetworkedComponent]
|
||||||
public sealed partial class NukeDiskComponent : Component
|
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-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-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 UI
|
||||||
nuke-user-interface-title = Nuclear Fission Explosive
|
nuke-user-interface-title = Nuclear Fission Explosive
|
||||||
nuke-user-interface-arm-button = ARM
|
nuke-user-interface-arm-button = ARM
|
||||||
|
|||||||
Reference in New Issue
Block a user