Exemple #1
0
        public override string GetInfo()
        {
            double baseRate = 0d;

            for (int i = 0; i < inputs.Count; i++)
            {
                if (inputs[i].ResourceName == FuelName)
                {
                    baseRate = inputs[i].Ratio;
                }
            }
            if (HeatGeneration.Evaluate(100f) == 0)
            {
                return
                    (Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionEngine_PartInfo_Basic",
                                      ThrottleIncreaseRate.ToString("F0"),
                                      FindTimeRemaining(this.part.Resources.Get(PartResourceLibrary.Instance.GetDefinition(FuelName).id).amount, baseRate),
                                      NominalTemperature.ToString("F0"),
                                      CriticalTemperature.ToString("F0"),
                                      MaximumTemperature.ToString("F0")));
            }
            if (GeneratesElectricity)
            {
                return
                    (Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionEngine_PartInfo",
                                      ElectricalGeneration.Evaluate(100f).ToString("F0"),
                                      FindTimeRemaining(this.part.Resources.Get(PartResourceLibrary.Instance.GetDefinition(FuelName).id).amount, baseRate),
                                      (HeatGeneration.Evaluate(100f) - ElectricalGeneration.Evaluate(100f)).ToString("F0"),
                                      NominalTemperature.ToString("F0"),
                                      NominalTemperature.ToString("F0"),
                                      CriticalTemperature.ToString("F0"),
                                      MaximumTemperature.ToString("F0"),
                                      ThrottleIncreaseRate.ToString("F0"),
                                      MinimumThrottle.ToString("F0")));
            }
            else
            {
                return
                    (Localizer.Format("#LOC_SystemHeat_ModuleSystemHeatFissionEngine_PartInfo_NoPower",
                                      FindTimeRemaining(this.part.Resources.Get(PartResourceLibrary.Instance.GetDefinition(FuelName).id).amount, baseRate),
                                      HeatGeneration.Evaluate(100f).ToString("F0"),
                                      NominalTemperature.ToString("F0"),
                                      NominalTemperature.ToString("F0"),
                                      CriticalTemperature.ToString("F0"),
                                      MaximumTemperature.ToString("F0"),
                                      ThrottleIncreaseRate.ToString("F0"),
                                      MinimumThrottle.ToString("F0")));
            }
        }
Exemple #2
0
        /// <summary>
        /// Calculates the target reactor power level
        /// </summary>
        /// <param name="timeStep"></param>
        /// <returns></returns>
        protected override float CalculateGoalThrottle(float timeStep)
        {
            if (GeneratesElectricity)
            {
                part.GetConnectedResourceTotals(PartResourceLibrary.ElectricityHashcode, out double shipEC, out double shipMaxEC, true);

                float maxStepGeneration     = ElectricalGeneration.Evaluate(100f) * timeStep * CoreIntegrity / 100f;
                float minStepGeneration     = ElectricalGeneration.Evaluate(MinimumThrottle) * timeStep;
                float idealStepGeneration   = Mathf.Min(maxStepGeneration, (float)(shipMaxEC - shipEC));
                float powerToGenerateInStep = Mathf.Max(minStepGeneration, idealStepGeneration);
                float maxThrottleGeneration = (ElectricalGeneration.Curve.keys[ElectricalGeneration.Curve.keys.Length - 1].time) / 100f;
                return(Mathf.Max(GetEngineThrottleSetting(), Mathf.Clamp((powerToGenerateInStep) / maxStepGeneration, 0f, maxThrottleGeneration)) * 100f);
            }
            else
            {
                return(Mathf.Clamp(Mathf.Max(MinimumThrottle, GetEngineThrottleSetting() * 100f), 0f, 100f));
            }
        }
Exemple #3
0
        protected override float CalculateGoalThrottle(float timeStep)
        {
            if (GeneratesElectricity)
            {
                double shipEC    = 0d;
                double shipMaxEC = 0d;

                part.GetConnectedResourceTotals(PartResourceLibrary.ElectricityHashcode, out shipEC, out shipMaxEC, true);

                float maxGeneration   = ElectricalGeneration.Evaluate(100f) * CoreIntegrity / 100f;
                float minGeneration   = ElectricalGeneration.Evaluate(MinimumThrottle) * timeStep;
                float idealGeneration = Mathf.Min(maxGeneration * timeStep, (float)(shipMaxEC - shipEC));
                float powerToGenerate = Mathf.Max(Mathf.Max(minGeneration, idealGeneration));

                return(Mathf.Max(GetEngineThrottleSetting(), (powerToGenerate / timeStep) / maxGeneration) * 100f);
            }
            else
            {
                return(Mathf.Clamp(Mathf.Max(MinimumThrottle, GetEngineThrottleSetting() * 100f), 0f, 100f));
            }
        }