Fix addhand command (#1519)

This commit is contained in:
DrSmugleaf
2020-07-28 15:38:23 +02:00
committed by GitHub
parent c57b1c2914
commit 00d5effcb8
2 changed files with 25 additions and 5 deletions

View File

@@ -139,7 +139,11 @@ namespace Content.Client.GameObjects.Components.Items
if (entity == null) if (entity == null)
{ {
_sprite.LayerSetVisible($"hand-{name}", false); if (_sprite.LayerMapTryGet($"hand-{name}", out var layer))
{
_sprite.LayerSetVisible(layer, false);
}
return; return;
} }

View File

@@ -8,9 +8,11 @@ using Content.Shared.BodySystem;
using Content.Shared.Jobs; using Content.Shared.Jobs;
using Robust.Server.Interfaces.Console; using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player; using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility; using Robust.Shared.Utility;
namespace Content.Server.GameTicking namespace Content.Server.GameTicking
@@ -335,7 +337,7 @@ namespace Content.Server.GameTicking
{ {
if (player == null) 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; return;
} }
@@ -345,9 +347,23 @@ namespace Content.Server.GameTicking
return; return;
} }
var manager = player.AttachedEntity.GetComponent<BodyManagerComponent>(); if (!player.AttachedEntity.TryGetComponent(out BodyManagerComponent body))
var hand = manager.PartDictionary.First(x => x.Key == string.Join(" ", args)); {
manager.InstallBodyPart(hand.Value, hand.Key + new Random()); var random = IoCManager.Resolve<IRobustRandom>();
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
shell.SendText(player, text);
return;
}
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
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);
} }
} }