public double managedPowerSupplyPerSecondWithMinimumRatio(IORSResourceSupplier pm, double maximum_power, double ratio_min) { var minimum_power_per_second = maximum_power * ratio_min; var provided_demand_power_per_second = Math.Min(maximum_power, (Math.Max(GetCurrentUnfilledResourceDemand(), minimum_power_per_second))); var required_power_per_second = Math.Max(GetRequiredResourceDemand(), minimum_power_per_second); var managed_supply_per_second = Math.Min(maximum_power, required_power_per_second); currentPowerSupply += managed_supply_per_second; stable_supply += maximum_power; PowerGenerated powerGenerated; if (!power_produced.TryGetValue(pm, out powerGenerated)) { powerGenerated = new PowerGenerated(); power_produced.Add(pm, powerGenerated); } powerGenerated.currentSupply += managed_supply_per_second; powerGenerated.currentProvided += provided_demand_power_per_second; powerGenerated.maximumSupply += maximum_power; powerGenerated.minimumSupply += minimum_power_per_second; return provided_demand_power_per_second; }
public double powerSupplyPerSecondWithMax(IORSResourceSupplier pm, double power, double maxpower) { currentPowerSupply += power; stable_supply += maxpower; PowerGenerated powerGenerated; if (!power_produced.TryGetValue(pm, out powerGenerated)) { powerGenerated = new PowerGenerated(); power_produced.Add(pm, powerGenerated); } powerGenerated.currentSupply += power; powerGenerated.maximumSupply += maxpower; return power; }
public double powerSupplyFixed(IORSResourceSupplier pm, double power) { var current_power_supply_per_second = power / TimeWarpFixedDeltaTime; currentPowerSupply += current_power_supply_per_second; stable_supply += current_power_supply_per_second; PowerGenerated powerGenerated; if (!power_produced.TryGetValue(pm, out powerGenerated)) { powerGenerated = new PowerGenerated(); power_produced.Add(pm, powerGenerated); } powerGenerated.currentSupply += current_power_supply_per_second; powerGenerated.currentProvided += current_power_supply_per_second; powerGenerated.maximumSupply += current_power_supply_per_second; return power; }
public double managedPowerSupplyFixedWithMinimumRatio(IORSResourceSupplier pm, double power, double ratio_min) { var maximum_available_power_per_second = power / TimeWarp.fixedDeltaTime; var minimum_power_per_second = maximum_available_power_per_second * ratio_min; var required_power_per_second = Math.Max(GetRequiredResourceDemand(), minimum_power_per_second); var managed_supply_per_second = Math.Min(maximum_available_power_per_second, required_power_per_second); currentPowerSupply += managed_supply_per_second; stable_supply += maximum_available_power_per_second; PowerGenerated powerGenerated; if (!power_produced.TryGetValue(pm, out powerGenerated)) { powerGenerated = new PowerGenerated(); power_produced.Add(pm, powerGenerated); } powerGenerated.currentSupply += managed_supply_per_second; powerGenerated.maximumSupply += maximum_available_power_per_second; powerGenerated.minimumSupply += minimum_power_per_second; return(managed_supply_per_second * TimeWarp.fixedDeltaTime); }