Fix zipties/makeshift cuffs dropping multiple broken entities on removal (#23095)

This commit is contained in:
Nemanja
2023-12-28 18:50:08 -05:00
committed by GitHub
parent 194e9e790f
commit 526b966f09
3 changed files with 26 additions and 1 deletions

View 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()
{

View 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

View File

@@ -52,6 +52,14 @@
- 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
@@ -120,6 +128,14 @@
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