Command resolve and LEC conversion batch 3 (#38378)

* I'm just a silly goober

* requested changes

* Update Content.Server/Interaction/TilePryCommand.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
Kyle Tyo
2025-06-17 05:39:42 -04:00
committed by GitHub
parent 1443cda4ff
commit d316fa3483
16 changed files with 148 additions and 148 deletions

View File

@@ -13,24 +13,24 @@ using Robust.Shared.Utility;
namespace Content.Server.Mapping
{
[AdminCommand(AdminFlags.Server | AdminFlags.Mapping)]
sealed class MappingCommand : IConsoleCommand
public sealed class MappingCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly IResourceManager _resourceMgr = default!;
[Dependency] private readonly SharedMapSystem _mapSystem = default!;
[Dependency] private readonly MappingSystem _mappingSystem = default!;
[Dependency] private readonly MapLoaderSystem _mapLoader = default!;
public string Command => "mapping";
public string Description => Loc.GetString("cmd-mapping-desc");
public string Help => Loc.GetString("cmd-mapping-help");
public override string Command => "mapping";
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
switch (args.Length)
{
case 1:
return CompletionResult.FromHint(Loc.GetString("cmd-hint-mapping-id"));
case 2:
var res = IoCManager.Resolve<IResourceManager>();
var opts = CompletionHelper.UserFilePath(args[1], res.UserData)
.Concat(CompletionHelper.ContentFilePath(args[1], res));
var opts = CompletionHelper.UserFilePath(args[1], _resourceMgr.UserData)
.Concat(CompletionHelper.ContentFilePath(args[1], _resourceMgr));
return CompletionResult.FromHintOptions(opts, Loc.GetString("cmd-hint-mapping-path"));
case 3:
return CompletionResult.FromHintOptions(["false", "true"], Loc.GetString("cmd-mapping-hint-grid"));
@@ -38,7 +38,7 @@ namespace Content.Server.Mapping
return CompletionResult.Empty;
}
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
@@ -65,7 +65,7 @@ namespace Content.Server.Mapping
MapId mapId;
string? toLoad = null;
var mapSys = _entities.System<SharedMapSystem>();
Entity<MapGridComponent>? grid = null;
// Get the map ID to use
@@ -86,7 +86,7 @@ namespace Content.Server.Mapping
return;
}
if (mapSys.MapExists(mapId))
if (_mapSystem.MapExists(mapId))
{
shell.WriteError(Loc.GetString("cmd-mapping-exists", ("mapId", mapId)));
return;
@@ -95,26 +95,25 @@ namespace Content.Server.Mapping
// either load a map or create a new one.
if (args.Length <= 1)
{
mapSys.CreateMap(mapId, runMapInit: false);
_mapSystem.CreateMap(mapId, runMapInit: false);
}
else
{
var path = new ResPath(args[1]);
toLoad = path.FilenameWithoutExtension;
var opts = new DeserializationOptions {StoreYamlUids = true};
var loader = _entities.System<MapLoaderSystem>();
if (isGrid == true)
{
mapSys.CreateMap(mapId, runMapInit: false);
if (!loader.TryLoadGrid(mapId, path, out grid, opts))
_mapSystem.CreateMap(mapId, runMapInit: false);
if (!_mapLoader.TryLoadGrid(mapId, path, out grid, opts))
{
shell.WriteError(Loc.GetString("cmd-mapping-error"));
mapSys.DeleteMap(mapId);
_mapSystem.DeleteMap(mapId);
return;
}
}
else if (!loader.TryLoadMapWithId(mapId, path, out _, out _, opts))
else if (!_mapLoader.TryLoadMapWithId(mapId, path, out _, out _, opts))
{
if (isGrid == false)
{
@@ -125,31 +124,29 @@ namespace Content.Server.Mapping
// isGrid was not specified and loading it as a map failed, so we fall back to trying to load
// the file as a grid
shell.WriteLine(Loc.GetString("cmd-mapping-try-grid"));
mapSys.CreateMap(mapId, runMapInit: false);
if (!loader.TryLoadGrid(mapId, path, out grid, opts))
_mapSystem.CreateMap(mapId, runMapInit: false);
if (!_mapLoader.TryLoadGrid(mapId, path, out grid, opts))
{
shell.WriteError(Loc.GetString("cmd-mapping-error"));
mapSys.DeleteMap(mapId);
_mapSystem.DeleteMap(mapId);
return;
}
}
}
// was the map actually created or did it fail somehow?
if (!mapSys.MapExists(mapId))
if (!_mapSystem.MapExists(mapId))
{
shell.WriteError(Loc.GetString("cmd-mapping-error"));
return;
}
}
else
{
mapSys.CreateMap(out mapId, runMapInit: false);
}
_mapSystem.CreateMap(out mapId, runMapInit: false);
// map successfully created. run misc helpful mapping commands
if (player.AttachedEntity is { Valid: true } playerEntity &&
_entities.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != GameTicker.AdminObserverPrototypeName)
EntityManager.GetComponent<MetaDataComponent>(playerEntity).EntityPrototype?.ID != GameTicker.AdminObserverPrototypeName)
{
shell.ExecuteCommand("aghost");
}
@@ -158,15 +155,14 @@ namespace Content.Server.Mapping
shell.ExecuteCommand("changecvar events.enabled false");
shell.ExecuteCommand("changecvar shuttle.auto_call_time 0");
var auto = _entities.System<MappingSystem>();
if (grid != null)
auto.ToggleAutosave(grid.Value.Owner, toLoad ?? "NEWGRID");
_mappingSystem.ToggleAutosave(grid.Value.Owner, toLoad ?? "NEWGRID");
else
auto.ToggleAutosave(mapId, toLoad ?? "NEWMAP");
_mappingSystem.ToggleAutosave(mapId, toLoad ?? "NEWMAP");
shell.ExecuteCommand($"tp 0 0 {mapId}");
shell.RemoteExecuteCommand("mappingclientsidesetup");
DebugTools.Assert(mapSys.IsPaused(mapId));
DebugTools.Assert(_mapSystem.IsPaused(mapId));
if (args.Length != 2)
shell.WriteLine(Loc.GetString("cmd-mapping-success", ("mapId", mapId)));