Layering for atmospheric pipes (#36124)

Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
This commit is contained in:
chromiumboy
2025-06-02 00:01:43 -05:00
committed by GitHub
parent aa5ca90a3b
commit 45012cbe1d
134 changed files with 2671 additions and 306 deletions

View File

@@ -4,6 +4,7 @@ using Content.Server.NodeContainer;
using Content.Server.NodeContainer.Nodes;
using Content.Server.Popups;
using Content.Shared.Atmos;
using Content.Shared.Atmos.Components;
using Content.Shared.Construction.Components;
using Content.Shared.NodeContainer;
using JetBrains.Annotations;
@@ -97,27 +98,27 @@ public sealed class PipeRestrictOverlapSystem : EntitySystem
public bool PipeNodesOverlap(Entity<NodeContainerComponent, TransformComponent> ent, Entity<NodeContainerComponent, TransformComponent> other)
{
var entDirs = GetAllDirections(ent).ToList();
var otherDirs = GetAllDirections(other).ToList();
var entDirsAndLayers = GetAllDirectionsAndLayers(ent).ToList();
var otherDirsAndLayers = GetAllDirectionsAndLayers(other).ToList();
foreach (var dir in entDirs)
foreach (var (dir, layer) in entDirsAndLayers)
{
foreach (var otherDir in otherDirs)
foreach (var (otherDir, otherLayer) in otherDirsAndLayers)
{
if ((dir & otherDir) != 0)
if ((dir & otherDir) != 0 && layer == otherLayer)
return true;
}
}
return false;
IEnumerable<PipeDirection> GetAllDirections(Entity<NodeContainerComponent, TransformComponent> pipe)
IEnumerable<(PipeDirection, AtmosPipeLayer)> GetAllDirectionsAndLayers(Entity<NodeContainerComponent, TransformComponent> pipe)
{
foreach (var node in pipe.Comp1.Nodes.Values)
{
// we need to rotate the pipe manually like this because the rotation doesn't update for pipes that are unanchored.
if (node is PipeNode pipeNode)
yield return pipeNode.OriginalPipeDirection.RotatePipeDirection(pipe.Comp2.LocalRotation);
yield return (pipeNode.OriginalPipeDirection.RotatePipeDirection(pipe.Comp2.LocalRotation), pipeNode.CurrentPipeLayer);
}
}
}