Fix adding/removing airlock protections via welding (#19926)
This commit is contained in:
@@ -1,13 +1,19 @@
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Tools.Systems;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Wires;
|
||||
|
||||
public abstract class SharedWiresSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<WiresPanelComponent, WeldableAttemptEvent>(OnWeldableAttempt);
|
||||
}
|
||||
|
||||
private void OnExamine(EntityUid uid, WiresPanelComponent component, ExaminedEvent args)
|
||||
@@ -20,10 +26,21 @@ public abstract class SharedWiresSystem : EntitySystem
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("wires-panel-component-on-examine-open"));
|
||||
|
||||
if (component?.WiresPanelSecurityExamination != null)
|
||||
if (_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
|
||||
securityLevelPrototype.Examine != null)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString(component.WiresPanelSecurityExamination));
|
||||
args.PushMarkup(Loc.GetString(securityLevelPrototype.Examine));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnWeldableAttempt(EntityUid uid, WiresPanelComponent component, WeldableAttemptEvent args)
|
||||
{
|
||||
if (component.Open &&
|
||||
_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
|
||||
!securityLevelPrototype.WeldingAllowed)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,13 @@ public sealed partial class WiresPanelComponent : Component
|
||||
[DataField("screwdriverCloseSound")]
|
||||
public SoundSpecifier ScrewdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg");
|
||||
|
||||
/// <summary>
|
||||
/// This prototype describes the current security features of the wire panel
|
||||
/// </summary>
|
||||
[DataField("securityLevel")]
|
||||
[ValidatePrototypeId<WiresPanelSecurityLevelPrototype>]
|
||||
[AutoNetworkedField]
|
||||
public string? WiresPanelSecurityExamination = default!;
|
||||
|
||||
[AutoNetworkedField]
|
||||
public bool WiresAccessible = true;
|
||||
public string CurrentSecurityLevelID = "Level0";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -8,9 +8,24 @@ public sealed class WiresPanelSecurityLevelPrototype : IPrototype
|
||||
[IdDataField]
|
||||
public string ID { get; private set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// A verbal description of the wire panel's current security level
|
||||
/// </summary>
|
||||
[DataField("examine")]
|
||||
public string? Examine = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the wiring is accessible to hackers or not
|
||||
/// </summary>
|
||||
[DataField("wiresAccessible")]
|
||||
public bool WiresAccessible = true;
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the device can be welded shut or not
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Should be set false when you need to weld/unweld something to/from the wire panel
|
||||
/// </remarks>
|
||||
[DataField("weldingAllowed")]
|
||||
public bool WeldingAllowed = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user