]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Firelocks are no longer pryable by hand if they are powered (#29221)
authornikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com>
Sat, 22 Jun 2024 17:49:50 +0000 (17:49 +0000)
committerGitHub <noreply@github.com>
Sat, 22 Jun 2024 17:49:50 +0000 (10:49 -0700)
Content.Shared/Doors/Systems/SharedFirelockSystem.cs
Content.Shared/Prying/Components/PryingComponent.cs
Content.Shared/Prying/Systems/PryingSystem.cs

index 03350d2e6444bbc7862323805b5356817bb434fd..e613848c5c74c18f3681dd5309eca9466dfc7257 100644 (file)
@@ -21,6 +21,7 @@ public abstract class SharedFirelockSystem : EntitySystem
 
         // Access/Prying
         SubscribeLocalEvent<FirelockComponent, BeforeDoorOpenedEvent>(OnBeforeDoorOpened);
+        SubscribeLocalEvent<FirelockComponent, BeforePryEvent>(OnBeforePry);
         SubscribeLocalEvent<FirelockComponent, GetPryTimeModifierEvent>(OnDoorGetPryTimeModifier);
         SubscribeLocalEvent<FirelockComponent, PriedEvent>(OnAfterPried);
 
@@ -60,6 +61,14 @@ public abstract class SharedFirelockSystem : EntitySystem
             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);
index 6651e2b5744d39ccaf64f6e26430c027485ba42f..93713e52c67f73e7c01f465018fa6fd57ad7ff69 100644 (file)
@@ -43,14 +43,26 @@ public sealed partial class PryingComponent : Component
 /// Cancel to stop the entity from being pried open.
 /// </summary>
 [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;
 
+    /// <summary>
+    /// Whether prying should be allowed even if whatever is being pried is powered.
+    /// </summary>
     public readonly bool PryPowered = PryPowered;
 
+    /// <summary>
+    /// Whether prying should be allowed to go through under most circumstances. (E.g. airlock is bolted).
+    /// Systems may still wish to ignore this occasionally.
+    /// </summary>
     public readonly bool Force = Force;
 
+    /// <summary>
+    /// Whether anything other than bare hands were used. This should only be false if prying is being performed without a prying comp.
+    /// </summary>
+    public readonly bool StrongPry = StrongPry;
+
     public string? Message;
 
     public bool Cancelled;
index 52459c4f744caded2e4dd58efd2ce42dfdc104c3..10c80cfab594d6afec2137eb53bf250ee1f69874 100644 (file)
@@ -109,7 +109,7 @@ public sealed class PryingSystem : EntitySystem
 
         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 @@ public sealed class PryingSystem : EntitySystem
                 return false;
             }
 
-            canev = new BeforePryEvent(user, false, false);
+            canev = new BeforePryEvent(user, false, false, false);
         }
 
         RaiseLocalEvent(target, ref canev);