2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.Administration.UI;
|
2025-06-18 19:50:10 -04:00
|
|
|
using Content.Server.Clothing.Systems;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.EUI;
|
2021-01-08 10:29:08 -03:00
|
|
|
using Content.Shared.Administration;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Inventory;
|
2021-02-01 16:49:43 -08:00
|
|
|
using Robust.Shared.Console;
|
2021-01-08 10:29:08 -03:00
|
|
|
|
|
|
|
|
namespace Content.Server.Administration.Commands
|
|
|
|
|
{
|
|
|
|
|
[AdminCommand(AdminFlags.Admin)]
|
2025-06-18 19:50:10 -04:00
|
|
|
public sealed class SetOutfitCommand : LocalizedEntityCommands
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
2025-06-18 19:50:10 -04:00
|
|
|
[Dependency] private readonly EuiManager _euiManager = default!;
|
|
|
|
|
[Dependency] private readonly OutfitSystem _outfitSystem = default!;
|
2023-03-13 00:40:02 +01:00
|
|
|
|
2025-06-18 19:50:10 -04:00
|
|
|
public override string Command => "setoutfit";
|
|
|
|
|
public override string Description => Loc.GetString("cmd-setoutfit-desc", ("requiredComponent", nameof(InventoryComponent)));
|
2021-01-08 10:29:08 -03:00
|
|
|
|
2025-06-18 19:50:10 -04:00
|
|
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
|
|
|
|
if (args.Length < 1)
|
|
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-wrong-arguments-number"));
|
2021-01-08 10:29:08 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 19:04:31 -05:00
|
|
|
if (!int.TryParse(args[0], out var entInt))
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-entity-uid-must-be-number"));
|
2021-01-08 10:29:08 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 19:04:31 -05:00
|
|
|
var nent = new NetEntity(entInt);
|
2021-01-08 10:29:08 -03:00
|
|
|
|
2025-06-18 19:50:10 -04:00
|
|
|
if (!EntityManager.TryGetEntity(nent, out var target))
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
2021-06-21 02:13:54 +02:00
|
|
|
shell.WriteLine(Loc.GetString("shell-invalid-entity-id"));
|
2021-01-08 10:29:08 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-18 19:50:10 -04:00
|
|
|
if (!EntityManager.HasComponent<InventoryComponent>(target))
|
2021-01-08 10:29:08 -03:00
|
|
|
{
|
2023-07-22 21:19:51 -07:00
|
|
|
shell.WriteLine(Loc.GetString("shell-target-entity-does-not-have-message", ("missing", "inventory")));
|
2021-01-08 10:29:08 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (args.Length == 1)
|
|
|
|
|
{
|
2023-10-28 09:59:53 +11:00
|
|
|
if (shell.Player is not { } player)
|
2021-02-14 11:39:53 -03:00
|
|
|
{
|
2025-06-18 19:50:10 -04:00
|
|
|
shell.WriteError(Loc.GetString("cmd-setoutfit-is-not-player-error"));
|
2021-02-14 11:39:53 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-03 19:04:31 -05:00
|
|
|
var ui = new SetOutfitEui(nent);
|
2025-06-18 19:50:10 -04:00
|
|
|
_euiManager.OpenEui(ui, player);
|
2021-01-08 10:29:08 -03:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-18 19:50:10 -04:00
|
|
|
if (!_outfitSystem.SetOutfit(target.Value, args[1]))
|
|
|
|
|
shell.WriteLine(Loc.GetString("cmd-setoutfit-invalid-outfit-id-error"));
|
2021-01-08 10:29:08 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|