-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8e2844
commit c9e0e5d
Showing
6 changed files
with
86 additions
and
9 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
Content.Server/Administration/Commands/SetStationAiName.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Content.Server.Station.Systems; | ||
using Content.Shared.Administration; | ||
using Content.Shared.Roles; | ||
using Robust.Shared.Console; | ||
using Robust.Shared.Prototypes; | ||
|
||
|
||
namespace Content.Server.Administration.Commands; | ||
|
||
|
||
[AdminCommand(AdminFlags.Admin)] | ||
public sealed class GetStationAiNameCommand : IConsoleCommand | ||
{ | ||
[Dependency] private readonly IEntityManager _entManager = default!; | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly StationSpawningSystem _spawning = default!; | ||
|
||
private ProtoId<JobPrototype> _stationAIJob = "StationAi"; | ||
|
||
public string Command => "setstationainame"; | ||
public string Description => Loc.GetString("set-station-ai-name-command-description"); | ||
public string Help => Loc.GetString("set-station-ai-name-command-help-text", ("command", Command)); | ||
|
||
public void Execute(IConsoleShell shell, string argStr, string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
shell.WriteError(Loc.GetString("shell-wrong-arguments-number")); | ||
return; | ||
} | ||
|
||
if (!int.TryParse(args[0], out var entInt)) | ||
{ | ||
shell.WriteLine(Loc.GetString("shell-entity-uid-must-be-number")); | ||
return; | ||
} | ||
|
||
var netEntity = new NetEntity(entInt); | ||
|
||
if (!_entManager.TryGetEntity(netEntity, out var target)) | ||
{ | ||
shell.WriteLine(Loc.GetString("shell-invalid-entity-id")); | ||
return; | ||
} | ||
|
||
var hasStationAi = _prototypeManager.TryIndex(_stationAIJob, out var job); | ||
|
||
if (!hasStationAi) | ||
{ | ||
shell.WriteLine(Loc.GetString("set-station-ai-name-command-no-station-ai")); | ||
return; | ||
} | ||
|
||
_spawning.EquipJobName(target.Value, job!); | ||
shell.WriteLine(Loc.GetString("shell-command-success")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
Resources/Locale/en-US/administration/commands/set-station-ai-name-command.ftl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set-station-ai-name-command-description = Sets a specific uid to be given a Station AI name at random. | ||
set-station-ai-name-command-help-text = Usage: {$command} <entityUid> | ||
set-station-ai-name-command-no-station-ai = No station AI job prototype found. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters