Document code style and normalize files

This commit is contained in:
2026-05-08 21:10:46 +02:00
parent 2e813962c9
commit 5a261f5fe2
20 changed files with 1033 additions and 388 deletions

View File

@@ -1,6 +1,6 @@
namespace ReactorMaintenance.Simulation;
namespace ReactorMaintenance.Simulation;
public enum EditorTool
public enum EEditorTool
{
Floor,
Wall,
@@ -22,90 +22,76 @@ public enum EditorTool
public static class LevelEditor
{
public static LevelState Apply(LevelState level, GridPosition position, EditorTool tool)
public static LevelState Apply(LevelState level, GridPosition position, EEditorTool tool)
{
if (!level.InBounds(position))
return level;
if (tool == EditorTool.Robot)
if (tool == EEditorTool.Robot)
return level.GetCell(position).IsWalkable ? level with { Robot = position } : level;
var cell = level.GetCell(position);
cell = tool switch
{
EditorTool.Floor => cell with { Kind = CellKind.Floor },
EditorTool.Wall => cell with
{
Kind = CellKind.Wall,
Pipe = PipeMedium.None,
cell = tool switch {
EEditorTool.Floor => cell with { Kind = ECellKind.Floor },
EEditorTool.Wall => cell with {
Kind = ECellKind.Wall,
Pipe = EPipeMedium.None,
Powered = false
},
EditorTool.Reactor => cell with { Kind = CellKind.Reactor },
EditorTool.CoolingPump => cell with
{
Kind = CellKind.CoolingPump,
EEditorTool.Reactor => cell with { Kind = ECellKind.Reactor },
EEditorTool.CoolingPump => cell with {
Kind = ECellKind.CoolingPump,
Powered = true
},
EditorTool.Generator => cell with
{
Kind = CellKind.Generator,
EEditorTool.Generator => cell with {
Kind = ECellKind.Generator,
Powered = true
},
EditorTool.PressureRegulator => cell with { Kind = CellKind.PressureRegulator },
EditorTool.DiagnosticTerminal => cell with
{
Kind = CellKind.DiagnosticTerminal,
EEditorTool.PressureRegulator => cell with { Kind = ECellKind.PressureRegulator },
EEditorTool.DiagnosticTerminal => cell with {
Kind = ECellKind.DiagnosticTerminal,
Powered = true
},
EditorTool.ControlTerminal => cell with
{
Kind = CellKind.ControlTerminal,
EEditorTool.ControlTerminal => cell with {
Kind = ECellKind.ControlTerminal,
Powered = true
},
EditorTool.CoolantPipe => cell with
{
Pipe = PipeMedium.Coolant,
EEditorTool.CoolantPipe => cell with {
Pipe = EPipeMedium.Coolant,
Flow = 4,
Pressure = 4,
Integrity = Math.Max(cell.Integrity, 8),
PipeOpen = true
},
EditorTool.FuelPipe => cell with
{
Pipe = PipeMedium.Fuel,
EEditorTool.FuelPipe => cell with {
Pipe = EPipeMedium.Fuel,
Flow = 4,
Pressure = 4,
Integrity = Math.Max(cell.Integrity, 8),
PipeOpen = true
},
EditorTool.PressurePipe => cell with
{
Pipe = PipeMedium.Pressure,
EEditorTool.PressurePipe => cell with {
Pipe = EPipeMedium.Pressure,
Flow = 5,
Pressure = 6,
Integrity = Math.Max(cell.Integrity, 8),
PipeOpen = true
},
EditorTool.Leak => cell with
{
EEditorTool.Leak => cell with {
LeakRate = Math.Max(1, cell.LeakRate),
Integrity = Math.Min(cell.Integrity, 4)
},
EditorTool.Repair => cell with
{
EEditorTool.Repair => cell with {
LeakRate = 0,
Integrity = 10,
Hazards = cell.Hazards with
{
Hazards = cell.Hazards with {
Fire = false,
ElectricalCharge = 0
}
},
EditorTool.Heat => cell with { Hazards = cell.Hazards with { Heat = Rules.Clamp(cell.Hazards.Heat + 2) } },
EditorTool.Fire => cell with
{
Hazards = cell.Hazards with
{
EEditorTool.Heat => cell with { Hazards = cell.Hazards with { Heat = Rules.Clamp(cell.Hazards.Heat + 2) } },
EEditorTool.Fire => cell with {
Hazards = cell.Hazards with {
Fire = !cell.Hazards.Fire,
Heat = Math.Max(cell.Hazards.Heat, 7),
Smoke = Math.Max(cell.Hazards.Smoke, 3)
@@ -114,7 +100,7 @@ public static class LevelEditor
_ => cell
};
if (cell.Kind == CellKind.Wall)
if (cell.Kind == ECellKind.Wall)
cell = cell with { Hazards = new() };
return level.SetCell(position, cell);