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,11 +6,11 @@ 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
{
[AdminCommand(AdminFlags.Mapping)]
public sealed class FixRotationsCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
// ReSharper disable once StringLiteralTypo
@@ -27,7 +27,7 @@ namespace Content.Server.Construction.Commands
switch (args.Length)
{
case 0:
if (player?.AttachedEntity is not {Valid: true} playerEntity)
if (player?.AttachedEntity is not { Valid: true } playerEntity)
{
shell.WriteError("Only a player can run this command.");
return;
@@ -104,5 +104,4 @@ 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!;
@@ -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++;
}
}

View File

@@ -7,11 +7,11 @@ 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)]
public sealed class TileWallsCommand : IConsoleCommand
{
[AdminCommand(AdminFlags.Mapping)]
sealed class TileWallsCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
@@ -34,9 +34,9 @@ namespace Content.Server.Construction.Commands
switch (args.Length)
{
case 0:
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.");
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;
}
@@ -94,18 +94,17 @@ namespace Content.Server.Construction.Commands
var mapSystem = _entManager.System<MapSystem>();
var tile = mapSystem.GetTileRef(gridId.Value, grid, childTransform.Coordinates);
var tileDef = (ContentTileDefinition) _tileDefManager[tile.Tile.TypeId];
var tileDef = (ContentTileDefinition)_tileDefManager[tile.Tile.TypeId];
if (tileDef.ID == TilePrototypeId)
{
continue;
}
grid.SetTile(childTransform.Coordinates, underplatingTile);
mapSystem.SetTile(gridId.Value, grid, childTransform.Coordinates, underplatingTile);
changed++;
}
shell.WriteLine($"Changed {changed} tiles.");
}
}
}

View File

@@ -6,11 +6,11 @@ using Robust.Shared.Console;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
namespace Content.Server.Interaction
namespace Content.Server.Interaction;
[AdminCommand(AdminFlags.Debug)]
public sealed class TilePryCommand : IConsoleCommand
{
[AdminCommand(AdminFlags.Debug)]
sealed class TilePryCommand : IConsoleCommand
{
[Dependency] private readonly IEntityManager _entities = default!;
public string Command => "tilepry";
@@ -20,7 +20,7 @@ namespace Content.Server.Interaction
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
var player = shell.Player;
if (player?.AttachedEntity is not {} attached)
if (player?.AttachedEntity is not { } attached)
{
return;
}
@@ -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 tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
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));
}
}
}