Arachnid zombie hands fix (#19073)

* zombie hands begone

* the shortening

* Move it to SharedHandsSystem

* do the requested changes
This commit is contained in:
PixelTK
2023-08-13 20:51:20 +01:00
committed by GitHub
parent 080e923583
commit 1e36976d3a
2 changed files with 30 additions and 11 deletions

View File

@@ -33,6 +33,7 @@ using Content.Shared.Tools.Components;
using Content.Shared.Weapons.Melee; using Content.Shared.Weapons.Melee;
using Content.Shared.Zombies; using Content.Shared.Zombies;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using System.Linq;
namespace Content.Server.Zombies namespace Content.Server.Zombies
{ {
@@ -244,18 +245,10 @@ namespace Content.Server.Zombies
ghostRole.RoleRules = Loc.GetString("zombie-role-rules"); ghostRole.RoleRules = Loc.GetString("zombie-role-rules");
} }
//Goes through every hand, drops the items in it, then removes the hand if (TryComp<HandsComponent>(target, out var handsComp))
//may become the source of various bugs.
if (TryComp<HandsComponent>(target, out var hands))
{ {
foreach (var hand in _hands.EnumerateHands(target)) _hands.RemoveHands(target);
{ RemComp(target, handsComp);
_hands.SetActiveHand(target, hand, hands);
_hands.DoDrop(target, hand, handsComp: hands);
_hands.RemoveHand(target, hand.Name, hands);
}
RemComp(target, hands);
} }
// No longer waiting to become a zombie: // No longer waiting to become a zombie:

View File

@@ -77,6 +77,32 @@ public abstract partial class SharedHandsSystem : EntitySystem
Dirty(handsComp); Dirty(handsComp);
} }
/// <summary>
/// Gets rid of all the entity's hands.
/// </summary>
/// <param name="uid"></param>
/// <param name="handsComp"></param>
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<Hand> 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) private void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs)
{ {
if (eventArgs.SenderSession.AttachedEntity == null) if (eventArgs.SenderSession.AttachedEntity == null)