20 lines
851 B
C#
20 lines
851 B
C#
using ReactorMaintenance.Simulation;
|
|
|
|
namespace ReactorMaintenance.Simulation.Hazards;
|
|
|
|
public sealed class PipeBurstHazard : Hazard
|
|
{
|
|
public override IEnumerable<Forecast> Predict(LevelState level, int turns)
|
|
{
|
|
for (var y = Balancing.Current.FirstGridCoordinate; y < level.Height; y++)
|
|
{
|
|
for (var x = Balancing.Current.FirstGridCoordinate; x < level.Width; x++)
|
|
{
|
|
var position = new GridPosition(x, y);
|
|
var cell = level.GetCell(position);
|
|
if (cell is { HasPipe: true, PipeOpen: false } && cell.Flow == Balancing.Current.BrokenPipeFlow && cell.LeakRate >= Balancing.Current.BurstLeakRate)
|
|
yield return new(EFailureKind.PipeBurst, position, turns, $"PIPE BURST PREDICTED AT {x},{y} IN {turns} TURNS");
|
|
}
|
|
}
|
|
}
|
|
} |