private PowerGenerated GetProductionRequest(IResourceSupplier pm, double maximum_power, double requiredDemand, double minPower)
        {
            double managedSupply = Math.Min(maximum_power, Math.Max(minPower, requiredDemand));

            current.Supply       += managedSupply;
            current.StableSupply += maximum_power;

            if (!productionRequests.TryGetValue(pm, out PowerGenerated powerGenerated))
            {
                productionRequests.Add(pm, powerGenerated = new PowerGenerated());
            }

            powerGenerated.CurrentSupply += managedSupply;
            powerGenerated.MaximumSupply += maximum_power;
            powerGenerated.MinimumSupply += minPower;

            return(powerGenerated);
        }
        public double powerSupplyPerSecondWithMaxAndEfficiency(IResourceSupplier pm, double power, double maxpower, double efficiencyRatio)
        {
            if (power.IsInfinityOrNaN() || maxpower.IsInfinityOrNaN() || efficiencyRatio.IsInfinityOrNaN())
            {
                return(0.0);
            }

            current.Supply       += power;
            current.StableSupply += maxpower;

            if (!productionRequests.TryGetValue(pm, out PowerGenerated powerGenerated))
            {
                productionRequests.Add(pm, powerGenerated = new PowerGenerated());
            }
            powerGenerated.CurrentSupply   += power;
            powerGenerated.CurrentProvided += power;
            powerGenerated.MaximumSupply   += maxpower;
            powerGenerated.EfficiencyRatio  = efficiencyRatio;

            return(power);
        }
Esempio n. 3
0
 public PowerGeneratedPair(IResourceSupplier key, PowerGenerated value)
 {
     Key   = key;
     Value = value;
 }