Fix adding/removing airlock protections via welding (#19926)

This commit is contained in:
chromiumboy
2023-09-14 00:54:49 -05:00
committed by GitHub
parent 4c25483693
commit 3753fed920
8 changed files with 74 additions and 31 deletions

View File

@@ -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<WiresPanelComponent>(uid, out var panel) && panel.Open && panel.WiresAccessible
&& TryComp<ActorComponent>(args.User, out var actor))
if (TryComp<WiresPanelComponent>(uid, out var panel) &&
panel.Open &&
_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(panel.CurrentSecurityLevelID, out var securityLevelPrototype) &&
securityLevelPrototype.WiresAccessible &&
TryComp<ActorComponent>(args.User, out var actor))
{
_wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
args.Handled = true;

View File

@@ -59,7 +59,6 @@ public sealed class WiresSystem : SharedWiresSystem
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(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<ToolComponent>(args.Used, out var tool) || !TryComp<WiresPanelComponent>(uid, out var panel))
return;
if (panel.Open && panel.WiresAccessible &&
if (panel.Open &&
_protoMan.TryIndex<WiresPanelSecurityLevelPrototype>(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<WiresPanelSecurityLevelPrototype>(wiresPanelSecurityLevelID);
component.CurrentSecurityLevelID = wiresPanelSecurityLevelID;
Dirty(uid, component);
if (wiresPanelSecurityLevelPrototype == null)
return;
component.WiresAccessible = wiresPanelSecurityLevelPrototype.WiresAccessible;
component.WiresPanelSecurityExamination = wiresPanelSecurityLevelPrototype.Examine;
Dirty(component);
if (wiresPanelSecurityLevelPrototype?.WiresAccessible == false)
if (_protoMan.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
securityLevelPrototype.WiresAccessible)
{
_uiSystem.TryCloseAll(uid, WiresUiKey.Key);
}