Fix editor link validation regressions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user