6
2026-01-24 12:49:55 +03:00

46 lines
1.5 KiB
C#

using Content.Server.Administration;
using Content.Server._NF.Shipyard.Systems;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Utility;
namespace Content.Server._NF.Shipyard.Commands;
/// <summary>
/// Purchases a shuttle and docks it to a station.
/// </summary>
[AdminCommand(AdminFlags.Fun)]
public sealed class PurchaseShuttleCommand : IConsoleCommand
{
[Dependency] private readonly IEntitySystemManager _entityManager = default!;
public string Command => "purchaseshuttle";
public string Description => Loc.GetString("shipyard-commands-purchase-desc");
public string Help => $"{Command} <station ID> <gridfile path>";
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (!int.TryParse(args[0], out var stationId))
{
shell.WriteError($"{args[0]} is not a valid integer.");
return;
}
var shuttlePath = args[1];
var system = _entityManager.GetEntitySystem<ShipyardSystem>();
var station = new EntityUid(stationId);
system.TryPurchaseShuttle(station, new ResPath(shuttlePath), out _);
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
switch (args.Length)
{
case 1:
return CompletionResult.FromHint(Loc.GetString("station-id"));
case 2:
return CompletionResult.FromHint(Loc.GetString("cmd-hint-savemap-path"));
}
return CompletionResult.Empty;
}
}