Fix editor link validation regressions

This commit is contained in:
2026-05-14 10:31:25 +02:00
parent ec8761f4e8
commit fbc26bb3b8
2 changed files with 6 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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 });
}