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

@@ -6,8 +6,8 @@ using Content.Shared.Tag;
using Robust.Shared.Console;
using Robust.Shared.Map.Components;
namespace Content.Server.Construction.Commands
{
namespace Content.Server.Construction.Commands;
[AdminCommand(AdminFlags.Mapping)]
public sealed class FixRotationsCommand : IConsoleCommand
{
@@ -105,4 +105,3 @@ namespace Content.Server.Construction.Commands
shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect.");
}
}
}

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!;
@@ -29,7 +29,7 @@ sealed class TileReplaceCommand : IConsoleCommand
case 2:
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++;
}
}

View File

@@ -7,10 +7,10 @@ using Robust.Shared.Map;
using Robust.Server.GameObjects;
using Robust.Shared.Map.Components;
namespace Content.Server.Construction.Commands
{
namespace Content.Server.Construction.Commands;
[AdminCommand(AdminFlags.Mapping)]
sealed class TileWallsCommand : IConsoleCommand
public sealed class TileWallsCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
@@ -36,7 +36,7 @@ namespace Content.Server.Construction.Commands
case 0:
if (player?.AttachedEntity is not { Valid: true } playerEntity)
{
shell.WriteLine("Only a player can run this command.");
shell.WriteError("Only a player can run this command.");
return;
}
@@ -45,7 +45,7 @@ namespace Content.Server.Construction.Commands
case 1:
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;
}
@@ -58,13 +58,13 @@ namespace Content.Server.Construction.Commands
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;
}
@@ -101,11 +101,10 @@ namespace Content.Server.Construction.Commands
continue;
}
grid.SetTile(childTransform.Coordinates, underplatingTile);
mapSystem.SetTile(gridId.Value, grid, childTransform.Coordinates, underplatingTile);
changed++;
}
shell.WriteLine($"Changed {changed} tiles.");
}
}
}

View File

@@ -6,10 +6,10 @@ using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Server.Interaction
{
namespace Content.Server.Interaction;
[AdminCommand(AdminFlags.Debug)]
sealed class TilePryCommand : IConsoleCommand
public sealed class TilePryCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
@@ -33,18 +33,19 @@ namespace Content.Server.Interaction
if (!int.TryParse(args[0], out var radius))
{
shell.WriteLine($"{args[0]} isn't a valid integer.");
shell.WriteError($"{args[0]} isn't a valid integer.");
return;
}
if (radius < 0)
{
shell.WriteLine("Radius must be positive.");
shell.WriteError("Radius must be positive.");
return;
}
var mapManager = IoCManager.Resolve<IMapManager>();
var mapSystem = _entities.System<SharedMapSystem>();
var xform = _entities.GetComponent<TransformComponent>(attached);
var playerGrid = xform.GridUid;
if (!_entities.TryGetComponent<MapGridComponent>(playerGrid, out var mapGrid))
@@ -57,15 +58,14 @@ namespace Content.Server.Interaction
{
for (var j = -radius; j <= radius; j++)
{
var tile = mapGrid.GetTileRef(playerPosition.Offset(new Vector2(i, j)));
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
var tile = mapSystem.GetTileRef(playerGrid.Value, mapGrid, playerPosition.Offset(new Vector2(i, j)));
var coordinates = mapSystem.GridTileToLocal(playerGrid.Value, mapGrid, tile.GridIndices);
var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.Tile.TypeId];
if (!tileDef.CanCrowbar) continue;
var plating = tileDefinitionManager["Plating"];
mapGrid.SetTile(coordinates, new Tile(plating.TileId));
}
mapSystem.SetTile(playerGrid.Value, mapGrid, coordinates, new Tile(plating.TileId));
}
}
}