MyGasGenerator PowerConsumption

slimeradio shared this bug 3 years ago
Outdated

Gas generator power consumption doesn't depend on how much gas it produces.

Here is a small code rework, that will make it.

private static float ComputeRequiredPower(MyGasGenerator generator) {
    if (!generator.Enabled || !generator.IsFunctional) { return 0f; }
    var def = (MyOxygenGeneratorDefinition) generator.BlockDefinition;
    if (!MySession.Static.Settings.EnableOxygen && def.ProducedGases.TrueForAll(info => info.Id == generator.m_oxygenGasId)) { return 0f; }
    
    float max = 0;
    foreach (var gas in def.ProducedGases) {
        var output = generator.SourceComp.CurrentOutputByType(gas.Id);
        var maxOutput = generator.SourceComp.MaxOutputByType(gas.Id);
        var current = output / maxOutput;
        if (current > max) {
            max = current;
        }
    }
    return MathHelper.Lerp(def.StandbyPowerConsumption, def.OperationalPowerConsumption, max) * (generator as IMyGasGenerator).PowerConsumptionMultiplier;
}

Replies (1)

photo
1

Hello, Engineer!


Thank you for your feedback! Your topic has been added between considered issues.

Please keep voting for the issue as it will help us to identify the most serious bugs.


We really appreciate your patience.


Kind Regards

Keen Software House: QA Department

Leave a Comment
 
Attach a file