From fbc26bb3b8994e6b677c2b1516f2ff020c913a9d Mon Sep 17 00:00:00 2001 From: Frank Tovar Date: Thu, 14 May 2026 10:31:25 +0200 Subject: [PATCH] Fix editor link validation regressions --- src/ReactorMaintenance.Simulation/LevelEditor.cs | 4 ++-- .../SimulationEngineTests.cs | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ReactorMaintenance.Simulation/LevelEditor.cs b/src/ReactorMaintenance.Simulation/LevelEditor.cs index 0f5dd9c..b1f971a 100644 --- a/src/ReactorMaintenance.Simulation/LevelEditor.cs +++ b/src/ReactorMaintenance.Simulation/LevelEditor.cs @@ -223,7 +223,7 @@ public static class LevelEditor return SetFloorProp(level, position, new() { Type = EPropType.SprinklerControl, SwitchState = EPropSwitchState.Enabled, - LinkedPosition = level.InBounds(linkedValve) && level.GetProp(linkedValve).Type == EPropType.SprinklerValve ? linkedValve : null + LinkedPosition = linkedValve is not null && level.GetProp(linkedValve).Type == EPropType.SprinklerValve ? linkedValve : null }); } @@ -238,7 +238,7 @@ public static class LevelEditor return level; var unlinkedControl = LevelTraversal.AllPositions(next).FirstOrDefault(candidate => next.GetProp(candidate) is { Type: EPropType.SprinklerControl, LinkedPosition: null }); - return next.InBounds(unlinkedControl) && next.GetProp(unlinkedControl).Type == EPropType.SprinklerControl + return unlinkedControl is not null && next.GetProp(unlinkedControl).Type == EPropType.SprinklerControl ? next.SetProp(unlinkedControl, next.GetProp(unlinkedControl) with { LinkedPosition = position }) : next; } diff --git a/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs b/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs index 00b5ca2..9401308 100644 --- a/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs +++ b/tests/ReactorMaintenance.Simulation.Tests/SimulationEngineTests.cs @@ -558,6 +558,10 @@ public sealed class SimulationEngineTests level = AddLine(level, ECarrierType.Electricity, new(2, 2), new(3, 2)); level = level.SetProp(new(2, 2), new() { Type = EPropType.Flow, Carrier = ECarrierType.Electricity }); } + else + { + level = level.SetUnderground(new(3, 2), ECarrierType.Electricity, new() { State = EUndergroundState.Intact }); + } return level.SetProp(new(3, 2), new() { Type = EPropType.Door, DoorState = EDoorState.Closed }); }