Fix addhand command (#1519)
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user