Fixes zipties spawning multiple entities on removal (#15761)

This commit is contained in:
Menshin
2023-05-02 12:14:55 +02:00
committed by GitHub
parent abd1074da8
commit 04b2f41cb4
2 changed files with 38 additions and 13 deletions

View File

@@ -553,7 +553,25 @@ namespace Content.Shared.Cuffs
if (!_doAfter.TryStartDoAfter(doAfterEventArgs))
return;
_popup.PopupEntity(Loc.GetString("cuffable-component-start-removing-cuffs-message"), user, Filter.Local(), false);
if (_net.IsServer)
{
_popup.PopupEntity(Loc.GetString("cuffable-component-start-uncuffing-observer",
("user", Identity.Name(user, EntityManager)), ("target", Identity.Name(target, EntityManager))),
target, Filter.Pvs(target, entityManager: EntityManager)
.RemoveWhere(e => e.AttachedEntity == target || e.AttachedEntity == user), true);
if (target == user)
{
_popup.PopupEntity(Loc.GetString("cuffable-component-start-uncuffing-self"), user, user);
}
else
{
_popup.PopupEntity(Loc.GetString("cuffable-component-start-uncuffing-target-message",
("targetName", Identity.Name(target, EntityManager, user))), user, user);
_popup.PopupEntity(Loc.GetString("cuffable-component-start-uncuffing-by-other-message",
("otherName", Identity.Name(user, EntityManager, target))), target, target);
}
}
_audio.PlayPredicted(isOwner ? cuff.StartBreakoutSound : cuff.StartUncuffSound, target, user);
}
@@ -571,6 +589,10 @@ namespace Content.Shared.Cuffs
cuffable.Container.Remove(cuffsToRemove);
if (_net.IsServer)
{
// Handles spawning broken cuffs on server to avoid client misprediction
if (cuff.BreakOnRemove)
{
QueueDel(cuffsToRemove);
@@ -583,8 +605,6 @@ namespace Content.Shared.Cuffs
}
// Only play popups on server because popups suck
if (_net.IsServer)
{
if (cuffable.CuffedHandCount == 0)
{
_popup.PopupEntity(Loc.GetString("cuffable-component-remove-cuffs-success-message"), user, user);

View File

@@ -1,6 +1,11 @@
cuffable-component-cannot-interact-message = You can't do that!
cuffable-component-cannot-remove-cuffs-too-far-message = You are too far away to remove the cuffs.
cuffable-component-start-removing-cuffs-message = You start removing the cuffs.
cuffable-component-start-uncuffing-self = You start uncuffing yourself.
cuffable-component-start-uncuffing-observer = {$user} starts uncuffing {$target}!
cuffable-component-start-uncuffing-target-message = You start uncuffing {$targetName}.
cuffable-component-start-uncuffing-by-other-message = {$otherName} starts uncuffing you!
cuffable-component-remove-cuffs-success-message = You successfully remove the cuffs.
cuffable-component-remove-cuffs-by-other-success-message = {$otherName} uncuffs your hands.
cuffable-component-remove-cuffs-to-other-partial-success-message = You successfully remove the cuffs. {$cuffedHandCount} of {$otherName}'s hands remain cuffed.