From dc45f14536447dd6dd1c91fabb62ca1b90ac2e1d Mon Sep 17 00:00:00 2001 From: 20kdc Date: Tue, 17 May 2022 19:11:47 +0100 Subject: [PATCH] Underplating, go away (#8138) --- .../Commands/TileReplaceCommand.cs | 88 ++++++++++++++++++ .../Construction/Commands/TileWallsCommand.cs | 23 ++--- Resources/Prototypes/Tiles/plating.yml | 4 +- Resources/Textures/Tiles/copyright.txt | 5 +- Resources/Textures/Tiles/deprecated.png | Bin 0 -> 1383 bytes Resources/Textures/Tiles/underplating.png | Bin 302 -> 0 bytes 6 files changed, 102 insertions(+), 18 deletions(-) create mode 100644 Content.Server/Construction/Commands/TileReplaceCommand.cs create mode 100644 Resources/Textures/Tiles/deprecated.png delete mode 100644 Resources/Textures/Tiles/underplating.png 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 0000000000000000000000000000000000000000..90666ab23d89aa0b33953966d163685fc5e4c88e GIT binary patch literal 1383 zcmV-t1(^DYP)H6BPg|pNm>8^09ABF zSad^gZEa<4bO3Z{Wgs#zYh+^}WMyz+a&&EFZge1TW*}pAbY*U3b8{eKa%pa7b0B$d zbvg=Tb#!GQZEtmRWgvBKWMy)2Y+-b1Zf78OVRCM1Zf7CplH?}<00fgsL_t(Y$K_T_ zXk1ko{?Gf~JFlA98Jpsw3AD}5MJzT8aUn!$QX(NO11&`=Eh6<@>jPTRBHD^BYQ?$; zNFy#vDkh>?DD9$@x`?z;Vd^7d3n7{qW;!$XbzUy6q~m0orb6BLFD~cY^Z)1j{?|DN zS!>}=3Whr@|4#sf(8`tR^2^p*jGIXue|;N5Xoc0$T5o!Kx~r=z8IOIidu?HrBN$^O z2xZS>M*!fn_jeVa`(z~;%>boRsk^%y0KOZ0krFI8^&CzpF~%@T9Ko!$zs)T43?51R zyA1%X_2*-!hPM~5ojV+ca-mXJN;5_{qd^$w+p}65V=QA>a5leCyKn2;D*?EXgQ=;h z;qArCU%gtbg`AO988?j8*$Y>mIedCi=j^9X-<9>0GWqt*$)h`0l8L`HwAPf;OA{~G zgBT&?2OmaE5&)I2`;MT)`$jIDdZF$|+8Bay$`e0*bLdj(nza@z5R88K`ZY@F@=j2M z(A3lv0Q^zbvvU<=tm`mstWp{PYJL>O%3ABW+!!mB>h4;jl#ZoR+T7dGHaYU-@`0kI zQfcGHjiaNZJ9g~oTs!0lDgx#@%yT&al&ij!ni7mLas=ay06-AQAd*t)(l4_QJ+L8( zurY=Zvb1T?{QSI9s#dF&%jKS)o}&l0daiId&1KvmlsosIoH(%uA%rk;IQ3l4D5(dr zAH*1=zQ;fO`P)NRe*JyR6Ce4$&lsb$xpQ$Ul}e}6ZEfxOeE$6T^ZVZ!_k$>m^mJ!uXR`Fv zu15;1(3*U%E$1n1q%vA-W307+5J;uNFb05ZHaj>t*x%p3Y11a9RFaQ>RG8MfUawaw z6#!t28Dru&4#O}xotBr27cUkH1wx3mRtVvF9%HPn32FbJumHlv-;- z2g$wALD9!Z1`yan6Mh#u%kkLM4hKrIh11LWtYA(QbyclwbnilKX7~{5zqI zuY^X9$#@Yy88^{fM!)&lVy#Wqn!bsBqh+H)lkIZvqMJqVX1rGZOu~)4S{k>EOv`D@ pO>j#(O_6C?KaD1hR{wPs{RK&fk$iA6+J^uD002ovPDHLkV1oKWesll; literal 0 HcmV?d00001 diff --git a/Resources/Textures/Tiles/underplating.png b/Resources/Textures/Tiles/underplating.png deleted file mode 100644 index 18dfaca091d9ee00e69bf67c2bab68088b73a629..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 302 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnF3?v&v(vJfvi2$DvS2GJMVPUa=kT3};DK!mE zEgd}rBU42s6^EDBhk$A>db&7;z|+cJ#qfY*UcyAdf3qyUFs!Lyh<#tr z@;gece=pO;E%S8Ko8HHq0$=K7qlRWZdGitEdxxi|zriJfCm5i(HFs1Pdt)Hw6F zf9sN)<&*C)s2VYZJz)7DWs=C4V>@AD;}*uqMw7WIeR{_JpA$6i)%wrLH83tT@n-N7 z)t5T8m+OX%+`jgmKSgb%Ba||ao_)qpuNiUXZS(qC-mLo$GaCO&Xc`nJ&asF-dUe(% y2hG3#s$_zEZgAg>JL9rDCvW%d{crO__Ath|7EQmQ%pMQ)9D}E;pUXO@geCxzL~auR