Station management commands (#5553)
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Roles;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
|
||||
[AdminCommand(AdminFlags.Spawn)]
|
||||
public class AdjustStationJobCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "adjstationjob";
|
||||
|
||||
public string Description => "Adjust the job manifest on a station.";
|
||||
|
||||
public string Help => "adjstationjob <station id> <job id> <amount>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 3)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
|
||||
if (!uint.TryParse(args[0], out var station) || !stationSystem.StationInfo.ContainsKey(new StationId(station)))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
if (!prototypeManager.TryIndex<JobPrototype>(args[1], out var job))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-must-be-prototype",
|
||||
("index", 2), ("prototypeName", nameof(JobPrototype))));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!int.TryParse(args[2], out var amount) || amount < -1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-number-must-be-between",
|
||||
("index", 3), ("lower", -1), ("upper", int.MaxValue)));
|
||||
return;
|
||||
}
|
||||
|
||||
stationSystem.AdjustJobsAvailableOnStation(new StationId(station), job, amount);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public class ListStationJobsCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "lsstationjobs";
|
||||
|
||||
public string Description => "Lists all jobs on the given station.";
|
||||
|
||||
public string Help => "lsstationjobs <station id>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
|
||||
if (!uint.TryParse(args[0], out var station) || !stationSystem.StationInfo.ContainsKey(new StationId(station)))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var (job, amount) in stationSystem.StationInfo[new StationId(station)].JobList)
|
||||
{
|
||||
shell.WriteLine($"{job}: {amount}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public class ListStationsCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "lsstations";
|
||||
|
||||
public string Description => "List all active stations";
|
||||
|
||||
public string Help => "lsstations";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
foreach (var (id, station) in EntitySystem.Get<StationSystem>().StationInfo)
|
||||
{
|
||||
shell.WriteLine($"{id.Id, -2} | {station.Name} | {station.MapPrototype.ID}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Content.Server.Station;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Station;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
|
||||
namespace Content.Server.Administration.Commands.Station;
|
||||
|
||||
[AdminCommand(AdminFlags.Admin)]
|
||||
public class RenameStationCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "renamestation";
|
||||
|
||||
public string Description => "Renames the given station";
|
||||
|
||||
public string Help => "renamestation <station id> <name>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length != 2)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
var stationSystem = EntitySystem.Get<StationSystem>();
|
||||
|
||||
if (!uint.TryParse(args[0], out var station) || !stationSystem.StationInfo.ContainsKey(new StationId(station)))
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-argument-station-id-invalid", ("index", 1)));
|
||||
return;
|
||||
}
|
||||
|
||||
stationSystem.RenameStation(new StationId(station), args[1]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user