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

@@ -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);
}