diff --git a/Content.Client/Atmos/Consoles/AtmosMonitoringConsoleNavMapControl.cs b/Content.Client/Atmos/Consoles/AtmosMonitoringConsoleNavMapControl.cs index 20902722ff..94bfb4b4f3 100644 --- a/Content.Client/Atmos/Consoles/AtmosMonitoringConsoleNavMapControl.cs +++ b/Content.Client/Atmos/Consoles/AtmosMonitoringConsoleNavMapControl.cs @@ -162,10 +162,10 @@ public sealed partial class AtmosMonitoringConsoleNavMapControl : NavMapControl { var list = new List(); - foreach (var ((netId, layer, hexColor), atmosPipeData) in chunk.AtmosPipeData) + foreach (var ((netId, layer, pipeColor), atmosPipeData) in chunk.AtmosPipeData) { // Determine the correct coloration for the pipe - var color = Color.FromHex(hexColor) * _basePipeNetColor; + var color = pipeColor * _basePipeNetColor; if (FocusNetId != null && FocusNetId != netId) color *= _unfocusedPipeNetColor; diff --git a/Content.Server/Atmos/Consoles/AtmosMonitoringConsoleSystem.cs b/Content.Server/Atmos/Consoles/AtmosMonitoringConsoleSystem.cs index 3cce1c956e..ebe79c6b5d 100644 --- a/Content.Server/Atmos/Consoles/AtmosMonitoringConsoleSystem.cs +++ b/Content.Server/Atmos/Consoles/AtmosMonitoringConsoleSystem.cs @@ -17,6 +17,7 @@ using Robust.Shared.Map.Components; using Robust.Shared.Timing; using System.Diagnostics.CodeAnalysis; using System.Linq; +using Content.Server.Atmos.EntitySystems; using Content.Shared.DeviceNetwork.Components; using Content.Shared.NodeContainer; @@ -53,6 +54,7 @@ public sealed class AtmosMonitoringConsoleSystem : SharedAtmosMonitoringConsoleS // Grid events SubscribeLocalEvent(OnGridSplit); + SubscribeLocalEvent(OnPipeNodeGroupRemoved); } #region Event handling @@ -295,6 +297,25 @@ public sealed class AtmosMonitoringConsoleSystem : SharedAtmosMonitoringConsoleS #region Pipe net functions + private void OnPipeNodeGroupRemoved(ref PipeNodeGroupRemovedEvent args) + { + // When a pipe node group is removed, we need to iterate over all of + // our pipe chunks and remove any entries with a matching net id. + // (We only need to check the chunks for the affected grid, though.) + + if (!_gridAtmosPipeChunks.TryGetValue(args.Grid, out var chunkData)) + return; + + foreach (var chunk in chunkData.Values) + { + foreach (var key in chunk.AtmosPipeData.Keys) + { + if (key.NetId == args.NetId) + chunk.AtmosPipeData.Remove(key); + } + } + } + private void RebuildAtmosPipeGrid(EntityUid gridUid, MapGridComponent grid) { var allChunks = new Dictionary(); @@ -411,7 +432,7 @@ public sealed class AtmosMonitoringConsoleSystem : SharedAtmosMonitoringConsoleS continue; var netId = GetPipeNodeNetId(pipeNode); - var subnet = new AtmosMonitoringConsoleSubnet(netId, pipeNode.CurrentPipeLayer, pipeColor.Color.ToHex()); + var subnet = new AtmosMonitoringConsoleSubnet(netId, pipeNode.CurrentPipeLayer, pipeColor.Color); var pipeDirection = pipeNode.CurrentPipeDirection; chunk.AtmosPipeData.TryGetValue(subnet, out var atmosPipeData); diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs index df31db6ba0..67f3a20779 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.API.cs @@ -279,6 +279,14 @@ public partial class AtmosphereSystem public bool RemovePipeNet(Entity grid, PipeNet pipeNet) { + // Technically this event can be fired even on grids that don't + // actually have grid atmospheres. + if (pipeNet.Grid is not null) + { + var ev = new PipeNodeGroupRemovedEvent(grid, pipeNet.NetId); + RaiseLocalEvent(ref ev); + } + return _atmosQuery.Resolve(grid, ref grid.Comp, false) && grid.Comp.PipeNets.Remove(pipeNet); } @@ -329,3 +337,12 @@ public partial class AtmosphereSystem [ByRefEvent] private record struct IsHotspotActiveMethodEvent (EntityUid Grid, Vector2i Tile, bool Result = false, bool Handled = false); } + + +/// +/// Raised broadcasted when a pipe node group within a grid has been removed. +/// +/// The grid with the removed node group. +/// The net id of the removed node group. +[ByRefEvent] +public record struct PipeNodeGroupRemovedEvent(EntityUid Grid, int NetId); diff --git a/Content.Shared/Atmos/Consoles/Components/AtmosMonitoringConsoleComponent.cs b/Content.Shared/Atmos/Consoles/Components/AtmosMonitoringConsoleComponent.cs index d01fb4e8bc..022a787ebd 100644 --- a/Content.Shared/Atmos/Consoles/Components/AtmosMonitoringConsoleComponent.cs +++ b/Content.Shared/Atmos/Consoles/Components/AtmosMonitoringConsoleComponent.cs @@ -234,9 +234,9 @@ public struct AtmosMonitoringConsoleEntry /// /// The associated network ID. /// The associated pipe layer. -/// The color of the pipe. +/// The color of the pipe. [Serializable, NetSerializable] -public record AtmosMonitoringConsoleSubnet(int NetId, AtmosPipeLayer PipeLayer, string HexCode); +public record AtmosMonitoringConsoleSubnet(int NetId, AtmosPipeLayer PipeLayer, Color Color); public enum AtmosPipeChunkDataFacing : byte {