]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix zipties/makeshift cuffs dropping multiple broken entities on removal (#23095)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Thu, 28 Dec 2023 23:50:08 +0000 (18:50 -0500)
committerGitHub <noreply@github.com>
Thu, 28 Dec 2023 23:50:08 +0000 (16:50 -0700)
Content.Shared/Cuffs/Components/HandcuffComponent.cs
Content.Shared/Cuffs/SharedCuffableSystem.cs
Resources/Prototypes/Entities/Objects/Misc/handcuffs.yml

index b43bf18bf8f6203e789bf815ced182e56873eeab..a91692389f1fbd225a092d722f0a01c364c612e5 100644 (file)
@@ -45,6 +45,13 @@ public sealed partial class HandcuffComponent : Component
     [DataField, ViewVariables(VVAccess.ReadWrite)]
     public EntProtoId? BrokenPrototype;
 
+    /// <summary>
+    /// Whether or not these cuffs are in the process of being removed.
+    /// Used simply to prevent spawning multiple <see cref="BrokenPrototype"/>.
+    /// </summary>
+    [DataField]
+    public bool Removing;
+
     [DataField, ViewVariables(VVAccess.ReadWrite)]
     public DamageSpecifier DamageOnResist = new()
     {
index 9f41ed3b5eb1724584bed5276482a9a5ec0a9013..088323fcc5263f29d53799d0deae4221b50ddcfb 100644 (file)
@@ -621,7 +621,7 @@ namespace Content.Shared.Cuffs
             if (!Resolve(target, ref cuffable) || !Resolve(cuffsToRemove, ref cuff))
                 return;
 
-            if (TerminatingOrDeleted(cuffsToRemove) || TerminatingOrDeleted(target))
+            if (cuff.Removing || TerminatingOrDeleted(cuffsToRemove) || TerminatingOrDeleted(target))
                 return;
 
             if (user != null)
@@ -632,6 +632,7 @@ namespace Content.Shared.Cuffs
                     return;
             }
 
+            cuff.Removing = true;
             _audio.PlayPredicted(cuff.EndUncuffSound, target, user);
 
             _container.Remove(cuffsToRemove, cuffable.Container);
@@ -688,6 +689,7 @@ namespace Content.Shared.Cuffs
                     }
                 }
             }
+            cuff.Removing = false;
         }
 
         #region ActionBlocker
index f2fbab04a0e88252b2080a7132b2525fb36b616a..2e33ef24a30c97f29f159e89d18e9f630d1cdaea 100644 (file)
   - type: Construction
     graph: makeshifthandcuffs
     node: cuffscable
+  - type: Item
+    inhandVisuals:
+      left:
+        - state: inhand-left
+          color: forestgreen
+      right:
+        - state: inhand-right
+          color: forestgreen
   - type: Sprite
     sprite: Objects/Misc/cablecuffs.rsi
     state: cuff
     sprite: Objects/Misc/cablecuffs.rsi
     state: cuff-broken
     color: forestgreen
+  - type: Item
+    inhandVisuals:
+      left:
+        - state: inhand-left
+          color: forestgreen
+      right:
+        - state: inhand-right
+          color: forestgreen
 
 - type: entity
   parent: Handcuffs