Fix adding/removing airlock protections via welding (#19926)
This commit is contained in:
@@ -9,6 +9,7 @@ using Content.Shared.Doors.Systems;
|
|||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Content.Shared.Wires;
|
using Content.Shared.Wires;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.Doors.Systems;
|
namespace Content.Server.Doors.Systems;
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ public sealed class AirlockSystem : SharedAirlockSystem
|
|||||||
[Dependency] private readonly WiresSystem _wiresSystem = default!;
|
[Dependency] private readonly WiresSystem _wiresSystem = default!;
|
||||||
[Dependency] private readonly PowerReceiverSystem _power = default!;
|
[Dependency] private readonly PowerReceiverSystem _power = default!;
|
||||||
[Dependency] private readonly DoorBoltSystem _bolts = default!;
|
[Dependency] private readonly DoorBoltSystem _bolts = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -149,8 +151,11 @@ public sealed class AirlockSystem : SharedAirlockSystem
|
|||||||
|
|
||||||
private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
|
private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
|
||||||
{
|
{
|
||||||
if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open && panel.WiresAccessible
|
if (TryComp<WiresPanelComponent>(uid, out var panel) &&
|
||||||
&& TryComp<ActorComponent>(args.User, out var actor))
|
panel.Open &&
|
||||||
|
_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(panel.CurrentSecurityLevelID, out var securityLevelPrototype) &&
|
||||||
|
securityLevelPrototype.WiresAccessible &&
|
||||||
|
TryComp<ActorComponent>(args.User, out var actor))
|
||||||
{
|
{
|
||||||
_wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
|
_wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ public sealed class WiresSystem : SharedWiresSystem
|
|||||||
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
|
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
|
||||||
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(OnActivatableUIPanelChanged);
|
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(OnActivatableUIPanelChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetOrCreateWireLayout(EntityUid uid, WiresComponent? wires = null)
|
private void SetOrCreateWireLayout(EntityUid uid, WiresComponent? wires = null)
|
||||||
{
|
{
|
||||||
if (!Resolve(uid, ref wires))
|
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))
|
if (!TryComp<ToolComponent>(args.Used, out var tool) || !TryComp<WiresPanelComponent>(uid, out var panel))
|
||||||
return;
|
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, "Cutting", tool) ||
|
||||||
_toolSystem.HasQuality(args.Used, "Pulsing", tool)))
|
_toolSystem.HasQuality(args.Used, "Pulsing", tool)))
|
||||||
{
|
{
|
||||||
@@ -642,14 +643,14 @@ public sealed class WiresSystem : SharedWiresSystem
|
|||||||
{
|
{
|
||||||
component.Visible = visible;
|
component.Visible = visible;
|
||||||
UpdateAppearance(uid, component);
|
UpdateAppearance(uid, component);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TogglePanel(EntityUid uid, WiresPanelComponent component, bool open)
|
public void TogglePanel(EntityUid uid, WiresPanelComponent component, bool open)
|
||||||
{
|
{
|
||||||
component.Open = open;
|
component.Open = open;
|
||||||
UpdateAppearance(uid, component);
|
UpdateAppearance(uid, component);
|
||||||
Dirty(component);
|
Dirty(uid, component);
|
||||||
|
|
||||||
var ev = new PanelChangedEvent(component.Open);
|
var ev = new PanelChangedEvent(component.Open);
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
@@ -657,16 +658,11 @@ public sealed class WiresSystem : SharedWiresSystem
|
|||||||
|
|
||||||
public void SetWiresPanelSecurityData(EntityUid uid, WiresPanelComponent component, string wiresPanelSecurityLevelID)
|
public void SetWiresPanelSecurityData(EntityUid uid, WiresPanelComponent component, string wiresPanelSecurityLevelID)
|
||||||
{
|
{
|
||||||
var wiresPanelSecurityLevelPrototype = _protoMan.Index<WiresPanelSecurityLevelPrototype>(wiresPanelSecurityLevelID);
|
component.CurrentSecurityLevelID = wiresPanelSecurityLevelID;
|
||||||
|
Dirty(uid, component);
|
||||||
|
|
||||||
if (wiresPanelSecurityLevelPrototype == null)
|
if (_protoMan.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
|
||||||
return;
|
securityLevelPrototype.WiresAccessible)
|
||||||
|
|
||||||
component.WiresAccessible = wiresPanelSecurityLevelPrototype.WiresAccessible;
|
|
||||||
component.WiresPanelSecurityExamination = wiresPanelSecurityLevelPrototype.Examine;
|
|
||||||
Dirty(component);
|
|
||||||
|
|
||||||
if (wiresPanelSecurityLevelPrototype?.WiresAccessible == false)
|
|
||||||
{
|
{
|
||||||
_uiSystem.TryCloseAll(uid, WiresUiKey.Key);
|
_uiSystem.TryCloseAll(uid, WiresUiKey.Key);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,16 +41,6 @@ public sealed class WeldableSystem : EntitySystem
|
|||||||
|
|
||||||
private void OnInteractUsing(EntityUid uid, WeldableComponent component, InteractUsingEvent args)
|
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<ConstructionGraphEdge>(_construction.GetCurrentNode(uid)?.Edges, x => _construction.CheckConditions(uid, x.Conditions)
|
|
||||||
&& Enumerable.Any<ConstructionGraphStep>(x.Steps, y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true)
|
|
||||||
{
|
|
||||||
args.Handled = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Tools.Systems;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Shared.Wires;
|
namespace Content.Shared.Wires;
|
||||||
|
|
||||||
public abstract class SharedWiresSystem : EntitySystem
|
public abstract class SharedWiresSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
|
||||||
|
SubscribeLocalEvent<WiresPanelComponent, WeldableAttemptEvent>(OnWeldableAttempt);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnExamine(EntityUid uid, WiresPanelComponent component, ExaminedEvent args)
|
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"));
|
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")]
|
[DataField("screwdriverCloseSound")]
|
||||||
public SoundSpecifier ScrewdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg");
|
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]
|
[AutoNetworkedField]
|
||||||
public string? WiresPanelSecurityExamination = default!;
|
public string CurrentSecurityLevelID = "Level0";
|
||||||
|
|
||||||
[AutoNetworkedField]
|
|
||||||
public bool WiresAccessible = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -8,9 +8,24 @@ public sealed class WiresPanelSecurityLevelPrototype : IPrototype
|
|||||||
[IdDataField]
|
[IdDataField]
|
||||||
public string ID { get; private set; } = default!;
|
public string ID { get; private set; } = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A verbal description of the wire panel's current security level
|
||||||
|
/// </summary>
|
||||||
[DataField("examine")]
|
[DataField("examine")]
|
||||||
public string? Examine = default!;
|
public string? Examine = default!;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether the wiring is accessible to hackers or not
|
||||||
|
/// </summary>
|
||||||
[DataField("wiresAccessible")]
|
[DataField("wiresAccessible")]
|
||||||
public bool WiresAccessible = true;
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Doors/Airlocks/Standard/atmospherics.rsi
|
sprite: Structures/Doors/Airlocks/Standard/atmospherics.rsi
|
||||||
|
- type: WiresPanel
|
||||||
|
securityLevel: Level2
|
||||||
- type: Construction
|
- type: Construction
|
||||||
node: airlockMedSecurity
|
node: airlockMedSecurity
|
||||||
|
|
||||||
@@ -71,6 +73,8 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Doors/Airlocks/Standard/command.rsi
|
sprite: Structures/Doors/Airlocks/Standard/command.rsi
|
||||||
|
- type: WiresPanel
|
||||||
|
securityLevel: Level5
|
||||||
- type: Construction
|
- type: Construction
|
||||||
node: airlockMaxSecurity
|
node: airlockMaxSecurity
|
||||||
|
|
||||||
@@ -81,6 +85,8 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Doors/Airlocks/Standard/security.rsi
|
sprite: Structures/Doors/Airlocks/Standard/security.rsi
|
||||||
|
- type: WiresPanel
|
||||||
|
securityLevel: Level2
|
||||||
- type: Construction
|
- type: Construction
|
||||||
node: airlockMedSecurity
|
node: airlockMedSecurity
|
||||||
|
|
||||||
@@ -170,6 +176,8 @@
|
|||||||
sprite: Structures/Doors/Airlocks/Glass/atmospherics.rsi
|
sprite: Structures/Doors/Airlocks/Glass/atmospherics.rsi
|
||||||
- type: PaintableAirlock
|
- type: PaintableAirlock
|
||||||
group: Glass
|
group: Glass
|
||||||
|
- type: WiresPanel
|
||||||
|
securityLevel: Level2
|
||||||
- type: Construction
|
- type: Construction
|
||||||
node: glassAirlockMedSecurity
|
node: glassAirlockMedSecurity
|
||||||
|
|
||||||
@@ -222,6 +230,8 @@
|
|||||||
sprite: Structures/Doors/Airlocks/Glass/command.rsi
|
sprite: Structures/Doors/Airlocks/Glass/command.rsi
|
||||||
- type: PaintableAirlock
|
- type: PaintableAirlock
|
||||||
group: Glass
|
group: Glass
|
||||||
|
- type: WiresPanel
|
||||||
|
securityLevel: Level5
|
||||||
- type: Construction
|
- type: Construction
|
||||||
node: glassAirlockMaxSecurity
|
node: glassAirlockMaxSecurity
|
||||||
|
|
||||||
@@ -234,6 +244,8 @@
|
|||||||
sprite: Structures/Doors/Airlocks/Glass/security.rsi
|
sprite: Structures/Doors/Airlocks/Glass/security.rsi
|
||||||
- type: PaintableAirlock
|
- type: PaintableAirlock
|
||||||
group: Glass
|
group: Glass
|
||||||
|
- type: WiresPanel
|
||||||
|
securityLevel: Level2
|
||||||
- type: Construction
|
- type: Construction
|
||||||
node: glassAirlockMedSecurity
|
node: glassAirlockMedSecurity
|
||||||
|
|
||||||
|
|||||||
@@ -6,21 +6,25 @@
|
|||||||
id: Level1
|
id: Level1
|
||||||
examine: wires-panel-component-on-examine-security-level1
|
examine: wires-panel-component-on-examine-security-level1
|
||||||
wiresAccessible: false
|
wiresAccessible: false
|
||||||
|
weldingAllowed: false
|
||||||
|
|
||||||
- type: WiresPanelSecurityLevel
|
- type: WiresPanelSecurityLevel
|
||||||
id: Level2
|
id: Level2
|
||||||
examine: wires-panel-component-on-examine-security-level2
|
examine: wires-panel-component-on-examine-security-level2
|
||||||
wiresAccessible: false
|
wiresAccessible: false
|
||||||
|
weldingAllowed: false
|
||||||
|
|
||||||
- type: WiresPanelSecurityLevel
|
- type: WiresPanelSecurityLevel
|
||||||
id: Level3
|
id: Level3
|
||||||
examine: wires-panel-component-on-examine-security-level3
|
examine: wires-panel-component-on-examine-security-level3
|
||||||
wiresAccessible: false
|
wiresAccessible: false
|
||||||
|
weldingAllowed: false
|
||||||
|
|
||||||
- type: WiresPanelSecurityLevel
|
- type: WiresPanelSecurityLevel
|
||||||
id: Level4
|
id: Level4
|
||||||
examine: wires-panel-component-on-examine-security-level4
|
examine: wires-panel-component-on-examine-security-level4
|
||||||
wiresAccessible: false
|
wiresAccessible: false
|
||||||
|
weldingAllowed: false
|
||||||
|
|
||||||
- type: WiresPanelSecurityLevel
|
- type: WiresPanelSecurityLevel
|
||||||
id: Level5
|
id: Level5
|
||||||
@@ -31,9 +35,11 @@
|
|||||||
id: Level6
|
id: Level6
|
||||||
examine: wires-panel-component-on-examine-security-level6
|
examine: wires-panel-component-on-examine-security-level6
|
||||||
wiresAccessible: false
|
wiresAccessible: false
|
||||||
|
weldingAllowed: false
|
||||||
|
|
||||||
- type: WiresPanelSecurityLevel
|
- type: WiresPanelSecurityLevel
|
||||||
id: Level7
|
id: Level7
|
||||||
examine: wires-panel-component-on-examine-security-level7
|
examine: wires-panel-component-on-examine-security-level7
|
||||||
wiresAccessible: false
|
wiresAccessible: false
|
||||||
|
weldingAllowed: false
|
||||||
|
|
||||||
Reference in New Issue
Block a user