From 06f549d2827e13a586a284bbe78f3ee78a6b799f Mon Sep 17 00:00:00 2001 From: collinlunn <60152240+collinlunn@users.noreply.github.com> Date: Tue, 2 Mar 2021 11:58:19 -0700 Subject: [PATCH] Piping Unit test fixes (#3471) * PipeNetDevice on piping prototypes * client component ignore * NodeContainer OnRemove bugfix * Moves some NodeContainer code from OnRemove to Shutdown * yaml indentation fix --- Content.Client/IgnoredComponents.cs | 1 + .../Components/NodeContainer/NodeContainerComponent.cs | 7 ++++--- .../Components/NodeContainer/Nodes/AdjacentNode.cs | 6 ++++-- .../GameObjects/Components/NodeContainer/Nodes/Node.cs | 2 +- .../Components/NodeContainer/Nodes/PipeNode.cs | 10 ++++++---- .../Entities/Constructible/Piping/gascanisterports.yml | 1 + .../Entities/Constructible/Piping/gasfilters.yml | 1 + .../Entities/Constructible/Piping/gasgenerator.yml | 1 + .../Entities/Constructible/Piping/heaters.yml | 3 ++- .../Prototypes/Entities/Constructible/Piping/pumps.yml | 3 ++- .../Entities/Constructible/Piping/scrubbers.yml | 1 + .../Prototypes/Entities/Constructible/Piping/vents.yml | 1 + 12 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Content.Client/IgnoredComponents.cs b/Content.Client/IgnoredComponents.cs index 61a47e73c6..c2bb6cfe98 100644 --- a/Content.Client/IgnoredComponents.cs +++ b/Content.Client/IgnoredComponents.cs @@ -152,6 +152,7 @@ namespace Content.Client "VolumePump", "PressureSiphon", "PipeHeater", + "PipeNetDevice", "SignalReceiver", "SignalSwitch", "SignalTransmitter", diff --git a/Content.Server/GameObjects/Components/NodeContainer/NodeContainerComponent.cs b/Content.Server/GameObjects/Components/NodeContainer/NodeContainerComponent.cs index 16c85aa58c..8d8827837f 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/NodeContainerComponent.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/NodeContainerComponent.cs @@ -60,13 +60,14 @@ namespace Content.Server.GameObjects.Components.NodeContainer } } - public override void OnRemove() + protected override void Shutdown() { + base.Shutdown(); + foreach (var node in _nodes) { - node.OnContainerRemove(); + node.OnContainerShutdown(); } - base.OnRemove(); } private void AnchorUpdate() diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs index 07b0bcda68..a5ce141a19 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/AdjacentNode.cs @@ -11,8 +11,10 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes { protected override IEnumerable GetReachableNodes() { - var cells = Owner.GetComponent() - .GetCardinalNeighborCells(); + if (!Owner.TryGetComponent(out SnapGridComponent? grid)) + yield break; + + var cells = grid.GetCardinalNeighborCells(); foreach (var cell in cells) { diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs index 73bb4f0cb1..2c0fa4ec10 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/Node.cs @@ -74,7 +74,7 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes } } - public virtual void OnContainerRemove() + public virtual void OnContainerShutdown() { _deleting = true; NodeGroup.RemoveNode(this); diff --git a/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs b/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs index a4f497de63..b3361503db 100644 --- a/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs +++ b/Content.Server/GameObjects/Components/NodeContainer/Nodes/PipeNode.cs @@ -109,9 +109,9 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes UpdateAppearance(); } - public override void OnContainerRemove() + public override void OnContainerShutdown() { - base.OnContainerRemove(); + base.OnContainerShutdown(); UpdateAdjacentConnectedDirections(); } @@ -173,8 +173,10 @@ namespace Content.Server.GameObjects.Components.NodeContainer.Nodes /// private IEnumerable PipesInDirection(PipeDirection pipeDir) { - var entities = Owner.GetComponent() - .GetInDir(pipeDir.ToDirection()); + if (!Owner.TryGetComponent(out SnapGridComponent? grid)) + yield break; + + var entities = grid.GetInDir(pipeDir.ToDirection()); foreach (var entity in entities) { diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml b/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml index 7ddc8b1042..7c34e491c6 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gascanisterports.yml @@ -29,6 +29,7 @@ - !type:DoActsBehavior acts: ["Destruction"] - type: GasCanisterPort + - type: PipeNetDevice - type: entity parent: GasCanisterPortBase diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml b/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml index 626486ca08..159f6f6feb 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gasfilters.yml @@ -30,6 +30,7 @@ visuals: - type: PipeConnectorVisualizer - type: GasFilterVisualizer + - type: PipeNetDevice - type: entity parent: GasFilterBase diff --git a/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml b/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml index 028b736c17..17dd8c93d9 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/gasgenerator.yml @@ -23,6 +23,7 @@ - type: SnapGrid offset: Center - type: GasGenerator + - type: PipeNetDevice - type: entity parent: GasGeneratorBase diff --git a/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml b/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml index d71bff1d12..c2e8492fe0 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/heaters.yml @@ -30,4 +30,5 @@ - !type:PipeNode nodeGroupID: Pipe pipeDirection: East - - type: PipeHeater \ No newline at end of file + - type: PipeHeater + - type: PipeNetDevice \ No newline at end of file diff --git a/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml b/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml index 2be027d606..b0de3e1c1e 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/pumps.yml @@ -30,7 +30,8 @@ visuals: - type: PipeConnectorVisualizer - type: PumpVisualizer - + - type: PipeNetDevice + - type: entity parent: PumpBase id: DebugPressurePump diff --git a/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml b/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml index ed77fa53f8..56f81d8fdb 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/scrubbers.yml @@ -30,6 +30,7 @@ visuals: - type: PipeConnectorVisualizer - type: SiphonVisualizer + - type: PipeNetDevice - type: entity parent: ScrubberBase diff --git a/Resources/Prototypes/Entities/Constructible/Piping/vents.yml b/Resources/Prototypes/Entities/Constructible/Piping/vents.yml index 6081dd470d..6812a68dba 100644 --- a/Resources/Prototypes/Entities/Constructible/Piping/vents.yml +++ b/Resources/Prototypes/Entities/Constructible/Piping/vents.yml @@ -30,6 +30,7 @@ visuals: - type: PipeConnectorVisualizer - type: VentVisualizer + - type: PipeNetDevice - type: entity parent: VentBase