Hacking protections for airlocks (#18894)

* Adds the ability to better protect to the internal wiring of airlocks
- Achieved by opening the maintenance panel, adding either steel or plasteel to the airlock, then welding the plate in place
- To access the wiring, the plating must be cut with a welder and then pried out with a crowbar

* Code revisions
- Cleaned up the code
- Cutting the security grille can now shock you
- Atmospherics and Security dept airlocks start with a medium level of protection (a welded steel plate)
- Command dept airlocks start with a high level of protection (a welded plasteel plate and electrified security grille)

* Code revision
- Accounted for a potentially null string

* Update Content.Server/Construction/Completions/AttemptElectrocute.cs

Co-authored-by: Slava0135 <40753025+Slava0135@users.noreply.github.com>

* Update ChangeWiresPanelSecurityLevel.cs

Adjusted scope

* Update Content.Shared/Wires/SharedWiresSystem.cs

Co-authored-by: Slava0135 <40753025+Slava0135@users.noreply.github.com>

* Update Content.Shared/Wires/SharedWiresSystem.cs

Co-authored-by: Slava0135 <40753025+Slava0135@users.noreply.github.com>

* Update ChangeWiresPanelSecurityLevel.cs

Removed get / setter and added [ValidatePrototypeId] attribute

* Update ChangeWiresPanelSecurityLevel.cs

Set security level to "Level0" as the default

* Update airlock.yml

Removed 'super max' level of security

* Update WiresPanelSecurityLevelPrototype.cs

* Update WiresSystem.cs

Added check for WiresAccessible to OnInteractUsing

* Update AttemptElectrocute.cs

File scoped namespace

* Update ChangeWiresPanelSecurityLevel.cs

File scoped namespace

* Update AirlockSystem.cs

File scoped namespace

* Update SharedWiresSystem.cs

Removed boiler plate 'OnGetState' and 'OnHandleState'

* Update WiresPanelComponent.cs

Implemented AutoGenerateComponentState

* Removed unnecessary usage references

* use TryCloseAll when wires not accessible

* minor changes to AttemmptElectrocute

* lets try all 7 levels

* fix indent in airlock graph

* fix indent 2

---------

Co-authored-by: Slava0135 <40753025+Slava0135@users.noreply.github.com>
Co-authored-by: Slava0135 <super.novalskiy_0135@inbox.ru>
This commit is contained in:
chromiumboy
2023-08-10 03:33:03 -05:00
committed by GitHub
parent 13991d3948
commit 636819f4e3
13 changed files with 557 additions and 231 deletions

View File

@@ -1,17 +1,24 @@
using Content.Server.Electrocution;
using Content.Shared.Construction;
namespace Content.Server.Construction.Completions
namespace Content.Server.Construction.Completions;
[DataDefinition]
public sealed class AttemptElectrocute : IGraphAction
{
[DataDefinition]
public sealed class AttemptElectrocute : IGraphAction
{
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (userUid == null)
return;
entityManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>().TryDoElectrifiedAct(uid, userUid.Value);
}
if (!entityManager.TryGetComponent<ElectrifiedComponent>(uid, out var electrified))
return;
var currentValue = electrified.Enabled;
electrified.Enabled = true;
entityManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>().TryDoElectrifiedAct(uid, userUid.Value, electrified: electrified);
electrified.Enabled = currentValue;
}
}

View File

@@ -0,0 +1,27 @@
using Content.Server.Wires;
using Content.Shared.Construction;
using Content.Shared.Wires;
using JetBrains.Annotations;
namespace Content.Server.Construction.Completions;
[UsedImplicitly]
[DataDefinition]
public sealed class ChangeWiresPanelSecurityLevel : IGraphAction
{
[DataField("level")]
[ValidatePrototypeId<WiresPanelSecurityLevelPrototype>]
public string WiresPanelSecurityLevelID = "Level0";
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (WiresPanelSecurityLevelID == null)
return;
if (entityManager.TryGetComponent(uid, out WiresPanelComponent? wiresPanel)
&& entityManager.TrySystem(out WiresSystem? wiresSystem))
{
wiresSystem.SetWiresPanelSecurityData(uid, wiresPanel, WiresPanelSecurityLevelID);
}
}
}

View File

@@ -10,10 +10,10 @@ using Content.Shared.Interaction;
using Robust.Server.GameObjects;
using Content.Shared.Wires;
namespace Content.Server.Doors.Systems
namespace Content.Server.Doors.Systems;
public sealed class AirlockSystem : SharedAirlockSystem
{
public sealed class AirlockSystem : SharedAirlockSystem
{
[Dependency] private readonly WiresSystem _wiresSystem = default!;
[Dependency] private readonly PowerReceiverSystem _power = default!;
[Dependency] private readonly DoorBoltSystem _bolts = default!;
@@ -149,8 +149,8 @@ namespace Content.Server.Doors.Systems
private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
{
if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open &&
TryComp<ActorComponent>(args.User, out var actor))
if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open && panel.WiresAccessible
&& TryComp<ActorComponent>(args.User, out var actor))
{
_wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
args.Handled = true;
@@ -185,5 +185,4 @@ namespace Content.Server.Doors.Systems
{
return this.IsPowered(uid, EntityManager) && !_bolts.IsBolted(uid);
}
}
}

View File

@@ -22,7 +22,6 @@ using Content.Shared.Speech.EntitySystems;
using Content.Shared.StatusEffect;
using Content.Shared.Stunnable;
using Content.Shared.Tag;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Audio;
using Robust.Shared.Map;

View File

@@ -1,5 +1,8 @@
using Content.Server.Administration.Logs;
using Content.Server.Construction;
using Content.Server.Tools.Components;
using Content.Server.Wires;
using Content.Shared.Construction.Steps;
using Content.Shared.Database;
using Content.Shared.DoAfter;
using Content.Shared.Examine;
@@ -7,8 +10,10 @@ using Content.Shared.Interaction;
using Content.Shared.Tools;
using Content.Shared.Tools.Components;
using Content.Shared.Tools.Systems;
using Content.Shared.Wires;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
using System.Linq;
namespace Content.Server.Tools.Systems;
@@ -18,6 +23,7 @@ public sealed class WeldableSystem : EntitySystem
[Dependency] private readonly SharedToolSystem _toolSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ConstructionSystem _construction = default!;
public override void Initialize()
{
@@ -36,6 +42,14 @@ 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
if (_construction.GetCurrentNode(uid)?.Edges.Any(x => _construction.CheckConditions(uid, x.Conditions)
&& x.Steps.Any(y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true)
{
args.Handled = false;
return;
}
if (args.Handled)
return;

View File

@@ -31,6 +31,7 @@ public sealed class WiresSystem : SharedWiresSystem
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly WiresSystem _wiresSystem = default!;
// This is where all the wire layouts are stored.
[ViewVariables] private readonly Dictionary<string, WireLayout> _layouts = new();
@@ -455,7 +456,7 @@ public sealed class WiresSystem : SharedWiresSystem
if (!TryComp<ToolComponent>(args.Used, out var tool) || !TryComp<WiresPanelComponent>(uid, out var panel))
return;
if (panel.Open &&
if (panel.Open && panel.WiresAccessible &&
(_toolSystem.HasQuality(args.Used, "Cutting", tool) ||
_toolSystem.HasQuality(args.Used, "Pulsing", tool)))
{
@@ -631,6 +632,23 @@ public sealed class WiresSystem : SharedWiresSystem
Dirty(component);
}
public void SetWiresPanelSecurityData(EntityUid uid, WiresPanelComponent component, string wiresPanelSecurityLevelID)
{
var wiresPanelSecurityLevelPrototype = _protoMan.Index<WiresPanelSecurityLevelPrototype>(wiresPanelSecurityLevelID);
if (wiresPanelSecurityLevelPrototype == null)
return;
component.WiresAccessible = wiresPanelSecurityLevelPrototype.WiresAccessible;
component.WiresPanelSecurityExamination = wiresPanelSecurityLevelPrototype.Examine;
Dirty(component);
if (wiresPanelSecurityLevelPrototype?.WiresAccessible == false)
{
_uiSystem.TryCloseAll(uid, WiresUiKey.Key);
}
}
private void UpdateAppearance(EntityUid uid, WiresPanelComponent panel)
{
if (TryComp<AppearanceComponent>(uid, out var appearance))

View File

@@ -1,5 +1,4 @@
using Content.Shared.Examine;
using Robust.Shared.GameStates;
namespace Content.Shared.Wires;
@@ -9,31 +8,22 @@ public abstract class SharedWiresSystem : EntitySystem
{
base.Initialize();
SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<WiresPanelComponent, ComponentGetState>(OnGetState);
SubscribeLocalEvent<WiresPanelComponent, ComponentHandleState>(OnHandleState);
}
private void OnExamine(EntityUid uid, WiresPanelComponent component, ExaminedEvent args)
{
args.PushMarkup(Loc.GetString(component.Open
? "wires-panel-component-on-examine-open"
: "wires-panel-component-on-examine-closed"));
if (!component.Open)
{
args.PushMarkup(Loc.GetString("wires-panel-component-on-examine-closed"));
}
else
{
args.PushMarkup(Loc.GetString("wires-panel-component-on-examine-open"));
private void OnGetState(EntityUid uid, WiresPanelComponent component, ref ComponentGetState args)
if (component?.WiresPanelSecurityExamination != null)
{
args.State = new WiresPanelComponentState
{
Open = component.Open,
Visible = component.Visible
};
args.PushMarkup(Loc.GetString(component.WiresPanelSecurityExamination));
}
}
private void OnHandleState(EntityUid uid, WiresPanelComponent component, ref ComponentHandleState args)
{
if (args.Current is not WiresPanelComponentState state)
return;
component.Open = state.Open;
component.Visible = state.Visible;
}
}

View File

@@ -1,23 +1,25 @@
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Wires;
[NetworkedComponent, RegisterComponent]
[Access(typeof(SharedWiresSystem))]
public sealed class WiresPanelComponent : Component
[AutoGenerateComponentState]
public sealed partial class WiresPanelComponent : Component
{
/// <summary>
/// Is the panel open for this entity's wires?
/// </summary>
[DataField("open")]
[AutoNetworkedField]
public bool Open;
/// <summary>
/// Should this entity's wires panel be visible at all?
/// </summary>
[ViewVariables]
[AutoNetworkedField]
public bool Visible = true;
[DataField("screwdriverOpenSound")]
@@ -25,11 +27,10 @@ public sealed class WiresPanelComponent : Component
[DataField("screwdriverCloseSound")]
public SoundSpecifier ScrewdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg");
}
[Serializable, NetSerializable]
public sealed class WiresPanelComponentState : ComponentState
{
public bool Open;
public bool Visible;
[AutoNetworkedField]
public string? WiresPanelSecurityExamination = default!;
[AutoNetworkedField]
public bool WiresAccessible = true;
}

View File

@@ -0,0 +1,16 @@
using Robust.Shared.Prototypes;
namespace Content.Shared.Wires;
[Prototype("WiresPanelSecurityLevel")]
public sealed class WiresPanelSecurityLevelPrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
[DataField("examine")]
public string? Examine = default!;
[DataField("wiresAccessible")]
public bool WiresAccessible = true;
}

View File

@@ -0,0 +1,8 @@
# Examination for different levels of wiring protection
wires-panel-component-on-examine-security-level1 = There is a steel plate preventing access to the internal wiring. Use a [color=cyan]Crowbar[/color] to remove it.
wires-panel-component-on-examine-security-level2 = A steel plate has been welded to the inside the [color=lightgray]maintenance panel[/color]. Use a [color=cyan]Welder[/color] to free it.
wires-panel-component-on-examine-security-level3 = There is a plasteel plate preventing access to the internal wiring. Use a [color=cyan]Crowbar[/color] to remove it.
wires-panel-component-on-examine-security-level4 = A plasteel plate has been welded to the inside the [color=lightgray]maintenance panel[/color]. Use a [color=cyan]Welder[/color] to free it.
wires-panel-component-on-examine-security-level5 = The inside of the [color=lightgray]maintenance panel[/color] is protected by a security grille. Use [color=cyan]Wirecutters[/color] to remove it.
wires-panel-component-on-examine-security-level6 = A plasteel plate sits within the interior of the [color=lightgray]maintenance panel[/color]. Use a [color=cyan]Crowbar[/color] to remove it.
wires-panel-component-on-examine-security-level7 = A welded plasteel plate protects the interior of the [color=lightgray]maintenance panel[/color]. Use a [color=cyan]Welder[/color] to free it.

View File

@@ -21,6 +21,8 @@
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/atmospherics.rsi
- type: Construction
node: airlockMedSecurity
- type: entity
parent: Airlock
@@ -69,6 +71,8 @@
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/command.rsi
- type: Construction
node: airlockMaxSecurity
- type: entity
parent: Airlock
@@ -77,6 +81,8 @@
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/security.rsi
- type: Construction
node: airlockMedSecurity
- type: entity
parent: Airlock
@@ -156,6 +162,8 @@
sprite: Structures/Doors/Airlocks/Glass/atmospherics.rsi
- type: PaintableAirlock
group: Glass
- type: Construction
node: airlockMedSecurity
- type: entity
parent: AirlockGlass
@@ -206,6 +214,8 @@
sprite: Structures/Doors/Airlocks/Glass/command.rsi
- type: PaintableAirlock
group: Glass
- type: Construction
node: airlockMaxSecurity
- type: entity
parent: AirlockGlass
@@ -216,3 +226,5 @@
sprite: Structures/Doors/Airlocks/Glass/security.rsi
- type: PaintableAirlock
group: Glass
- type: Construction
node: airlockMedSecurity

View File

@@ -0,0 +1,39 @@
- type: WiresPanelSecurityLevel
id: Level0
wiresAccessible: true
- type: WiresPanelSecurityLevel
id: Level1
examine: wires-panel-component-on-examine-security-level1
wiresAccessible: false
- type: WiresPanelSecurityLevel
id: Level2
examine: wires-panel-component-on-examine-security-level2
wiresAccessible: false
- type: WiresPanelSecurityLevel
id: Level3
examine: wires-panel-component-on-examine-security-level3
wiresAccessible: false
- type: WiresPanelSecurityLevel
id: Level4
examine: wires-panel-component-on-examine-security-level4
wiresAccessible: false
- type: WiresPanelSecurityLevel
id: Level5
examine: wires-panel-component-on-examine-security-level5
wiresAccessible: false
- type: WiresPanelSecurityLevel
id: Level6
examine: wires-panel-component-on-examine-security-level6
wiresAccessible: false
- type: WiresPanelSecurityLevel
id: Level7
examine: wires-panel-component-on-examine-security-level7
wiresAccessible: false

View File

@@ -86,24 +86,6 @@
- tool: Prying
doAfter: 5
- node: airlock
entity: Airlock
edges:
- to: wired #TODO DOOR ELECTRONICS. If door electronics ever govern access permissions, this step should probably be further down? It makes it too easy to swap permissions around. See also windoor.
conditions:
- !type:EntityAnchored {}
- !type:DoorWelded {}
- !type:DoorBolted
value: false
- !type:WirePanel {}
- !type:AllWiresCut
completed:
- !type:EmptyAllContainers {}
steps:
- tool: Prying
doAfter: 5
- node: glassElectronics
entity: AirlockAssembly
edges:
@@ -146,3 +128,217 @@
steps:
- tool: Prying
doAfter: 2
- node: airlock
entity: Airlock
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level0
edges:
- to: wired #TODO DOOR ELECTRONICS. If door electronics ever govern access permissions, this step should probably be further down? It makes it too easy to swap permissions around. See also windoor.
conditions:
- !type:EntityAnchored {}
- !type:DoorWelded {}
- !type:DoorBolted
value: false
- !type:WirePanel {}
- !type:AllWiresCut
completed:
- !type:EmptyAllContainers {}
steps:
- tool: Prying
doAfter: 5
- to: airlockMedSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- material: Steel
amount: 2
doAfter: 2
- to: airlockHighSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- material: Plasteel
amount: 2
doAfter: 2
## Return node so that removing all internal plating doesn't reset the door
- node: airlockUnsecured
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level0
edges:
- to: wired
conditions:
- !type:EntityAnchored {}
- !type:DoorWelded {}
- !type:DoorBolted
value: false
- !type:WirePanel {}
- !type:AllWiresCut
completed:
- !type:EmptyAllContainers {}
steps:
- tool: Prying
doAfter: 5
- to: airlockMedSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- material: Steel
amount: 2
doAfter: 2
- to: airlockHighSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- material: Plasteel
amount: 2
doAfter: 2
## Medium security level airlock: a layer of steel plating protects the internal wiring
- node: airlockMedSecurityBreached
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level1
edges:
- to: airlockUnsecured
completed:
- !type:GivePrototype
prototype: SheetSteel1
amount: 2
conditions:
- !type:WirePanel {}
steps:
- tool: Prying
doAfter: 4
- to: airlockMedSecurity
conditions:
- !type:WirePanel {}
steps:
- tool: Welding
doAfter: 3
- node: airlockMedSecurity
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level2
edges:
- to: airlockMedSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- tool: Welding
doAfter: 10
## High security level airlock: a layer of plasteel plating protects the internal wiring
- node: airlockHighSecurityBreached
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level3
edges:
- to: airlockUnsecured
completed:
- !type:GivePrototype
prototype: SheetPlasteel1
amount: 2
conditions:
- !type:WirePanel {}
steps:
- tool: Prying
doAfter: 4
- to: airlockHighSecurity
conditions:
- !type:WirePanel {}
steps:
- tool: Welding
doAfter: 5
- node: airlockHighSecurity
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level4
edges:
- to: airlockHighSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- tool: Welding
doAfter: 15
- to: airlockMaxSecurity
conditions:
- !type:WirePanel {}
steps:
- material: MetalRod
amount: 2
doAfter: 1
## Max security level airlock: an electric grill is added
- node: airlockMaxSecurity
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level5
edges:
- to: airlockHighSecurity
completed:
- !type:AttemptElectrocute
- !type:GivePrototype
prototype: PartRodMetal1
amount: 2
conditions:
- !type:WirePanel {}
steps:
- tool: Cutting
doAfter: 0.5
- to: airlockSuperMaxSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- material: Plasteel
amount: 2
doAfter: 2
## Super max security level airlock: an additional layer of plasteel is added
- node: airlockSuperMaxSecurityBreached
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level6
edges:
- to: airlockMaxSecurity
completed:
- !type:GivePrototype
prototype: SheetPlasteel1
amount: 2
conditions:
- !type:WirePanel {}
steps:
- tool: Prying
doAfter: 4
- to: airlockSuperMaxSecurity
conditions:
- !type:WirePanel {}
steps:
- tool: Welding
doAfter: 5
- node: airlockSuperMaxSecurity
actions:
- !type:ChangeWiresPanelSecurityLevel
level: Level7
edges:
- to: airlockSuperMaxSecurityBreached
conditions:
- !type:WirePanel {}
steps:
- tool: Welding
doAfter: 15