Refactor simulation effects and forecast hazards

This commit is contained in:
2026-05-08 21:26:19 +02:00
parent 023d139281
commit 637e9f7fbc
14 changed files with 374 additions and 141 deletions

View File

@@ -0,0 +1,26 @@
namespace ReactorMaintenance.Simulation;
public sealed class PipeLeakEffect : ISimulationEffect
{
public CellState Apply(CellState cell)
{
if (!cell.HasPipe || cell.LeakRate <= 0)
return cell;
var hazards = cell.Pipe switch {
EPipeMedium.Fuel => cell.Hazards with {
LiquidFuel = cell.Hazards.LiquidFuel + cell.LeakRate,
FuelVapor = cell.Hazards.FuelVapor + (cell.Pressure >= 7 ? cell.LeakRate : Math.Max(0, cell.Hazards.Heat - 3) / 3)
},
EPipeMedium.Coolant => cell.Hazards with {
CoolantPooling = cell.Hazards.CoolantPooling + cell.LeakRate,
Heat = cell.Hazards.Heat - Math.Max(1, cell.LeakRate / 2),
Smoke = cell.Hazards.Smoke + (cell.Hazards.Heat >= 7 ? 2 : 0)
},
EPipeMedium.Pressure => cell.Hazards with { Smoke = cell.Hazards.Smoke + (cell.Pressure >= 8 ? 1 : 0) },
_ => cell.Hazards
};
return cell with { Hazards = hazards.Clamp() };
}
}