Remove obsolete functions from tile commands. (#31112)

* first part

* second part - file scope namespaces

* missing peice
This commit is contained in:
Mervill
2024-08-22 18:10:13 -07:00
committed by GitHub
parent e1093ca36f
commit 35c4e29db9
4 changed files with 244 additions and 244 deletions

View File

@@ -7,7 +7,7 @@ using Robust.Shared.Map.Components;
namespace Content.Server.Construction.Commands;
[AdminCommand(AdminFlags.Mapping)]
sealed class TileReplaceCommand : IConsoleCommand
public sealed class TileReplaceCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDef = default!;
@@ -27,9 +27,9 @@ sealed class TileReplaceCommand : IConsoleCommand
switch (args.Length)
{
case 2:
if (player?.AttachedEntity is not {Valid: true} playerEntity)
if (player?.AttachedEntity is not { Valid: true } playerEntity)
{
shell.WriteLine("Only a player can run this command without a grid ID.");
shell.WriteError("Only a player can run this command without a grid ID.");
return;
}
@@ -41,7 +41,7 @@ sealed class TileReplaceCommand : IConsoleCommand
if (!NetEntity.TryParse(args[0], out var idNet) ||
!_entManager.TryGetEntity(idNet, out var id))
{
shell.WriteLine($"{args[0]} is not a valid entity.");
shell.WriteError($"{args[0]} is not a valid entity.");
return;
}
@@ -59,23 +59,25 @@ sealed class TileReplaceCommand : IConsoleCommand
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
{
shell.WriteLine($"No grid exists with id {gridId}");
shell.WriteError($"No grid exists with id {gridId}");
return;
}
if (!_entManager.EntityExists(gridId))
{
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
shell.WriteError($"Grid {gridId} doesn't have an associated grid entity.");
return;
}
var mapSystem = _entManager.System<SharedMapSystem>();
var changed = 0;
foreach (var tile in grid.GetAllTiles())
foreach (var tile in mapSystem.GetAllTiles(gridId.Value, grid))
{
var tileContent = tile.Tile;
if (tileContent.TypeId == tileA.TileId)
{
grid.SetTile(tile.GridIndices, new Tile(tileB.TileId));
mapSystem.SetTile(gridId.Value, grid, tile.GridIndices, new Tile(tileB.TileId));
changed++;
}
}