2020-12-03 03:40:47 +01:00
|
|
|
using System.Linq;
|
|
|
|
|
using Content.Server.Administration;
|
|
|
|
|
using Content.Shared.Administration;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Body.Components;
|
|
|
|
|
using Content.Shared.Body.Part;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Server.Player;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2021-12-03 14:17:01 +01:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Server.Body.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
[AdminCommand(AdminFlags.Fun)]
|
2022-02-16 00:23:23 -07:00
|
|
|
sealed class RemoveHandCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
public string Command => "removehand";
|
|
|
|
|
public string Description => "Removes a hand from your entity.";
|
|
|
|
|
public string Help => $"Usage: {Command}";
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
var player = shell.Player as IPlayerSession;
|
2020-12-03 03:40:47 +01:00
|
|
|
if (player == null)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("Only a player can run this command.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (player.AttachedEntity == null)
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("You have no entity.");
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-06 15:39:46 +11:00
|
|
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(player.AttachedEntity, out SharedBodyComponent? body))
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
|
|
|
|
var random = IoCManager.Resolve<IRobustRandom>();
|
|
|
|
|
var text = $"You have no body{(random.Prob(0.2f) ? " and you must scream." : ".")}";
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine(text);
|
2020-12-03 03:40:47 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-05 14:54:51 +02:00
|
|
|
var hand = body.GetPartsOfType(BodyPartType.Hand).FirstOrDefault();
|
|
|
|
|
|
2020-12-04 13:17:40 +01:00
|
|
|
if (hand == null)
|
2020-12-03 03:40:47 +01:00
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
shell.WriteLine("You have no hands.");
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2020-12-04 13:17:40 +01:00
|
|
|
body.RemovePart(hand);
|
2020-12-03 03:40:47 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|