diff --git a/Content.Server/Zombies/ZombieSystem.Transform.cs b/Content.Server/Zombies/ZombieSystem.Transform.cs index 0887e5a099..d979639f88 100644 --- a/Content.Server/Zombies/ZombieSystem.Transform.cs +++ b/Content.Server/Zombies/ZombieSystem.Transform.cs @@ -33,6 +33,7 @@ using Content.Shared.Tools.Components; using Content.Shared.Weapons.Melee; using Content.Shared.Zombies; using Robust.Shared.Audio; +using System.Linq; namespace Content.Server.Zombies { @@ -244,18 +245,10 @@ namespace Content.Server.Zombies ghostRole.RoleRules = Loc.GetString("zombie-role-rules"); } - //Goes through every hand, drops the items in it, then removes the hand - //may become the source of various bugs. - if (TryComp(target, out var hands)) + if (TryComp(target, out var handsComp)) { - foreach (var hand in _hands.EnumerateHands(target)) - { - _hands.SetActiveHand(target, hand, hands); - _hands.DoDrop(target, hand, handsComp: hands); - _hands.RemoveHand(target, hand.Name, hands); - } - - RemComp(target, hands); + _hands.RemoveHands(target); + RemComp(target, handsComp); } // No longer waiting to become a zombie: diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs index b0a3f116cc..0d671759e8 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs @@ -77,6 +77,32 @@ public abstract partial class SharedHandsSystem : EntitySystem Dirty(handsComp); } + /// + /// Gets rid of all the entity's hands. + /// + /// + /// + + public void RemoveHands(EntityUid uid, HandsComponent? handsComp = null) + { + if (!Resolve(uid, ref handsComp)) + return; + + RemoveHands(uid, EnumerateHands(uid), handsComp); + } + + private void RemoveHands(EntityUid uid, IEnumerable hands, HandsComponent handsComp) + { + if (!hands.Any()) + return; + + var hand = hands.First(); + RemoveHand(uid, hand.Name, handsComp); + + // Repeats it for any additional hands. + RemoveHands(uid, hands, handsComp); + } + private void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs) { if (eventArgs.SenderSession.AttachedEntity == null)