diff --git a/Content.Client/GameObjects/Components/Items/HandsComponent.cs b/Content.Client/GameObjects/Components/Items/HandsComponent.cs index 236eb6cd64..0a024e4195 100644 --- a/Content.Client/GameObjects/Components/Items/HandsComponent.cs +++ b/Content.Client/GameObjects/Components/Items/HandsComponent.cs @@ -139,7 +139,11 @@ namespace Content.Client.GameObjects.Components.Items if (entity == null) { - _sprite.LayerSetVisible($"hand-{name}", false); + if (_sprite.LayerMapTryGet($"hand-{name}", out var layer)) + { + _sprite.LayerSetVisible(layer, false); + } + return; } diff --git a/Content.Server/GameTicking/GameTickerCommands.cs b/Content.Server/GameTicking/GameTickerCommands.cs index 170da5fdd6..8b7676f08f 100644 --- a/Content.Server/GameTicking/GameTickerCommands.cs +++ b/Content.Server/GameTicking/GameTickerCommands.cs @@ -8,9 +8,11 @@ using Content.Shared.BodySystem; using Content.Shared.Jobs; using Robust.Server.Interfaces.Console; using Robust.Server.Interfaces.Player; +using Robust.Shared.Interfaces.Random; using Robust.Shared.IoC; using Robust.Shared.Network; using Robust.Shared.Prototypes; +using Robust.Shared.Random; using Robust.Shared.Utility; namespace Content.Server.GameTicking @@ -335,7 +337,7 @@ namespace Content.Server.GameTicking { if (player == null) { - shell.SendText(player, "Only a player can run this command."); + shell.SendText((IPlayerSession) null, "Only a player can run this command."); return; } @@ -345,9 +347,23 @@ namespace Content.Server.GameTicking return; } - var manager = player.AttachedEntity.GetComponent(); - var hand = manager.PartDictionary.First(x => x.Key == string.Join(" ", args)); - manager.InstallBodyPart(hand.Value, hand.Key + new Random()); + if (!player.AttachedEntity.TryGetComponent(out BodyManagerComponent body)) + { + var random = IoCManager.Resolve(); + var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}"; + + shell.SendText(player, text); + return; + } + + var prototypeManager = IoCManager.Resolve(); + prototypeManager.TryIndex("bodyPart.Hand.BasicHuman", out BodyPartPrototype prototype); + + var part = new BodyPart(prototype); + var slot = part.GetHashCode().ToString(); + + body.Template.Slots.Add(slot, BodyPartType.Hand); + body.InstallBodyPart(part, slot); } }