From 822c8f3c70d45588182cd60da0962d5c053d6ca8 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Wed, 31 Aug 2022 23:22:25 -0400 Subject: [PATCH] make jaws of life not awful (#10770) --- Content.Server/Doors/Components/AirlockComponent.cs | 8 ++++++++ Content.Server/Doors/Systems/AirlockSystem.cs | 12 ++++++++++++ Content.Server/Doors/Systems/DoorSystem.cs | 3 ++- Content.Shared/Doors/DoorEvents.cs | 4 +++- .../Tools/Components/ToolForcePoweredComponent.cs | 10 ++++++++++ .../Entities/Objects/Tools/jaws_of_life.yml | 1 + 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 Content.Shared/Tools/Components/ToolForcePoweredComponent.cs diff --git a/Content.Server/Doors/Components/AirlockComponent.cs b/Content.Server/Doors/Components/AirlockComponent.cs index fdf683d589..db82273a27 100644 --- a/Content.Server/Doors/Components/AirlockComponent.cs +++ b/Content.Server/Doors/Components/AirlockComponent.cs @@ -36,6 +36,14 @@ namespace Content.Server.Doors.Components [DataField("powerWiresTimeout")] public float PowerWiresTimeout = 5.0f; + /// + /// Pry modifier for a powered airlock. + /// Most anything that can pry powered has a pry speed bonus, + /// so this default is closer to 6 effectively on e.g. jaws (9 seconds when applied to other default.) + /// + [DataField("poweredPryModifier")] + public readonly float PoweredPryModifier = 9f; + /// /// Whether the maintenance panel should be visible even if the airlock is opened. /// diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs index 733093c541..38ab19f25c 100644 --- a/Content.Server/Doors/Systems/AirlockSystem.cs +++ b/Content.Server/Doors/Systems/AirlockSystem.cs @@ -1,5 +1,7 @@ using Content.Server.Doors.Components; using Content.Server.Power.Components; +using Content.Server.Power.EntitySystems; +using Content.Shared.Tools.Components; using Content.Server.Wires; using Content.Shared.Doors; using Content.Shared.Doors.Components; @@ -13,6 +15,7 @@ namespace Content.Server.Doors.Systems public sealed class AirlockSystem : SharedAirlockSystem { [Dependency] private readonly WiresSystem _wiresSystem = default!; + [Dependency] private readonly PowerReceiverSystem _power = default!; public override void Initialize() { @@ -23,6 +26,7 @@ namespace Content.Server.Doors.Systems SubscribeLocalEvent(OnBeforeDoorOpened); SubscribeLocalEvent(OnBeforeDoorDenied); SubscribeLocalEvent(OnActivate, before: new [] {typeof(DoorSystem)}); + SubscribeLocalEvent(OnGetPryMod); SubscribeLocalEvent(OnDoorPry); } @@ -132,6 +136,12 @@ namespace Content.Server.Doors.Systems } } + private void OnGetPryMod(EntityUid uid, AirlockComponent component, DoorGetPryTimeModifierEvent args) + { + if (_power.IsPowered(uid)) + args.PryTimeModifier *= component.PoweredPryModifier; + } + private void OnDoorPry(EntityUid uid, AirlockComponent component, BeforeDoorPryEvent args) { if (component.IsBolted()) @@ -141,6 +151,8 @@ namespace Content.Server.Doors.Systems } if (component.IsPowered()) { + if (HasComp(args.Tool)) + return; component.Owner.PopupMessage(args.User, Loc.GetString("airlock-component-cannot-pry-is-powered-message")); args.Cancel(); } diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index f2491310ee..c92030db92 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -174,6 +174,7 @@ public sealed class DoorSystem : SharedDoorSystem }); } + /// /// Pry open a door. This does not check if the user is holding the required tool. /// @@ -187,7 +188,7 @@ public sealed class DoorSystem : SharedDoorSystem if (!force) { - var canEv = new BeforeDoorPryEvent(user); + var canEv = new BeforeDoorPryEvent(user, tool); RaiseLocalEvent(target, canEv, false); if (canEv.Cancelled) diff --git a/Content.Shared/Doors/DoorEvents.cs b/Content.Shared/Doors/DoorEvents.cs index 458218829c..591013d7fe 100644 --- a/Content.Shared/Doors/DoorEvents.cs +++ b/Content.Shared/Doors/DoorEvents.cs @@ -78,10 +78,12 @@ namespace Content.Shared.Doors public sealed class BeforeDoorPryEvent : CancellableEntityEventArgs { public readonly EntityUid User; + public readonly EntityUid Tool; - public BeforeDoorPryEvent(EntityUid user) + public BeforeDoorPryEvent(EntityUid user, EntityUid tool) { User = user; + Tool = tool; } } } diff --git a/Content.Shared/Tools/Components/ToolForcePoweredComponent.cs b/Content.Shared/Tools/Components/ToolForcePoweredComponent.cs new file mode 100644 index 0000000000..2bb72d3e38 --- /dev/null +++ b/Content.Shared/Tools/Components/ToolForcePoweredComponent.cs @@ -0,0 +1,10 @@ +namespace Content.Shared.Tools.Components +{ + /// + /// Tag component to let a tool ignore restrictions on whether devices are powered + /// or not to work. + /// + [RegisterComponent] + public sealed class ToolForcePoweredComponent : Component + {} +} diff --git a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml index d5f6273801..f90e1dcdd0 100644 --- a/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml +++ b/Resources/Prototypes/Entities/Objects/Tools/jaws_of_life.yml @@ -24,6 +24,7 @@ qualities: - Prying speed: 1.5 + - type: ToolForcePowered - type: MultipleTool statusShowBehavior: true entries: