Underplating, go away (#8138)
This commit is contained in:
88
Content.Server/Construction/Commands/TileReplaceCommand.cs
Normal file
88
Content.Server/Construction/Commands/TileReplaceCommand.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.Construction.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Mapping)]
|
||||
sealed class TileReplaceCommand : IConsoleCommand
|
||||
{
|
||||
// ReSharper disable once StringLiteralTypo
|
||||
public string Command => "tilereplace";
|
||||
public string Description => "Replaces one tile with another.";
|
||||
public string Help => $"Usage: {Command} [<gridId>] <src> <dst>";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||
GridId gridId;
|
||||
string tileIdA = "";
|
||||
string tileIdB = "";
|
||||
|
||||
switch (args.Length)
|
||||
{
|
||||
case 2:
|
||||
if (player?.AttachedEntity is not {Valid: true} playerEntity)
|
||||
{
|
||||
shell.WriteLine("Only a player can run this command without a grid ID.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = entityManager.GetComponent<TransformComponent>(playerEntity).GridID;
|
||||
tileIdA = args[0];
|
||||
tileIdB = args[1];
|
||||
break;
|
||||
case 3:
|
||||
if (!int.TryParse(args[0], out var id))
|
||||
{
|
||||
shell.WriteLine($"{args[0]} is not a valid integer.");
|
||||
return;
|
||||
}
|
||||
|
||||
gridId = new GridId(id);
|
||||
tileIdA = args[1];
|
||||
tileIdB = args[2];
|
||||
break;
|
||||
default:
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
var tileA = tileDefinitionManager[tileIdA];
|
||||
var tileB = tileDefinitionManager[tileIdB];
|
||||
|
||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||
if (!mapManager.TryGetGrid(gridId, out var grid))
|
||||
{
|
||||
shell.WriteLine($"No grid exists with id {gridId}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!entityManager.EntityExists(grid.GridEntityId))
|
||||
{
|
||||
shell.WriteLine($"Grid {gridId} doesn't have an associated grid entity.");
|
||||
return;
|
||||
}
|
||||
|
||||
var changed = 0;
|
||||
foreach (var tile in grid.GetAllTiles())
|
||||
{
|
||||
var tileContent = tile.Tile;
|
||||
if (tileContent.TypeId == tileA.TileId)
|
||||
{
|
||||
grid.SetTile(tile.GridIndices, new Tile(tileB.TileId));
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
|
||||
shell.WriteLine($"Changed {changed} tiles.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Tag;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Map;
|
||||
@@ -16,6 +17,9 @@ namespace Content.Server.Construction.Commands
|
||||
public string Description => "Puts an underplating tile below every wall on a grid.";
|
||||
public string Help => $"Usage: {Command} <gridId> | {Command}";
|
||||
|
||||
public const string TilePrototypeID = "plating";
|
||||
public const string WallTag = "Wall";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
@@ -61,8 +65,8 @@ namespace Content.Server.Construction.Commands
|
||||
}
|
||||
|
||||
var tileDefinitionManager = IoCManager.Resolve<ITileDefinitionManager>();
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
var underplating = tileDefinitionManager["underplating"];
|
||||
var tagSystem = EntitySystem.Get<TagSystem>();
|
||||
var underplating = tileDefinitionManager[TilePrototypeID];
|
||||
var underplatingTile = new Tile(underplating.TileId);
|
||||
var changed = 0;
|
||||
foreach (var child in entityManager.GetComponent<TransformComponent>(grid.GridEntityId).ChildEntities)
|
||||
@@ -72,18 +76,7 @@ namespace Content.Server.Construction.Commands
|
||||
continue;
|
||||
}
|
||||
|
||||
var prototype = entityManager.GetComponent<MetaDataComponent>(child).EntityPrototype;
|
||||
while (true)
|
||||
{
|
||||
if (prototype?.Parent == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
prototype = prototypeManager.Index<EntityPrototype>(prototype.Parent);
|
||||
}
|
||||
|
||||
if (prototype?.ID != "base_wall")
|
||||
if (!tagSystem.HasTag(child, WallTag))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -98,7 +91,7 @@ namespace Content.Server.Construction.Commands
|
||||
var tile = grid.GetTileRef(childTransform.Coordinates);
|
||||
var tileDef = (ContentTileDefinition) tileDefinitionManager[tile.Tile.TypeId];
|
||||
|
||||
if (tileDef.ID == "underplating")
|
||||
if (tileDef.ID == TilePrototypeID)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
# TODO kill underplating and all its usages since it is deprecated
|
||||
- type: tile
|
||||
id: underplating
|
||||
name: underplating
|
||||
texture: underplating
|
||||
name: haqrecyngvat [DO NOT USE]
|
||||
texture: deprecated
|
||||
base_turfs:
|
||||
- lattice
|
||||
is_subfloor: true
|
||||
|
||||
@@ -12,3 +12,6 @@ reinforced.png taken from /tg/ at commit https://github.com/tgstation/tgstation/
|
||||
ironsand1-4, junglegrass, eightiesred and eighties taken from TG station at https://github.com/tgstation/tgstation/commit/8abb19545828230d92ba18827feeb42a67a55d49
|
||||
arcadeblue edited by Peptide90 based on eightiestred from TG.
|
||||
shuttleblue, orange, purple, red and white taken from ParadiseSS13 at https://github.com/ParadiseSS13/Paradise/commit/69c831afcd9aef25a2889b507e4f36a3a5fc6def
|
||||
|
||||
deprecated.png made by 20kdc, licensed under SS14's MIT license - don't remove it, it's useful to make sure that maps with old tiles get noticed.
|
||||
|
||||
|
||||
BIN
Resources/Textures/Tiles/deprecated.png
Normal file
BIN
Resources/Textures/Tiles/deprecated.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 302 B |
Reference in New Issue
Block a user