diff --git a/Content.Server/Construction/Commands/TileReplaceCommand.cs b/Content.Server/Construction/Commands/TileReplaceCommand.cs new file mode 100644 index 0000000000..8a3ec6ca74 --- /dev/null +++ b/Content.Server/Construction/Commands/TileReplaceCommand.cs @@ -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} [] "; + + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + var player = shell.Player as IPlayerSession; + var entityManager = IoCManager.Resolve(); + 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(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(); + var tileA = tileDefinitionManager[tileIdA]; + var tileB = tileDefinitionManager[tileIdB]; + + var mapManager = IoCManager.Resolve(); + 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."); + } +} + diff --git a/Content.Server/Construction/Commands/TileWallsCommand.cs b/Content.Server/Construction/Commands/TileWallsCommand.cs index bcc4d18d4c..7f8ae1f610 100644 --- a/Content.Server/Construction/Commands/TileWallsCommand.cs +++ b/Content.Server/Construction/Commands/TileWallsCommand.cs @@ -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} | {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(); - var prototypeManager = IoCManager.Resolve(); - var underplating = tileDefinitionManager["underplating"]; + var tagSystem = EntitySystem.Get(); + var underplating = tileDefinitionManager[TilePrototypeID]; var underplatingTile = new Tile(underplating.TileId); var changed = 0; foreach (var child in entityManager.GetComponent(grid.GridEntityId).ChildEntities) @@ -72,18 +76,7 @@ namespace Content.Server.Construction.Commands continue; } - var prototype = entityManager.GetComponent(child).EntityPrototype; - while (true) - { - if (prototype?.Parent == null) - { - break; - } - - prototype = prototypeManager.Index(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; } diff --git a/Resources/Prototypes/Tiles/plating.yml b/Resources/Prototypes/Tiles/plating.yml index 073caaa662..321331daf2 100644 --- a/Resources/Prototypes/Tiles/plating.yml +++ b/Resources/Prototypes/Tiles/plating.yml @@ -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 diff --git a/Resources/Textures/Tiles/copyright.txt b/Resources/Textures/Tiles/copyright.txt index 7e9c6643c2..002ee174ba 100644 --- a/Resources/Textures/Tiles/copyright.txt +++ b/Resources/Textures/Tiles/copyright.txt @@ -11,4 +11,7 @@ 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 \ No newline at end of file +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. + diff --git a/Resources/Textures/Tiles/deprecated.png b/Resources/Textures/Tiles/deprecated.png new file mode 100644 index 0000000000..90666ab23d Binary files /dev/null and b/Resources/Textures/Tiles/deprecated.png differ diff --git a/Resources/Textures/Tiles/underplating.png b/Resources/Textures/Tiles/underplating.png deleted file mode 100644 index 18dfaca091..0000000000 Binary files a/Resources/Textures/Tiles/underplating.png and /dev/null differ