Revisions and cleanup to dock and shuttle commands. (#38533)

commit
This commit is contained in:
Kyle Tyo
2025-06-23 17:25:35 -04:00
committed by GitHub
parent b68c6b37ac
commit 6a2afa5625
6 changed files with 48 additions and 68 deletions

View File

@@ -9,24 +9,17 @@ namespace Content.Server.Shuttles.Commands;
/// Delays the round from ending via the shuttle call. Can still be ended via other means. /// Delays the round from ending via the shuttle call. Can still be ended via other means.
/// </summary> /// </summary>
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public sealed class DelayRoundEndCommand : IConsoleCommand public sealed class DelayRoundEndCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntitySystemManager _sysManager = default!; [Dependency] private readonly EmergencyShuttleSystem _shuttleSystem = default!;
public string Command => "delayroundend"; public override string Command => "delayroundend";
public string Description => Loc.GetString("emergency-shuttle-command-round-desc");
public string Help => $"{Command}"; public override void Execute(IConsoleShell shell, string argStr, string[] args)
public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var system = _sysManager.GetEntitySystem<EmergencyShuttleSystem>(); if (_shuttleSystem.DelayEmergencyRoundEnd())
if (system.DelayEmergencyRoundEnd())
{
shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-yes")); shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-yes"));
}
else else
{
shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-no")); shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-no"));
}
} }
} }

View File

@@ -7,70 +7,61 @@ using Robust.Shared.Console;
namespace Content.Server.Shuttles.Commands; namespace Content.Server.Shuttles.Commands;
[AdminCommand(AdminFlags.Mapping)] [AdminCommand(AdminFlags.Mapping)]
public sealed class DockCommand : IConsoleCommand public sealed class DockCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntityManager _entManager = default!; [Dependency] private readonly DockingSystem _dockSystem = default!;
public string Command => "dock"; public override string Command => "dock";
public string Description => Loc.GetString("cmd-dock-desc");
public string Help => Loc.GetString("cmd-dock-help"); public override void Execute(IConsoleShell shell, string argStr, string[] args)
public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
if (args.Length != 2) if (args.Length != 2)
{ {
shell.WriteError(Loc.GetString("cmd-dock-args")); shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific",
("properAmount", 2),
("currentAmount", args.Length)));
return; return;
} }
if (!NetEntity.TryParse(args[0], out var airlock1Net) || !_entManager.TryGetEntity(airlock1Net, out var airlock1)) if (!NetEntity.TryParse(args[0], out var airlock1Net) || !EntityManager.TryGetEntity(airlock1Net, out var airlock1))
{ {
shell.WriteError(Loc.GetString("cmd-dock-invalid", ("entity", args[0]))); shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[0])));
return; return;
} }
if (!NetEntity.TryParse(args[1], out var airlock2Net) || !_entManager.TryGetEntity(airlock2Net, out var airlock2)) if (!NetEntity.TryParse(args[1], out var airlock2Net) || !EntityManager.TryGetEntity(airlock2Net, out var airlock2))
{ {
shell.WriteError(Loc.GetString("cmd-dock-invalid", ("entity", args[1]))); shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[1])));
return; return;
} }
if (!_entManager.TryGetComponent(airlock1, out DockingComponent? dock1)) if (!EntityManager.TryGetComponent(airlock1, out DockingComponent? dock1))
{ {
shell.WriteError(Loc.GetString("cmd-dock-found", ("airlock", airlock1))); shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", args[0]), ("componentName", nameof(DockingComponent))));
return; return;
} }
if (!_entManager.TryGetComponent(airlock2, out DockingComponent? dock2)) if (!EntityManager.TryGetComponent(airlock2, out DockingComponent? dock2))
{ {
shell.WriteError(Loc.GetString("cmd-dock-found", ("airlock", airlock2))); shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", args[1]), ("componentName", nameof(DockingComponent))));
return; return;
} }
var dockSystem = _entManager.System<DockingSystem>(); _dockSystem.Dock((airlock1.Value, dock1), (airlock2.Value, dock2));
dockSystem.Dock((airlock1.Value, dock1), (airlock2.Value, dock2));
if (dock1.DockedWith == airlock2) if (dock1.DockedWith == airlock2)
{
shell.WriteLine(Loc.GetString("cmd-dock-success")); shell.WriteLine(Loc.GetString("cmd-dock-success"));
}
else else
{
shell.WriteError(Loc.GetString("cmd-dock-fail")); shell.WriteError(Loc.GetString("cmd-dock-fail"));
}
} }
public CompletionResult GetCompletion(IConsoleShell shell, string[] args) public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{ {
if (args.Length == 1) return args.Length switch
{ {
return CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[0], _entManager)); 1 => CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[0], EntityManager)),
} 2 => CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[1], EntityManager)),
_ => CompletionResult.Empty,
if (args.Length == 2) };
{
return CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[1], _entManager));
}
return CompletionResult.Empty;
} }
} }

View File

@@ -9,16 +9,14 @@ namespace Content.Server.Shuttles.Commands;
/// Calls in the emergency shuttle. /// Calls in the emergency shuttle.
/// </summary> /// </summary>
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public sealed class DockEmergencyShuttleCommand : IConsoleCommand public sealed class DockEmergencyShuttleCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntitySystemManager _sysManager = default!; [Dependency] private readonly EmergencyShuttleSystem _shuttleSystem = default!;
public string Command => "dockemergencyshuttle"; public override string Command => "dockemergencyshuttle";
public string Description => Loc.GetString("emergency-shuttle-command-dock-desc");
public string Help => $"{Command}"; public override void Execute(IConsoleShell shell, string argStr, string[] args)
public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var system = _sysManager.GetEntitySystem<EmergencyShuttleSystem>(); _shuttleSystem.DockEmergencyShuttle();
system.DockEmergencyShuttle();
} }
} }

View File

@@ -9,16 +9,14 @@ namespace Content.Server.Shuttles.Commands;
/// Early launches in the emergency shuttle. /// Early launches in the emergency shuttle.
/// </summary> /// </summary>
[AdminCommand(AdminFlags.Fun)] [AdminCommand(AdminFlags.Fun)]
public sealed class LaunchEmergencyShuttleCommand : IConsoleCommand public sealed class LaunchEmergencyShuttleCommand : LocalizedEntityCommands
{ {
[Dependency] private readonly IEntitySystemManager _sysManager = default!; [Dependency] private readonly EmergencyShuttleSystem _shuttleSystem = default!;
public string Command => "launchemergencyshuttle"; public override string Command => "launchemergencyshuttle";
public string Description => Loc.GetString("emergency-shuttle-command-launch-desc");
public string Help => $"{Command}"; public override void Execute(IConsoleShell shell, string argStr, string[] args)
public void Execute(IConsoleShell shell, string argStr, string[] args)
{ {
var system = _sysManager.GetEntitySystem<EmergencyShuttleSystem>(); _shuttleSystem.EarlyLaunch();
system.EarlyLaunch();
} }
} }

View File

@@ -4,8 +4,5 @@ docking-component-undock = Undock
cmd-dock-desc = Attempts to dock 2 airlocks together. Doesn't check whether it is valid. cmd-dock-desc = Attempts to dock 2 airlocks together. Doesn't check whether it is valid.
cmd-dock-help = dock <airlock entityuid1> <airlock entityuid2> cmd-dock-help = dock <airlock entityuid1> <airlock entityuid2>
cmd-dock-args = Invalid number of args
cmd-dock-invalid = Invalid EntityUid {$entity}
cmd-dock-found = No docking component found on {$airlock}
cmd-dock-success = Successfully docked cmd-dock-success = Successfully docked
cmd-dock-fail = Unable to dock cmd-dock-fail = Unable to dock

View File

@@ -1,14 +1,17 @@
# Commands # Commands
## Delay shuttle round end ## Delay shuttle round end
emergency-shuttle-command-round-desc = Stops the timer that ends the round when the emergency shuttle exits hyperspace. cmd-delayroundend-desc = Stops the timer that ends the round when the emergency shuttle exits hyperspace.
cmd-delayroundend-help = Usage: delayroundend
emergency-shuttle-command-round-yes = Round delayed. emergency-shuttle-command-round-yes = Round delayed.
emergency-shuttle-command-round-no = Unable to delay round end. emergency-shuttle-command-round-no = Unable to delay round end.
## Dock emergency shuttle ## Dock emergency shuttle
emergency-shuttle-command-dock-desc = Calls the emergency shuttle and docks it to the station... if it can. cmd-dockemergencyshuttle-desc = Calls the emergency shuttle and docks it to the station... if it can.
cmd-dockemergencyshuttle-help = Usage: dockemergencyshuttle
## Launch emergency shuttle ## Launch emergency shuttle
emergency-shuttle-command-launch-desc = Early launches the emergency shuttle if possible. cmd-launchemergencyshuttle-desc = Early launches the emergency shuttle if possible.
cmd-launchemergencyshuttle-help = Usage: launchemergencyshuttle
# Emergency shuttle # Emergency shuttle
emergency-shuttle-left = The Emergency Shuttle has left the station. Estimate {$transitTime} seconds until the shuttle arrives at CentComm. emergency-shuttle-left = The Emergency Shuttle has left the station. Estimate {$transitTime} seconds until the shuttle arrives at CentComm.
@@ -37,4 +40,4 @@ emergency-shuttle-ui-remaining = Remaining: {$remaining}
# Map Misc. # Map Misc.
map-name-centcomm = Central Command map-name-centcomm = Central Command
map-name-terminal = Arrivals Terminal map-name-terminal = Arrivals Terminal