diff --git a/Content.Shared/Doors/Systems/SharedFirelockSystem.cs b/Content.Shared/Doors/Systems/SharedFirelockSystem.cs index 03350d2e6444..e613848c5c74 100644 --- a/Content.Shared/Doors/Systems/SharedFirelockSystem.cs +++ b/Content.Shared/Doors/Systems/SharedFirelockSystem.cs @@ -21,6 +21,7 @@ public override void Initialize() // Access/Prying SubscribeLocalEvent(OnBeforeDoorOpened); + SubscribeLocalEvent(OnBeforePry); SubscribeLocalEvent(OnDoorGetPryTimeModifier); SubscribeLocalEvent(OnAfterPried); @@ -60,6 +61,14 @@ private void OnBeforeDoorOpened(EntityUid uid, FirelockComponent component, Befo WarnPlayer((uid, component), args.User.Value); } + private void OnBeforePry(EntityUid uid, FirelockComponent component, ref BeforePryEvent args) + { + if (args.Cancelled || !component.Powered || args.StrongPry || args.PryPowered) + return; + + args.Cancelled = true; + } + private void OnDoorGetPryTimeModifier(EntityUid uid, FirelockComponent component, ref GetPryTimeModifierEvent args) { WarnPlayer((uid, component), args.User); diff --git a/Content.Shared/Prying/Components/PryingComponent.cs b/Content.Shared/Prying/Components/PryingComponent.cs index 6651e2b5744d..93713e52c67f 100644 --- a/Content.Shared/Prying/Components/PryingComponent.cs +++ b/Content.Shared/Prying/Components/PryingComponent.cs @@ -43,14 +43,26 @@ public sealed partial class PryingComponent : Component /// Cancel to stop the entity from being pried open. /// [ByRefEvent] -public record struct BeforePryEvent(EntityUid User, bool PryPowered, bool Force) +public record struct BeforePryEvent(EntityUid User, bool PryPowered, bool Force, bool StrongPry) { public readonly EntityUid User = User; + /// + /// Whether prying should be allowed even if whatever is being pried is powered. + /// public readonly bool PryPowered = PryPowered; + /// + /// Whether prying should be allowed to go through under most circumstances. (E.g. airlock is bolted). + /// Systems may still wish to ignore this occasionally. + /// public readonly bool Force = Force; + /// + /// Whether anything other than bare hands were used. This should only be false if prying is being performed without a prying comp. + /// + public readonly bool StrongPry = StrongPry; + public string? Message; public bool Cancelled; diff --git a/Content.Shared/Prying/Systems/PryingSystem.cs b/Content.Shared/Prying/Systems/PryingSystem.cs index 52459c4f744c..10c80cfab594 100644 --- a/Content.Shared/Prying/Systems/PryingSystem.cs +++ b/Content.Shared/Prying/Systems/PryingSystem.cs @@ -109,7 +109,7 @@ private bool CanPry(EntityUid target, EntityUid user, out string? message, Pryin if (comp != null || Resolve(user, ref comp, false)) { - canev = new BeforePryEvent(user, comp.PryPowered, comp.Force); + canev = new BeforePryEvent(user, comp.PryPowered, comp.Force, true); } else { @@ -119,7 +119,7 @@ private bool CanPry(EntityUid target, EntityUid user, out string? message, Pryin return false; } - canev = new BeforePryEvent(user, false, false); + canev = new BeforePryEvent(user, false, false, false); } RaiseLocalEvent(target, ref canev);