From: chromiumboy <50505512+chromiumboy@users.noreply.github.com> Date: Thu, 14 Sep 2023 05:54:49 +0000 (-0500) Subject: Fix adding/removing airlock protections via welding (#19926) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=3753fed920125317b8566566508e5762db55db97;p=space-station-14.git Fix adding/removing airlock protections via welding (#19926) --- diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs index f07dd23f4b..bb75fc7d47 100644 --- a/Content.Server/Doors/Systems/AirlockSystem.cs +++ b/Content.Server/Doors/Systems/AirlockSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Doors.Systems; using Content.Shared.Interaction; using Robust.Server.GameObjects; using Content.Shared.Wires; +using Robust.Shared.Prototypes; namespace Content.Server.Doors.Systems; @@ -17,6 +18,7 @@ public sealed class AirlockSystem : SharedAirlockSystem [Dependency] private readonly WiresSystem _wiresSystem = default!; [Dependency] private readonly PowerReceiverSystem _power = default!; [Dependency] private readonly DoorBoltSystem _bolts = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; public override void Initialize() { @@ -149,8 +151,11 @@ public sealed class AirlockSystem : SharedAirlockSystem private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args) { - if (TryComp(uid, out var panel) && panel.Open && panel.WiresAccessible - && TryComp(args.User, out var actor)) + if (TryComp(uid, out var panel) && + panel.Open && + _prototypeManager.TryIndex(panel.CurrentSecurityLevelID, out var securityLevelPrototype) && + securityLevelPrototype.WiresAccessible && + TryComp(args.User, out var actor)) { _wiresSystem.OpenUserInterface(uid, actor.PlayerSession); args.Handled = true; diff --git a/Content.Server/Wires/WiresSystem.cs b/Content.Server/Wires/WiresSystem.cs index 0baf0c5c22..e9522485ca 100644 --- a/Content.Server/Wires/WiresSystem.cs +++ b/Content.Server/Wires/WiresSystem.cs @@ -59,7 +59,6 @@ public sealed class WiresSystem : SharedWiresSystem SubscribeLocalEvent(OnAttemptOpenActivatableUI); SubscribeLocalEvent(OnActivatableUIPanelChanged); } - private void SetOrCreateWireLayout(EntityUid uid, WiresComponent? wires = null) { if (!Resolve(uid, ref wires)) @@ -459,7 +458,9 @@ public sealed class WiresSystem : SharedWiresSystem if (!TryComp(args.Used, out var tool) || !TryComp(uid, out var panel)) return; - if (panel.Open && panel.WiresAccessible && + if (panel.Open && + _protoMan.TryIndex(panel.CurrentSecurityLevelID, out var securityLevelPrototype) && + securityLevelPrototype.WiresAccessible && (_toolSystem.HasQuality(args.Used, "Cutting", tool) || _toolSystem.HasQuality(args.Used, "Pulsing", tool))) { @@ -642,14 +643,14 @@ public sealed class WiresSystem : SharedWiresSystem { component.Visible = visible; UpdateAppearance(uid, component); - Dirty(component); + Dirty(uid, component); } public void TogglePanel(EntityUid uid, WiresPanelComponent component, bool open) { component.Open = open; UpdateAppearance(uid, component); - Dirty(component); + Dirty(uid, component); var ev = new PanelChangedEvent(component.Open); RaiseLocalEvent(uid, ref ev); @@ -657,16 +658,11 @@ public sealed class WiresSystem : SharedWiresSystem public void SetWiresPanelSecurityData(EntityUid uid, WiresPanelComponent component, string wiresPanelSecurityLevelID) { - var wiresPanelSecurityLevelPrototype = _protoMan.Index(wiresPanelSecurityLevelID); - - if (wiresPanelSecurityLevelPrototype == null) - return; - - component.WiresAccessible = wiresPanelSecurityLevelPrototype.WiresAccessible; - component.WiresPanelSecurityExamination = wiresPanelSecurityLevelPrototype.Examine; - Dirty(component); + component.CurrentSecurityLevelID = wiresPanelSecurityLevelID; + Dirty(uid, component); - if (wiresPanelSecurityLevelPrototype?.WiresAccessible == false) + if (_protoMan.TryIndex(component.CurrentSecurityLevelID, out var securityLevelPrototype) && + securityLevelPrototype.WiresAccessible) { _uiSystem.TryCloseAll(uid, WiresUiKey.Key); } diff --git a/Content.Shared/Tools/Systems/WeldableSystem.cs b/Content.Shared/Tools/Systems/WeldableSystem.cs index 11ead6bba1..f887ed3049 100644 --- a/Content.Shared/Tools/Systems/WeldableSystem.cs +++ b/Content.Shared/Tools/Systems/WeldableSystem.cs @@ -41,16 +41,6 @@ public sealed class WeldableSystem : EntitySystem private void OnInteractUsing(EntityUid uid, WeldableComponent component, InteractUsingEvent args) { - // If any construction graph edges has its conditions meet and requires welding, then this construction takes priority - /* TODO: Whatever this is is not the way to do what you think you want to do. - if (Enumerable.Any(_construction.GetCurrentNode(uid)?.Edges, x => _construction.CheckConditions(uid, x.Conditions) - && Enumerable.Any(x.Steps, y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true) - { - args.Handled = false; - return; - } - */ - if (args.Handled) return; diff --git a/Content.Shared/Wires/SharedWiresSystem.cs b/Content.Shared/Wires/SharedWiresSystem.cs index 78cb298070..055827e8b1 100644 --- a/Content.Shared/Wires/SharedWiresSystem.cs +++ b/Content.Shared/Wires/SharedWiresSystem.cs @@ -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(OnExamine); + SubscribeLocalEvent(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(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(component.CurrentSecurityLevelID, out var securityLevelPrototype) && + !securityLevelPrototype.WeldingAllowed) + { + args.Cancel(); + } + } } diff --git a/Content.Shared/Wires/WiresPanelComponent.cs b/Content.Shared/Wires/WiresPanelComponent.cs index db7d018625..adc9d9a5f0 100644 --- a/Content.Shared/Wires/WiresPanelComponent.cs +++ b/Content.Shared/Wires/WiresPanelComponent.cs @@ -28,11 +28,13 @@ public sealed partial class WiresPanelComponent : Component [DataField("screwdriverCloseSound")] public SoundSpecifier ScrewdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg"); + /// + /// This prototype describes the current security features of the wire panel + /// + [DataField("securityLevel")] + [ValidatePrototypeId] [AutoNetworkedField] - public string? WiresPanelSecurityExamination = default!; - - [AutoNetworkedField] - public bool WiresAccessible = true; + public string CurrentSecurityLevelID = "Level0"; } /// diff --git a/Content.Shared/Wires/WiresPanelSecurityLevelPrototype.cs b/Content.Shared/Wires/WiresPanelSecurityLevelPrototype.cs index f5a72a66d7..8ddc8eeab8 100644 --- a/Content.Shared/Wires/WiresPanelSecurityLevelPrototype.cs +++ b/Content.Shared/Wires/WiresPanelSecurityLevelPrototype.cs @@ -8,9 +8,24 @@ public sealed class WiresPanelSecurityLevelPrototype : IPrototype [IdDataField] public string ID { get; private set; } = default!; + /// + /// A verbal description of the wire panel's current security level + /// [DataField("examine")] public string? Examine = default!; + /// + /// Determines whether the wiring is accessible to hackers or not + /// [DataField("wiresAccessible")] public bool WiresAccessible = true; + + /// + /// Determines whether the device can be welded shut or not + /// + /// + /// Should be set false when you need to weld/unweld something to/from the wire panel + /// + [DataField("weldingAllowed")] + public bool WeldingAllowed = true; } diff --git a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml index e729cbe6f9..0d77c8b986 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/Airlocks/airlocks.yml @@ -21,6 +21,8 @@ components: - type: Sprite sprite: Structures/Doors/Airlocks/Standard/atmospherics.rsi + - type: WiresPanel + securityLevel: Level2 - type: Construction node: airlockMedSecurity @@ -71,6 +73,8 @@ components: - type: Sprite sprite: Structures/Doors/Airlocks/Standard/command.rsi + - type: WiresPanel + securityLevel: Level5 - type: Construction node: airlockMaxSecurity @@ -81,6 +85,8 @@ components: - type: Sprite sprite: Structures/Doors/Airlocks/Standard/security.rsi + - type: WiresPanel + securityLevel: Level2 - type: Construction node: airlockMedSecurity @@ -170,6 +176,8 @@ sprite: Structures/Doors/Airlocks/Glass/atmospherics.rsi - type: PaintableAirlock group: Glass + - type: WiresPanel + securityLevel: Level2 - type: Construction node: glassAirlockMedSecurity @@ -222,6 +230,8 @@ sprite: Structures/Doors/Airlocks/Glass/command.rsi - type: PaintableAirlock group: Glass + - type: WiresPanel + securityLevel: Level5 - type: Construction node: glassAirlockMaxSecurity @@ -234,6 +244,8 @@ sprite: Structures/Doors/Airlocks/Glass/security.rsi - type: PaintableAirlock group: Glass + - type: WiresPanel + securityLevel: Level2 - type: Construction node: glassAirlockMedSecurity diff --git a/Resources/Prototypes/Entities/Structures/Doors/wires_panel_security.yml b/Resources/Prototypes/Entities/Structures/Doors/wires_panel_security.yml index fb5b762662..4a42ed36ad 100644 --- a/Resources/Prototypes/Entities/Structures/Doors/wires_panel_security.yml +++ b/Resources/Prototypes/Entities/Structures/Doors/wires_panel_security.yml @@ -6,21 +6,25 @@ id: Level1 examine: wires-panel-component-on-examine-security-level1 wiresAccessible: false + weldingAllowed: false - type: WiresPanelSecurityLevel id: Level2 examine: wires-panel-component-on-examine-security-level2 wiresAccessible: false + weldingAllowed: false - type: WiresPanelSecurityLevel id: Level3 examine: wires-panel-component-on-examine-security-level3 wiresAccessible: false + weldingAllowed: false - type: WiresPanelSecurityLevel id: Level4 examine: wires-panel-component-on-examine-security-level4 wiresAccessible: false + weldingAllowed: false - type: WiresPanelSecurityLevel id: Level5 @@ -31,9 +35,11 @@ id: Level6 examine: wires-panel-component-on-examine-security-level6 wiresAccessible: false + weldingAllowed: false - type: WiresPanelSecurityLevel id: Level7 examine: wires-panel-component-on-examine-security-level7 wiresAccessible: false + weldingAllowed: false \ No newline at end of file