namespace ReactorMaintenance.Simulation; public sealed class PipeLeakEffect : ISimulationEffect { public CellState Apply(CellState cell) { if (!cell.HasPipe || cell.LeakRate <= Balancing.MinHazardValue) return cell; var hazards = cell.Pipe switch { EPipeMedium.Fuel => cell.Hazards with { LiquidFuel = cell.Hazards.LiquidFuel + cell.LeakRate, FuelVapor = cell.Hazards.FuelVapor + (cell.Pressure >= Balancing.PressurizedFuelLeakPressureThreshold ? cell.LeakRate : Math.Max(Balancing.MinHazardValue, cell.Hazards.Heat - Balancing.PassiveFuelVaporHeatOffset) / Balancing.PassiveFuelVaporDivisor) }, EPipeMedium.Coolant => cell.Hazards with { CoolantPooling = cell.Hazards.CoolantPooling + cell.LeakRate, Heat = cell.Hazards.Heat - Math.Max(Balancing.MinimumCoolantHeatReduction, cell.LeakRate / Balancing.CoolantHeatReductionDivisor), Smoke = cell.Hazards.Smoke + (cell.Hazards.Heat >= Balancing.CoolantSteamHeatThreshold ? Balancing.CoolantSteamSmokeIncrease : Balancing.MinHazardValue) }, EPipeMedium.Pressure => cell.Hazards with { Smoke = cell.Hazards.Smoke + (cell.Pressure >= Balancing.PressureLeakSmokeThreshold ? Balancing.PressureLeakSmokeIncrease : Balancing.MinHazardValue) }, _ => cell.Hazards }; return cell with { Hazards = hazards.Clamp() }; } }