Reorganize commands into the Commands folder (#2679)

* Reorganize commands into the Commands folder

* RIDER
This commit is contained in:
DrSmugleaf
2020-12-03 03:40:47 +01:00
committed by GitHub
parent 7905d93564
commit 87f9a6e167
69 changed files with 2817 additions and 2293 deletions

View File

@@ -0,0 +1,56 @@
#nullable enable
using System.Linq;
using Content.Server.Administration;
using Content.Shared.Administration;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Interfaces.Random;
using Robust.Shared.IoC;
using Robust.Shared.Random;
namespace Content.Server.Commands.Body
{
[AdminCommand(AdminFlags.Fun)]
class RemoveHandCommand : IClientCommand
{
public string Command => "removehand";
public string Description => "Removes a hand from your entity.";
public string Help => $"Usage: {Command}";
public void Execute(IConsoleShell shell, IPlayerSession? player, string[] args)
{
if (player == null)
{
shell.SendText(player, "Only a player can run this command.");
return;
}
if (player.AttachedEntity == null)
{
shell.SendText(player, "You have no entity.");
return;
}
if (!player.AttachedEntity.TryGetComponent(out IBody? body))
{
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 hand = body.Parts.FirstOrDefault(x => x.Value.PartType == BodyPartType.Hand);
if (hand.Value.Equals(default))
{
shell.SendText(player, "You have no hands.");
}
else
{
body.RemovePart(hand.Value);
}
}
}
}