diff --git a/TASKS.md b/TASKS.md index 8c08278..69f4753 100644 --- a/TASKS.md +++ b/TASKS.md @@ -44,9 +44,20 @@ - Verified after the simulation rework: - `dotnet test tests\ReactorMaintenance.Simulation.Tests\ReactorMaintenance.Simulation.Tests.csproj` passed with 23 tests, - `dotnet build ReactorMaintenance.slnx` passed with 0 warnings. +- Reworked the Win2D editor workflow: + - added the Surface/Electricity/Fuel/Coolant layer combobox, + - filtered tools by active layer and fixed exclusive tool selection, + - rendered underground networks as carrier-colored centerline networks with source dots and layer opacity rules, + - removed Rule Events, Reactor Binding, and pending workflow panels from the editor UI, + - replaced two-click electricity leak authoring with electric-layer leak access cycling, + - made Shift+left drag pan in all tools and Cursor drag move the robot or props. +- Added editor-helper tests for electricity leak access cycling and cursor drag movement behavior. +- Verified after the editor overhaul: + - `dotnet test tests\ReactorMaintenance.Simulation.Tests\ReactorMaintenance.Simulation.Tests.csproj` passed with 26 tests, + - `dotnet build ReactorMaintenance.slnx` passed with 0 warnings. ## Current Work -- Rework Win2D editor layer selection, rendering, tool filtering, drag behavior, and removed panels. +- Editor overhaul implementation is complete; commit is pending. ## Editor Overhaul Requirements - Add a layer combobox with Surface, Electricity, Fuel, and Coolant. diff --git a/src/ReactorMaintenance.Simulation/LevelEditor.cs b/src/ReactorMaintenance.Simulation/LevelEditor.cs index 821877a..4c79209 100644 --- a/src/ReactorMaintenance.Simulation/LevelEditor.cs +++ b/src/ReactorMaintenance.Simulation/LevelEditor.cs @@ -2,6 +2,52 @@ public static class LevelEditor { + public static LevelState MoveOccupant(LevelState level, GridPosition source, GridPosition destination) + { + if (!level.InBounds(source) || !level.IsFloor(destination) || source == destination) + return level; + + var prop = level.GetProp(source); + if (prop.Type == EPropType.None) + return level.Robot.Position == source ? level with { Robot = level.Robot with { Position = destination } } : level; + + if (level.GetProp(destination).Type != EPropType.None) + return level; + + var next = level.SetProp(source, new()).SetProp(destination, prop); + if (prop.Type != EPropType.ReactorControl) + return next; + + return next with { + Reactors = next.Reactors + .Select(reactor => reactor.ControlPosition == source ? reactor with { ControlPosition = destination } : reactor) + .ToArray() + }; + } + + public static LevelState CycleElectricityLeakAccess(LevelState level, GridPosition undergroundPosition) + { + if (!level.InBounds(undergroundPosition)) + return level; + + if (!level.GetUnderground(undergroundPosition, ECarrierType.Electricity).IsPresent) + return level; + + var accessPositions = undergroundPosition.Neighbors().Where(level.IsFloor).ToArray(); + if (accessPositions.Length == 0) + return level; + + var existingLeak = level.Leaks.FirstOrDefault(leak => leak.Carrier == ECarrierType.Electricity && leak.UndergroundPosition == undergroundPosition); + var nextAccessPosition = accessPositions[0]; + if (existingLeak is not null) + { + var index = Array.IndexOf(accessPositions, existingLeak.AccessPosition); + nextAccessPosition = accessPositions[(index + 1) % accessPositions.Length]; + } + + return SetLeak(level, undergroundPosition, nextAccessPosition, ECarrierType.Electricity); + } + public static LevelState Apply(LevelState level, GridPosition position, EditorToolCommand command) { if (!level.InBounds(position)) diff --git a/src/ReactorMaintenance.Win2D/MainWindow.xaml b/src/ReactorMaintenance.Win2D/MainWindow.xaml index a9c5a0a..b771e4d 100644 --- a/src/ReactorMaintenance.Win2D/MainWindow.xaml +++ b/src/ReactorMaintenance.Win2D/MainWindow.xaml @@ -30,6 +30,10 @@ + + @@ -51,10 +55,9 @@ - + @@ -96,37 +99,6 @@ - - - - - - - - - - - -