Remove obsolete functions from tile commands. (#31112)
* first part * second part - file scope namespaces * missing peice
This commit is contained in:
@@ -6,8 +6,8 @@ using Content.Shared.Tag;
|
|||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
|
|
||||||
namespace Content.Server.Construction.Commands
|
namespace Content.Server.Construction.Commands;
|
||||||
{
|
|
||||||
[AdminCommand(AdminFlags.Mapping)]
|
[AdminCommand(AdminFlags.Mapping)]
|
||||||
public sealed class FixRotationsCommand : IConsoleCommand
|
public sealed class FixRotationsCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
@@ -105,4 +105,3 @@ namespace Content.Server.Construction.Commands
|
|||||||
shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect.");
|
shell.WriteLine($"Changed {changed} entities. If things seem wrong, reconnect.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using Robust.Shared.Map.Components;
|
|||||||
namespace Content.Server.Construction.Commands;
|
namespace Content.Server.Construction.Commands;
|
||||||
|
|
||||||
[AdminCommand(AdminFlags.Mapping)]
|
[AdminCommand(AdminFlags.Mapping)]
|
||||||
sealed class TileReplaceCommand : IConsoleCommand
|
public sealed class TileReplaceCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||||
[Dependency] private readonly ITileDefinitionManager _tileDef = default!;
|
[Dependency] private readonly ITileDefinitionManager _tileDef = default!;
|
||||||
@@ -29,7 +29,7 @@ sealed class TileReplaceCommand : IConsoleCommand
|
|||||||
case 2:
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +41,7 @@ sealed class TileReplaceCommand : IConsoleCommand
|
|||||||
if (!NetEntity.TryParse(args[0], out var idNet) ||
|
if (!NetEntity.TryParse(args[0], out var idNet) ||
|
||||||
!_entManager.TryGetEntity(idNet, out var id))
|
!_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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,23 +59,25 @@ sealed class TileReplaceCommand : IConsoleCommand
|
|||||||
|
|
||||||
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||||
{
|
{
|
||||||
shell.WriteLine($"No grid exists with id {gridId}");
|
shell.WriteError($"No grid exists with id {gridId}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_entManager.EntityExists(gridId))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var mapSystem = _entManager.System<SharedMapSystem>();
|
||||||
|
|
||||||
var changed = 0;
|
var changed = 0;
|
||||||
foreach (var tile in grid.GetAllTiles())
|
foreach (var tile in mapSystem.GetAllTiles(gridId.Value, grid))
|
||||||
{
|
{
|
||||||
var tileContent = tile.Tile;
|
var tileContent = tile.Tile;
|
||||||
if (tileContent.TypeId == tileA.TileId)
|
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++;
|
changed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ using Robust.Shared.Map;
|
|||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
|
|
||||||
namespace Content.Server.Construction.Commands
|
namespace Content.Server.Construction.Commands;
|
||||||
{
|
|
||||||
[AdminCommand(AdminFlags.Mapping)]
|
[AdminCommand(AdminFlags.Mapping)]
|
||||||
sealed class TileWallsCommand : IConsoleCommand
|
public sealed class TileWallsCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entManager = default!;
|
[Dependency] private readonly IEntityManager _entManager = default!;
|
||||||
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
[Dependency] private readonly ITileDefinitionManager _tileDefManager = default!;
|
||||||
@@ -36,7 +36,7 @@ namespace Content.Server.Construction.Commands
|
|||||||
case 0:
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ namespace Content.Server.Construction.Commands
|
|||||||
case 1:
|
case 1:
|
||||||
if (!NetEntity.TryParse(args[0], out var idNet) || !_entManager.TryGetEntity(idNet, out var id))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,13 +58,13 @@ namespace Content.Server.Construction.Commands
|
|||||||
|
|
||||||
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
if (!_entManager.TryGetComponent(gridId, out MapGridComponent? grid))
|
||||||
{
|
{
|
||||||
shell.WriteLine($"No grid exists with id {gridId}");
|
shell.WriteError($"No grid exists with id {gridId}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_entManager.EntityExists(gridId))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,11 +101,10 @@ namespace Content.Server.Construction.Commands
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
grid.SetTile(childTransform.Coordinates, underplatingTile);
|
mapSystem.SetTile(gridId.Value, grid, childTransform.Coordinates, underplatingTile);
|
||||||
changed++;
|
changed++;
|
||||||
}
|
}
|
||||||
|
|
||||||
shell.WriteLine($"Changed {changed} tiles.");
|
shell.WriteLine($"Changed {changed} tiles.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ using Robust.Shared.Console;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Map.Components;
|
using Robust.Shared.Map.Components;
|
||||||
|
|
||||||
namespace Content.Server.Interaction
|
namespace Content.Server.Interaction;
|
||||||
{
|
|
||||||
[AdminCommand(AdminFlags.Debug)]
|
[AdminCommand(AdminFlags.Debug)]
|
||||||
sealed class TilePryCommand : IConsoleCommand
|
public sealed class TilePryCommand : IConsoleCommand
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _entities = default!;
|
[Dependency] private readonly IEntityManager _entities = default!;
|
||||||
|
|
||||||
@@ -33,18 +33,19 @@ namespace Content.Server.Interaction
|
|||||||
|
|
||||||
if (!int.TryParse(args[0], out var radius))
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (radius < 0)
|
if (radius < 0)
|
||||||
{
|
{
|
||||||
shell.WriteLine("Radius must be positive.");
|
shell.WriteError("Radius must be positive.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
var mapSystem = _entities.System<SharedMapSystem>();
|
||||||
var xform = _entities.GetComponent<TransformComponent>(attached);
|
var xform = _entities.GetComponent<TransformComponent>(attached);
|
||||||
|
|
||||||
var playerGrid = xform.GridUid;
|
var playerGrid = xform.GridUid;
|
||||||
|
|
||||||
if (!_entities.TryGetComponent<MapGridComponent>(playerGrid, out var mapGrid))
|
if (!_entities.TryGetComponent<MapGridComponent>(playerGrid, out var mapGrid))
|
||||||
@@ -57,15 +58,14 @@ namespace Content.Server.Interaction
|
|||||||
{
|
{
|
||||||
for (var j = -radius; j <= radius; j++)
|
for (var j = -radius; j <= radius; j++)
|
||||||
{
|
{
|
||||||
var tile = mapGrid.GetTileRef(playerPosition.Offset(new Vector2(i, j)));
|
var tile = mapSystem.GetTileRef(playerGrid.Value, mapGrid, playerPosition.Offset(new Vector2(i, j)));
|
||||||
var coordinates = mapGrid.GridTileToLocal(tile.GridIndices);
|
var coordinates = mapSystem.GridTileToLocal(playerGrid.Value, mapGrid, tile.GridIndices);
|
||||||
var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.Tile.TypeId];
|
var tileDef = (ContentTileDefinition)tileDefinitionManager[tile.Tile.TypeId];
|
||||||
|
|
||||||
if (!tileDef.CanCrowbar) continue;
|
if (!tileDef.CanCrowbar) continue;
|
||||||
|
|
||||||
var plating = tileDefinitionManager["Plating"];
|
var plating = tileDefinitionManager["Plating"];
|
||||||
mapGrid.SetTile(coordinates, new Tile(plating.TileId));
|
mapSystem.SetTile(playerGrid.Value, mapGrid, coordinates, new Tile(plating.TileId));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user