]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix AddHandCommand not working on aghosts (#38866)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Fri, 11 Jul 2025 17:10:43 +0000 (13:10 -0400)
committerGitHub <noreply@github.com>
Fri, 11 Jul 2025 17:10:43 +0000 (13:10 -0400)
Content.Server/Body/Commands/AddHandCommand.cs

index a28b07ef572c4dda7b7cc6f56405876266e97eb8..4d2805333a7d18b0e353c6162c0c4e994160132c 100644 (file)
@@ -1,12 +1,13 @@
 using System.Linq;
 using Content.Server.Administration;
 using Content.Server.Body.Systems;
+using Content.Server.Hands.Systems;
 using Content.Shared.Administration;
 using Content.Shared.Body.Components;
 using Content.Shared.Body.Part;
+using Content.Shared.Hands.Components;
 using Robust.Shared.Console;
 using Robust.Shared.Prototypes;
-using Robust.Shared.Random;
 
 namespace Content.Server.Body.Commands
 {
@@ -15,9 +16,9 @@ namespace Content.Server.Body.Commands
     {
         [Dependency] private readonly IEntityManager _entManager = default!;
         [Dependency] private readonly IPrototypeManager _protoManager = default!;
-        [Dependency] private readonly IRobustRandom _random = default!;
 
         private static readonly EntProtoId DefaultHandPrototype = "LeftHandHuman";
+        private static int _handIdAccumulator;
 
         public string Command => "addhand";
         public string Description => "Adds a hand to your entity.";
@@ -114,9 +115,17 @@ namespace Content.Server.Body.Commands
 
             if (!_entManager.TryGetComponent(entity, out BodyComponent? body) || body.RootContainer.ContainedEntity == null)
             {
-                var text = $"You have no body{(_random.Prob(0.2f) ? " and you must scream." : ".")}";
-
-                shell.WriteLine(text);
+                var location = _entManager.GetComponentOrNull<BodyPartComponent>(hand)?.Symmetry switch
+                {
+                    BodyPartSymmetry.None => HandLocation.Middle,
+                    BodyPartSymmetry.Left => HandLocation.Left,
+                    BodyPartSymmetry.Right => HandLocation.Right,
+                    _ => HandLocation.Right
+                };
+                _entManager.DeleteEntity(hand);
+
+                // You have no body and you must scream.
+                _entManager.System<HandsSystem>().AddHand(entity, $"{hand}-cmd-{_handIdAccumulator++}", location);
                 return;
             }