using ReactorMaintenance.Simulation;

namespace ReactorMaintenance.Simulation.Effects;

public sealed class MachineEffect : ISimulationEffect
{
    public CellState Apply(CellState cell)
    {
        var hazards = cell.Prop switch {
            ECellProp.Generator when cell.Powered => cell.Hazards with { Heat = cell.Hazards.Heat + Balancing.Current.GeneratorHeatIncrease },
            ECellProp.CoolingPump when cell.Powered => cell.Hazards with { Heat = cell.Hazards.Heat - Balancing.Current.CoolingPumpHeatReduction },
            ECellProp.Reactor => cell.Hazards with { Heat = cell.Hazards.Heat + Balancing.Current.ReactorHeatIncrease },
            _ => cell.Hazards
        };

        return cell with { Hazards = hazards.Clamp() };
    }
}