This commit is contained in:
2026-05-11 21:51:18 +02:00
parent 1b9372ff7c
commit 5ddd1b8ec8
6 changed files with 30 additions and 89 deletions

View File

@@ -23,6 +23,7 @@ dotnet_sort_system_directives_first = false
file_header_template = # this. and Me. preferences file_header_template = # this. and Me. preferences
dotnet_style_qualification_for_event = false:suggestion dotnet_style_qualification_for_event = false:suggestion
dotnet_style_qualification_for_field = false:suggestion dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_method = false:suggestion dotnet_style_qualification_for_method = false:suggestion

View File

@@ -2,71 +2,8 @@
## Current State ## Current State
- Branch: `design-rewrite`
- Scope approved: implement `docs/design.md` end-to-end with deterministic defaults and no backward compatibility.
- Simulation core has been replaced with the first design-native model and deterministic engine slice.
- Simulation and test projects now target `net10.0` because this Linux environment only has the .NET 10 runtime.
- Win2D editor has been rewritten against the new design model.
- Win2D project now targets `net10.0-windows10.0.19041.0` to match the simulation project.
- Linux can restore and compile the referenced simulation project, but full WinUI/XAML compilation still requires a Windows-capable XAML compiler environment.
## Completed Work ## Completed Work
- Read project instructions, Linux instructions, code style, and `docs/design.md`.
- Confirmed deterministic balance defaults should be chosen during implementation.
- Confirmed a full Win2D editor is required.
- Created branch `design-rewrite`.
- Added `TASKS.md` as the required per-commit work tracker.
- Removed the legacy integer hazard/effect/hazard plug-in simulation surface.
- Added design-native terrain, underground carrier layers, surface hazards, props, leaks, doors, reactor bindings, robot inventory, rule events, validation, serialization, and forecasts.
- Added deterministic default balancing values.
- Added a first deterministic simulation pipeline for network propagation, consumers, leaks, surface interactions, robot safety, reactor readiness, rule events, and forecasts.
- Replaced old tests with design-based simulation tests.
- Verified `dotnet test tests/ReactorMaintenance.Simulation.Tests/ReactorMaintenance.Simulation.Tests.csproj` passes: 11 passed.
- Attempted `dotnet jb cleanupcode --build=False ...`; unavailable in this environment because `dotnet-jb` is not installed.
- Reviewed the first slice and fixed an action-resolution maintainability issue before commit.
- Verified `git diff --check` reports no whitespace errors.
- Ran `dotnet jb cleanupcode --build=False ...` successfully after ReSharper install and normalized line endings back to LF.
- Reworked the Win2D editor for the new model: full tool list, layer-aware painting, terrain, underground carriers, surface hazards, props, doors, leaks, robot, forecasts, save validation, starter level, and simple play actions.
- Removed old editor dependencies on legacy props, pressure pipes, smoke, fire, and global power/cooling/core-stability fields.
- Verified `dotnet test tests/ReactorMaintenance.Simulation.Tests/ReactorMaintenance.Simulation.Tests.csproj` passes after the editor rewrite: 11 passed.
- Attempted Win2D build on Linux with `dotnet build src/ReactorMaintenance.Win2D/ReactorMaintenance.Win2D.csproj -p:EnableWindowsTargeting=true -p:Platform=x64`; it fails at Windows `XamlCompiler.exe` with exec format error.
- Attempted managed XAML compiler path with `-p:UseXamlCompilerExecutable=false`; it fails loading the WinUI XAML compiler task dependency under this Linux/.NET 10 setup.
- Updated `README.md` for the new design-model editor, .NET 10 target, and Linux/Windows build expectations.
- Committed the Win2D editor rewrite slice.
- Added branch-aware junction flow analysis shared by validation and simulation propagation.
- Junction validation now rejects malformed branch counts and ambiguous source-side branches.
- Junction propagation now applies deterministic T-junction and cross-junction ratio weights only to inferred outgoing branches.
- Added tests for T-junction ratio splits, zero-weight branches, ambiguous junction validation, and best-path flow into non-junction cells.
- Verified `dotnet test tests/ReactorMaintenance.Simulation.Tests/ReactorMaintenance.Simulation.Tests.csproj` passes: 15 passed.
- Ran `jb cleanupcode --build=False ...` and `python D:\Code\crlf.py ...` for touched C# files after the junction slice.
- Expanded rule predicates with reactor readiness/loss/win, network value bands, and robot inventory checks.
- Expanded rule effects with removal of surface hazards, heat, and inventory, plus authored access positions for leak-start effects.
- Hardened rule event validation for predicate targets, effect targets, leak access, and non-negative amount effects.
- Added tests for network-band rules, reactor-ready rules, inventory rules, removal effects, electricity leak access, and invalid rule targets.
- Verified `dotnet test tests/ReactorMaintenance.Simulation.Tests/ReactorMaintenance.Simulation.Tests.csproj` passes after the rule slice: 21 passed.
- Ran `jb cleanupcode --build=False ...` and `python D:\Code\crlf.py ...` for touched C# files after the rule slice.
- Split serializable simulation records and enums from the monolithic `Models.cs` file into individual files under `Models`.
- Moved level creation, grid mutation helpers, surface clamping, grid geometry, and inventory operations out of serializable model records.
- Replaced separate T-junction and cross-junction props/tools with one topology-inferred `Junction` prop and one editor tool.
- Moved junction ratio presets into balancing data.
- Replaced hardcoded `EPairEffect` variants with parameterized surface interaction verbs and balance-owned magnitudes.
- Temporarily introduced and then removed a public `SimulationEngine` facade after review showed it was pure delegation.
- Updated design documentation for generic junctions and parameterized surface interactions.
- Removed the temporary `SimulationCoreSystem` catch-all and made `SimulationEngine` the real orchestration point.
- Split simulation behavior into purposeful systems for player actions, network propagation, consumers, leaks, surface interactions, robot safety, reactors, rule events, and forecasts.
- Kept `Systems` limited to behavior-owning systems; shared traversal, band, and carrier math helpers live at the simulation root.
- Replaced carrier-specific editor enum entries with parameterized editor commands.
- Added explicit editor workflows for door edge selection, electricity wall leak access-face selection, reactor consumer binding, and basic rule event authoring.
- Added editor operation tests plus broader junction validation and serialization round-trip coverage.
- Verified `dotnet test tests\ReactorMaintenance.Simulation.Tests\ReactorMaintenance.Simulation.Tests.csproj` passes: 27 passed.
- Verified `dotnet build src\ReactorMaintenance.Win2D\ReactorMaintenance.Win2D.csproj -p:Platform=x64 -p:EnableWindowsTargeting=true` succeeds on Windows.
- Ran `jb cleanupcode --build=False ...` and `python D:\Code\crlf.py ...` for touched files in the final rewrite slice.
## Current Work ## Current Work
- Rewrite task list completed on `design-rewrite`.
## Future Work ## Future Work
No known rewrite tasks remain.

View File

@@ -144,7 +144,7 @@ public static class LevelEditor
private static bool SameDoorEdge(DoorState door, GridPosition a, GridPosition b) private static bool SameDoorEdge(DoorState door, GridPosition a, GridPosition b)
{ {
return door.A == a && door.B == b || door.A == b && door.B == a; return (door.A == a && door.B == b) || (door.A == b && door.B == a);
} }
private static ReactorBinding BindConsumer(ReactorBinding reactor, ECarrierType carrier, GridPosition consumerPosition) private static ReactorBinding BindConsumer(ReactorBinding reactor, ECarrierType carrier, GridPosition consumerPosition)

View File

@@ -2,6 +2,24 @@
internal static class SurfaceInteractionSystem internal static class SurfaceInteractionSystem
{ {
private sealed class SurfaceDelta
{
public SurfaceState Apply(SurfaceState surface)
{
return surface with {
Fuel = surface.Fuel + Fuel,
Coolant = surface.Coolant + Coolant,
Electricity = surface.Electricity + Electricity,
Heat = surface.Heat + Heat
};
}
public float Fuel { get; set; }
public float Coolant { get; set; }
public float Electricity { get; set; }
public float Heat { get; set; }
}
public static LevelState Resolve(LevelState level) public static LevelState Resolve(LevelState level)
{ {
var deltas = Enumerable.Range(0, level.Width * level.Height).Select(_ => new SurfaceDelta()).ToArray(); var deltas = Enumerable.Range(0, level.Width * level.Height).Select(_ => new SurfaceDelta()).ToArray();
@@ -114,22 +132,4 @@ internal static class SurfaceInteractionSystem
break; break;
} }
} }
private sealed class SurfaceDelta
{
public SurfaceState Apply(SurfaceState surface)
{
return surface with {
Fuel = surface.Fuel + Fuel,
Coolant = surface.Coolant + Coolant,
Electricity = surface.Electricity + Electricity,
Heat = surface.Heat + Heat
};
}
public float Fuel { get; set; }
public float Coolant { get; set; }
public float Electricity { get; set; }
public float Heat { get; set; }
}
} }

View File

@@ -108,8 +108,10 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Content="Fuel" Click="BindFuel_Click" HorizontalAlignment="Stretch" /> <Button Content="Fuel" Click="BindFuel_Click" HorizontalAlignment="Stretch" />
<Button Grid.Column="1" Content="Coolant" Click="BindCoolant_Click" HorizontalAlignment="Stretch" /> <Button Grid.Column="1" Content="Coolant" Click="BindCoolant_Click"
<Button Grid.Column="2" Content="Electric" Click="BindElectricity_Click" HorizontalAlignment="Stretch" /> HorizontalAlignment="Stretch" />
<Button Grid.Column="2" Content="Electric" Click="BindElectricity_Click"
HorizontalAlignment="Stretch" />
</Grid> </Grid>
<TextBlock Text="Rule Events" FontSize="16" FontWeight="SemiBold" Foreground="#F4F1E8" /> <TextBlock Text="Rule Events" FontSize="16" FontWeight="SemiBold" Foreground="#F4F1E8" />
@@ -120,7 +122,8 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Button Content="Warn Next Turn" Click="AddWarningRule_Click" HorizontalAlignment="Stretch" /> <Button Content="Warn Next Turn" Click="AddWarningRule_Click" HorizontalAlignment="Stretch" />
<Button Grid.Column="1" Content="Leak Next Turn" Click="AddLeakRule_Click" HorizontalAlignment="Stretch" /> <Button Grid.Column="1" Content="Leak Next Turn" Click="AddLeakRule_Click"
HorizontalAlignment="Stretch" />
</Grid> </Grid>
<Button Content="Remove Last Rule" Click="RemoveLastRule_Click" HorizontalAlignment="Stretch" /> <Button Content="Remove Last Rule" Click="RemoveLastRule_Click" HorizontalAlignment="Stretch" />

View File

@@ -334,7 +334,7 @@ public sealed partial class MainWindow
private static Rect TilemapSourceRect(int wallMask) private static Rect TilemapSourceRect(int wallMask)
{ {
var tilePosition = wallMask switch { var tilePosition = wallMask switch {
c_BottomLeftCorner => new GridPosition(0, 0), c_BottomLeftCorner => new(0, 0),
c_TopRightCorner | c_BottomRightCorner => new(1, 0), c_TopRightCorner | c_BottomRightCorner => new(1, 0),
c_TopLeftCorner | c_BottomLeftCorner | c_BottomRightCorner => new(2, 0), c_TopLeftCorner | c_BottomLeftCorner | c_BottomRightCorner => new(2, 0),
c_BottomLeftCorner | c_BottomRightCorner => new(3, 0), c_BottomLeftCorner | c_BottomRightCorner => new(3, 0),
@@ -1005,11 +1005,11 @@ public sealed partial class MainWindow
private LevelState m_Level; private LevelState m_Level;
private double m_PanX; private double m_PanX;
private double m_PanY; private double m_PanY;
private GridPosition? m_PendingDoorCell;
private GridPosition? m_PendingElectricityLeakCell;
private CanvasBitmap? m_RobotSprite; private CanvasBitmap? m_RobotSprite;
private GridPosition? m_SelectedCell; private GridPosition? m_SelectedCell;
private int? m_SelectedReactorId = 1; private int? m_SelectedReactorId = 1;
private GridPosition? m_PendingDoorCell;
private GridPosition? m_PendingElectricityLeakCell;
private EditorToolCommand m_SelectedTool = new() { Tool = EEditorTool.Cursor }; private EditorToolCommand m_SelectedTool = new() { Tool = EEditorTool.Cursor };
private CanvasBitmap? m_TerrainTilemap; private CanvasBitmap? m_TerrainTilemap;
private double m_Zoom = 1; private double m_Zoom = 1;