Exemplo n.º 1
0
        public override void OnUpdate()
        {
            //Update Events
            Events["ActivateReactor"].active   = !IsEnabled && !IsNuclear;
            Events["DeactivateReactor"].active = IsEnabled && !IsNuclear;
            Events["BreedTritium"].active      = !breedtritium && IsNeutronRich && IsEnabled;
            Events["StopBreedTritium"].active  = breedtritium && IsNeutronRich && IsEnabled;
            Events["RetrofitReactor"].active   = ResearchAndDevelopment.Instance != null ? !isupgraded && ResearchAndDevelopment.Instance.Science >= upgradeCost && hasrequiredupgrade : false;
            //Update Fields
            Fields["currentTPwr"].guiActive = IsEnabled && (ongoing_thermal_power_f > 0);
            Fields["currentCPwr"].guiActive = IsEnabled && (ongoing_charged_power_f > 0);
            fuelModeStr = current_fuel_mode != null ? current_fuel_mode.ModeGUIName : "";
            //
            reactorTypeStr = isupgraded ? upgradedName != "" ? upgradedName : originalName : originalName;
            coretempStr    = CoreTemperature.ToString("0") + " K";
            if (update_count - last_draw_update > 10)
            {
                if (IsEnabled)
                {
                    if (current_fuel_mode != null && !current_fuel_mode.ReactorFuels.Any(fuel => getFuelAvailability(fuel) <= 0))
                    {
                        if (ongoing_thermal_power_f > 0)
                        {
                            currentTPwr = PluginHelper.getFormattedPowerString(ongoing_thermal_power_f) + "_th";
                        }
                        if (ongoing_charged_power_f > 0)
                        {
                            currentCPwr = PluginHelper.getFormattedPowerString(ongoing_charged_power_f) + "_cp";
                        }
                        statusStr = "Active (" + powerPcnt.ToString("0.00") + "%)";
                    }
                    else if (current_fuel_mode != null)
                    {
                        statusStr = current_fuel_mode.ReactorFuels.FirstOrDefault(fuel => getFuelAvailability(fuel) <= 0).FuelName + " Deprived";
                    }
                }
                else
                {
                    if (powerPcnt > 0)
                    {
                        statusStr = "Decay Heating (" + powerPcnt.ToString("0.00") + "%)";
                    }
                    else
                    {
                        statusStr = "Offline";
                    }
                }

                last_draw_update = update_count;
            }
            if (!vessel.isActiveVessel || part == null)
            {
                RenderingManager.RemoveFromPostDrawQueue(0, OnGUI);
            }
            update_count++;
        }
Exemplo n.º 2
0
        public override void OnUpdate() // is called while in flight
        {
            update_count++;

            if (update_count < 9)
            {
                return;
            }

            update_count = 0;

            thermalPowerConvStrField.guiActive = convectedThermalPower > 0;

            // synchronize states
            if (_moduleDeployableRadiator != null && pivotEnabled && showControls)
            {
                if (_moduleDeployableRadiator.deployState == ModuleDeployableRadiator.DeployState.EXTENDED)
                {
                    radiatorIsEnabled = true;
                }
                else if (_moduleDeployableRadiator.deployState == ModuleDeployableRadiator.DeployState.RETRACTED)
                {
                    radiatorIsEnabled = false;
                }
            }

            radiatorIsEnabledField.guiActive       = showControls;
            radiatorIsEnabledField.guiActiveEditor = showControls;

            isAutomatedField.guiActive       = showControls;
            isAutomatedField.guiActiveEditor = showControls;

            pivotEnabledField.guiActive       = showControls;
            pivotEnabledField.guiActiveEditor = showControls;

            if (radiatorIsEnabled && canRadiateHeat)
            {
                thermalPowerDissipStr = PluginHelper.getFormattedPowerString(radiatedThermalPower, "0.0", "0.000");
                thermalPowerConvStr   = PluginHelper.getFormattedPowerString(convectedThermalPower, "0.0", "0.000");
            }
            else
            {
                thermalPowerDissipStr = "disabled";
                thermalPowerConvStr   = "disabled";
            }

            radiatorTempStr = CurrentRadiatorTemperature.ToString("0.0") + "K / " + maxCurrentTemperature.ToString("0.0") + "K";

            partTempStr = part.temperature.ToString("0.0") + "K / " + part.maxTemp.ToString("0.0") + "K";

            if (showColorHeat)
            {
                ColorHeat();
            }
        }
Exemplo n.º 3
0
        public override string GetInfo()
        {
            ConfigNode[]           fuelmodes          = GameDatabase.Instance.GetConfigNodes("REACTOR_FUEL_MODE");
            List <ReactorFuelMode> basic_fuelmodes    = fuelmodes.Select(node => new ReactorFuelMode(node)).Where(fm => (fm.SupportedReactorTypes & reactorType) == reactorType).ToList();
            List <ReactorFuelMode> advanced_fuelmodes = fuelmodes.Select(node => new ReactorFuelMode(node)).Where(fm => (fm.SupportedReactorTypes & (upgradedReactorType > 0 ? upgradedReactorType : reactorType)) == (upgradedReactorType > 0 ? upgradedReactorType : reactorType)).ToList();
            StringBuilder          sb = new StringBuilder();

            sb.AppendLine("BASIC REACTOR INFO");
            sb.AppendLine(originalName);
            sb.AppendLine("Thermal Power: " + PluginHelper.getFormattedPowerString(PowerOutput));
            sb.AppendLine("Heat Exchanger Temperature: " + ReactorTemp.ToString("0") + "K");
            sb.AppendLine("Fuel Burnup: " + (fuelEfficiency * 100.0).ToString("0.00") + "%");
            sb.AppendLine("BASIC FUEL MODES");
            basic_fuelmodes.ForEach(fm => {
                sb.AppendLine("---");
                sb.AppendLine(fm.ModeGUIName);
                sb.AppendLine("Power Multiplier: " + fm.NormalisedReactionRate.ToString("0.00"));
                sb.AppendLine("Charged Particle Ratio: " + fm.ChargedPowerRatio.ToString("0.00"));
                sb.AppendLine("Total Energy Density: " + fm.ReactorFuels.Sum(fuel => fuel.EnergyDensity).ToString("0.00") + " MJ/kg");
                foreach (ReactorFuel fuel in fm.ReactorFuels)
                {
                    sb.AppendLine(fuel.FuelName + " " + fuel.FuelUsePerMJ * PowerOutput * fm.NormalisedReactionRate * 86400.0 / fuelEfficiency + fuel.Unit + "/day");
                }
                sb.AppendLine("---");
            });
            if (IsUpgradeable)
            {
                sb.AppendLine("-----");
                sb.AppendLine("UPGRADED REACTOR INFO");
                sb.AppendLine(upgradedName);
                sb.AppendLine("Thermal Power: " + PluginHelper.getFormattedPowerString(upgradedPowerOutput));
                sb.AppendLine("Heat Exchanger Temperature: " + upgradedReactorTemp.ToString("0") + "K");
                sb.AppendLine("Fuel Burnup: " + (upgradedFuelEfficiency * 100.0).ToString("0.00") + "%");
                sb.AppendLine("UPGRADED FUEL MODES");
                advanced_fuelmodes.ForEach(fm => {
                    sb.AppendLine("---");
                    sb.AppendLine(fm.ModeGUIName);
                    sb.AppendLine("Power Multiplier: " + fm.NormalisedReactionRate.ToString("0.00"));
                    sb.AppendLine("Charged Particle Ratio: " + fm.ChargedPowerRatio.ToString("0.00"));
                    sb.AppendLine("Total Energy Density: " + fm.ReactorFuels.Sum(fuel => fuel.EnergyDensity).ToString("0.00") + " MJ/kg");
                    foreach (ReactorFuel fuel in fm.ReactorFuels)
                    {
                        sb.AppendLine(fuel.FuelName + " " + fuel.FuelUsePerMJ * upgradedPowerOutput * fm.NormalisedReactionRate * 86400.0 / upgradedFuelEfficiency + fuel.Unit + "/day");
                    }
                    sb.AppendLine("---");
                });
            }
            return(sb.ToString());
        }
 public override void OnUpdate()
 {
     if (getCurrentResourceDemand(FNResourceManager.FNRESOURCE_MEGAJOULES) > getStableResourceSupply(FNResourceManager.FNRESOURCE_MEGAJOULES) && getResourceBarRatio(FNResourceManager.FNRESOURCE_MEGAJOULES) < 0.1 && IsEnabled && !fusion_alert)
     {
         ScreenMessages.PostScreenMessage("Warning: Fusion Reactor plasma heating cannot be guaranteed, reducing power requirements is recommended.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
         fusion_alert = true;
     }
     else
     {
         fusion_alert = false;
     }
     Events["SwapFuelMode"].active = isupgraded;
     tokomakPower = PluginHelper.getFormattedPowerString(power_consumed);
     base.OnUpdate();
 }
        public override void OnUpdate()
        {
            if (!isSwappingFuelMode && getCurrentResourceDemand(FNResourceManager.FNRESOURCE_MEGAJOULES) > getStableResourceSupply(FNResourceManager.FNRESOURCE_MEGAJOULES) && getResourceBarRatio(FNResourceManager.FNRESOURCE_MEGAJOULES) < 0.1 && IsEnabled && !fusion_alert)
            {
                ScreenMessages.PostScreenMessage("Warning: Fusion Reactor plasma heating cannot be guaranteed, reducing power requirements is recommended.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                fusion_alert = true;
            }
            else
            {
                fusion_alert = false;
            }

            Fields["accumulatedChargeStr"].guiActive = plasma_ratio < 1;

            electricPowerMaintenance = PluginHelper.getFormattedPowerString(power_consumed) + " / " + PluginHelper.getFormattedPowerString(LaserPowerRequirements);
            base.OnUpdate();
        }
Exemplo n.º 6
0
 public void UpdateGUI()
 {
     if (_bold_label == null)
     {
         _bold_label           = new GUIStyle(GUI.skin.label);
         _bold_label.fontStyle = FontStyle.Bold;
     }
     GUILayout.BeginHorizontal();
     GUILayout.Label("Power", _bold_label, GUILayout.Width(150));
     GUILayout.Label(PluginHelper.getFormattedPowerString(CurrentPower) + "/" + PluginHelper.getFormattedPowerString(PowerRequirements), GUILayout.Width(150));
     if (_remaining_seconds > 0 && !double.IsNaN(_remaining_seconds) && !double.IsInfinity(_remaining_seconds))
     {
         int hrs  = (int)(_remaining_seconds / 3600);
         int mins = (int)((_remaining_seconds - hrs * 3600) / 60);
         int secs = (hrs * 60 + mins) % ((int)(_remaining_seconds / 60));
         GUILayout.Label("Time Remaining", _bold_label, GUILayout.Width(150));
         GUILayout.Label(hrs + " hours " + mins + " minutes " + secs + " seconds", GUILayout.Width(150));
     }
     GUILayout.EndHorizontal();
 }
 public void UpdateGUI()
 {
     if (_bold_label == null)
     {
         _bold_label           = new GUIStyle(GUI.skin.label);
         _bold_label.fontStyle = FontStyle.Bold;
     }
     GUILayout.BeginHorizontal();
     GUILayout.Label("Power", _bold_label, GUILayout.Width(150));
     GUILayout.Label(PluginHelper.getFormattedPowerString(CurrentPower) + "/" + PluginHelper.getFormattedPowerString(PowerRequirements), GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Water Consumption Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label((_water_consumption_rate * GameConstants.HOUR_SECONDS).ToString("0.000") + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Hydrogen Peroxide Production Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label((_hydrogen_peroxide_production_rate * GameConstants.HOUR_SECONDS).ToString("0.000") + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
 }
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (!isSwappingFuelMode && (!CheatOptions.InfiniteElectricity && getDemandStableSupply(ResourceManager.FNRESOURCE_MEGAJOULES) > 1.01) && IsEnabled && !fusion_alert)
            {
                fusionAlertFrames++;
            }
            else
            {
                fusion_alert      = false;
                fusionAlertFrames = 0;
            }

            if (fusionAlertFrames > 2)
            {
                ScreenMessages.PostScreenMessage("Warning: Fusion Reactor plasma heating cannot be guaranteed, reducing power requirements is recommended.", 0.1f, ScreenMessageStyle.UPPER_CENTER);
                fusion_alert = true;
            }

            electricPowerMaintenance = PluginHelper.getFormattedPowerString(power_consumed) + " / " + PluginHelper.getFormattedPowerString(HeatingPowerRequirements);
        }
Exemplo n.º 9
0
        public override void OnUpdate()
        {
            base.OnUpdate();
            if (!isSwappingFuelMode && getDemandStableSupply(FNResourceManager.FNRESOURCE_MEGAJOULES) > 1.01 && IsEnabled && !fusion_alert)
            {
                fusionAlertFrames++;
            }
            else
            {
                fusion_alert      = false;
                fusionAlertFrames = 0;
            }

            if (fusionAlertFrames > 2)
            {
                ScreenMessages.PostScreenMessage("Warning: Fusion Reactor plasma heating cannot be guaranteed, reducing power requirements is recommended.", 0.1f, ScreenMessageStyle.UPPER_CENTER);
                fusion_alert = true;
            }

            Events["SwapNextFuelMode"].active     = true;
            Events["SwapPreviousFuelMode"].active = true;
            tokomakPower = PluginHelper.getFormattedPowerString(power_consumed) + "/" + PluginHelper.getFormattedPowerString(HeatingPowerRequirements);
        }
 public void UpdateGUI()
 {
     if (_bold_label == null)
     {
         _bold_label           = new GUIStyle(GUI.skin.label);
         _bold_label.fontStyle = FontStyle.Bold;
     }
     GUILayout.BeginHorizontal();
     GUILayout.Label("Power", _bold_label, GUILayout.Width(150));
     GUILayout.Label(PluginHelper.getFormattedPowerString(CurrentPower) + "/" + PluginHelper.getFormattedPowerString(PowerRequirements), GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Alumina Consumption Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label(_alumina_consumption_rate * GameConstants.HOUR_SECONDS + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Aluminium Production Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label(_aluminium_production_rate * GameConstants.HOUR_SECONDS + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Oxygen Production Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label(_oxygen_production_rate * GameConstants.HOUR_SECONDS + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
 }
Exemplo n.º 11
0
 public void UpdateGUI()
 {
     if (_bold_label == null)
     {
         _bold_label           = new GUIStyle(GUI.skin.label);
         _bold_label.fontStyle = FontStyle.Bold;
     }
     GUILayout.BeginHorizontal();
     GUILayout.Label("Power", _bold_label, GUILayout.Width(150));
     GUILayout.Label(PluginHelper.getFormattedPowerString(CurrentPower) + "/" + PluginHelper.getFormattedPowerString(PowerRequirements), GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Ammona Consumption Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label(_ammonia_consumption_rate * GameConstants.HOUR_SECONDS + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Uranium Tetraflouride Consumption Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label(_uranium_tetraflouride_consumption_rate * GameConstants.HOUR_SECONDS + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     GUILayout.Label("Uranium Nitride Production Rate", _bold_label, GUILayout.Width(150));
     GUILayout.Label(_uranium_nitride_production_rate * GameConstants.HOUR_SECONDS + " mT/hour", GUILayout.Width(150));
     GUILayout.EndHorizontal();
 }
        private void Window(int windowID)
        {
            green_label = new GUIStyle(GUI.skin.label);
            green_label.normal.textColor = Color.green;
            red_label = new GUIStyle(GUI.skin.label);
            red_label.normal.textColor = Color.red;
            orange_label = new GUIStyle(GUI.skin.label);
            orange_label.normal.textColor = Color.yellow;
            bold_label           = new GUIStyle(GUI.skin.label);
            bold_label.fontStyle = FontStyle.Bold;

            if (GUI.Button(new Rect(windowPosition.width - 20, 2, 18, 18), "x"))
            {
                render_window = false;
            }

            GUIStyle radiator_label = green_label;

            if (rad_max_dissip < total_source_power)
            {
                radiator_label = orange_label;
                if (rad_max_dissip < min_source_power)
                {
                    radiator_label = red_label;
                }
            }

            GUILayout.BeginVertical();
            //GUILayout.BeginHorizontal();
            //GUILayout.Label("Distance from Kerbol: /AU (Kerbin = 1)", GUILayout.ExpandWidth(false), GUILayout.ExpandWidth(true));
            //GUILayout.EndHorizontal();
            //GUILayout.BeginHorizontal();
            //au_scale = GUILayout.HorizontalSlider((float)au_scale, 0.001f, 8f, GUILayout.ExpandWidth(true));
            //GUILayout.Label(au_scale.ToString("0.000")+ " AU", GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            //GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_TotalHeatProduction"), bold_label, GUILayout.ExpandWidth(true));//"Total Heat Production:"
            GUILayout.Label(PluginHelper.getFormattedPowerString(total_source_power), GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_ThermalSourceTemperature100"), bold_label, GUILayout.ExpandWidth(true));//"Thermal Source Temperature at 100%:"
            string source_temp_string = (source_temp_at_100pc < 0) ? "N/A" : source_temp_at_100pc.ToString("0.0") + " K";

            GUILayout.Label(source_temp_string, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_ThermalSourceTemperature30"), bold_label, GUILayout.ExpandWidth(true));//"Thermal Source Temperature at 30%:"
            string source_temp_string2 = (source_temp_at_30pc < 0) ? "N/A" : source_temp_at_30pc.ToString("0.0") + " K";

            GUILayout.Label(source_temp_string2, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_TotalNumberofRadiators"), bold_label, GUILayout.ExpandWidth(true));//"Total Number of Radiators:"
            GUILayout.Label(n_rads.ToString(), GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_TotalAreaRadiators"), bold_label, GUILayout.ExpandWidth(true));//"Total Area Radiators:"
            GUILayout.Label(total_area + " m\xB2", GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();


            GUILayout.BeginHorizontal();
            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_RadiatorMaximumDissipation"), bold_label, GUILayout.ExpandWidth(true));//"Radiator Maximum Dissipation:"
            GUILayout.Label(PluginHelper.getFormattedPowerString(rad_max_dissip), radiator_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            string resting_radiator_temp_at_100pcntStr = (!double.IsInfinity(resting_radiator_temp_at_100pcnt) && !double.IsNaN(resting_radiator_temp_at_100pcnt)) ? resting_radiator_temp_at_100pcnt.ToString("0.0") + " K" : "N/A";

            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_RadiatorRestingTemperatureat100"), bold_label, GUILayout.ExpandWidth(true));//"Radiator Resting Temperature at 100% Power:"
            GUILayout.Label(resting_radiator_temp_at_100pcntStr, radiator_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            string resting_radiator_temp_at_30pcntStr = (!double.IsInfinity(resting_radiator_temp_at_30pcnt) && !double.IsNaN(resting_radiator_temp_at_30pcnt)) ? resting_radiator_temp_at_30pcnt.ToString("0.0") + " K" : "N/A";

            GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_RadiatorRestingTemperatureat30"), bold_label, GUILayout.ExpandWidth(true));//"Radiator Resting Temperature at 30% Power:"
            GUILayout.Label(resting_radiator_temp_at_30pcntStr, radiator_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
            GUILayout.EndHorizontal();

            if (has_generators)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_RestingGeneratorEfficiencyat100"), bold_label, GUILayout.ExpandWidth(true));//"Resting Generator Efficiency at 100% Power:"
                GUILayout.Label((generator_efficiency_at_100pcnt * 100).ToString("0.00") + "%", radiator_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                GUILayout.Label(Localizer.Format("#LOC_KSPIE_VABThermalUI_RestingGeneratorEfficiencyat30"), bold_label, GUILayout.ExpandWidth(true));//"Resting Generator Efficiency at 30% Power:"
                GUILayout.Label((generator_efficiency_at_30pcnt * 100).ToString("0.00") + "%", radiator_label, GUILayout.ExpandWidth(false), GUILayout.MinWidth(80));
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Exemplo n.º 13
0
        public override void OnUpdate() // is called while in flight
        {
            update_count++;

            if (update_count < FRAME_DELAY)
            {
                return;
            }

            update_count = 0;

            if (_moduleDeployableRadiator != null && (_moduleDeployableRadiator.deployState == ModuleDeployablePart.DeployState.RETRACTED ||
                                                      _moduleDeployableRadiator.deployState == ModuleDeployablePart.DeployState.EXTENDED))
            {
                if (radiatorState != _moduleDeployableRadiator.deployState)
                {
                    part.SendMessage("GeometryPartModuleRebuildMeshData");
                    Debug.Log("[KSPI] - Updating geometry mesh due to radiator deployment.");
                }
                radiatorState = _moduleDeployableRadiator.deployState;
            }

            thermalPowerConvStrField.guiActive = convectedThermalPower > 0;

            // synchronize states
            if (_moduleDeployableRadiator != null && pivotEnabled && showControls)
            {
                if (_moduleDeployableRadiator.deployState == ModuleDeployableRadiator.DeployState.EXTENDED)
                {
                    radiatorIsEnabled = true;
                }
                else if (_moduleDeployableRadiator.deployState == ModuleDeployableRadiator.DeployState.RETRACTED)
                {
                    radiatorIsEnabled = false;
                }
            }

            radiatorIsEnabledField.guiActive       = showControls;
            radiatorIsEnabledField.guiActiveEditor = showControls;

            isAutomatedField.guiActive       = showControls;
            isAutomatedField.guiActiveEditor = showControls;

            pivotEnabledField.guiActive       = showControls;
            pivotEnabledField.guiActiveEditor = showControls;

            if (radiatorIsEnabled && canRadiateHeat)
            {
                thermalPowerDissipStr = PluginHelper.getFormattedPowerString(radiatedThermalPower, "0.0", "0.000");
                thermalPowerConvStr   = PluginHelper.getFormattedPowerString(convectedThermalPower, "0.0", "0.000");
            }
            else
            {
                thermalPowerDissipStr = "disabled";
                thermalPowerConvStr   = "disabled";
            }

            radiatorTempStr = CurrentRadiatorTemperature.ToString("0.0") + "K / " + maxCurrentTemperature.ToString("0.0") + "K";

            partTempStr = part.temperature.ToString("0.0") + "K / " + part.maxTemp.ToString("0.0") + "K";

            if (showColorHeat)
            {
                ColorHeat();
            }
        }
        public override void OnUpdate()
        {
            if (!CheatOptions.InfiniteElectricity && !isChargingForJumpstart && !isSwappingFuelMode && getCurrentResourceDemand(ResourceManager.FNRESOURCE_MEGAJOULES) > getStableResourceSupply(ResourceManager.FNRESOURCE_MEGAJOULES) && getResourceBarRatio(ResourceManager.FNRESOURCE_MEGAJOULES) < 0.1 && IsEnabled && !fusion_alert)
            {
                ScreenMessages.PostScreenMessage("Warning: Fusion Reactor plasma heating cannot be guaranteed, reducing power requirements is recommended.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                fusion_alert = true;
            }
            else
            {
                fusion_alert = false;
            }

            if (isChargingField.guiActive)
            {
                accumulatedChargeStr = PluginHelper.getFormattedPowerString(accumulatedElectricChargeInMW, "0.0", "0.000")
                                       + " / " + PluginHelper.getFormattedPowerString(StartupPower, "0.0", "0.000");
            }
            else if (part.vessel.geeForce > startupMaximumGeforce)
            {
                accumulatedChargeStr = part.vessel.geeForce.ToString("0.000") + "g > " + startupMaximumGeforce + "g";
            }
            else
            {
                accumulatedChargeStr = String.Empty;
            }

            accumulatedChargeStrField.guiActive = plasma_ratio < 1;

            electricPowerMaintenance = PluginHelper.getFormattedPowerString(power_consumed) + " / " + PluginHelper.getFormattedPowerString(LaserPowerRequirements);

            if (startupAnimation != null && !initialized)
            {
                if (IsEnabled)
                {
                    //animationScalar = startupAnimation.GetScalar;
                    if (animationStarted == 0)
                    {
                        startupAnimation.ToggleAction(new KSPActionParam(KSPActionGroup.Custom01, KSPActionType.Activate));
                        animationStarted = Planetarium.GetUniversalTime();
                    }
                    else if (!startupAnimation.IsMoving())
                    {
                        startupAnimation.ToggleAction(new KSPActionParam(KSPActionGroup.Custom01, KSPActionType.Deactivate));
                        animationStarted = 0;
                        initialized      = true;
                        isDeployed       = true;
                    }
                }
                else // Not Enabled
                {
                    // continiously start
                    startupAnimation.ToggleAction(new KSPActionParam(KSPActionGroup.Custom01, KSPActionType.Activate));
                    startupAnimation.ToggleAction(new KSPActionParam(KSPActionGroup.Custom01, KSPActionType.Deactivate));
                }
            }
            else if (startupAnimation == null)
            {
                isDeployed = true;
            }

            // call base class
            base.OnUpdate();
        }
Exemplo n.º 15
0
        /// <summary>
        /// Is called by KSP while the part is active
        /// </summary>
        public override void OnUpdate()
        {
            powerCustomSettingFraction = powerPercentage / 100;

            Events["ActivateGenerator"].active    = !IsEnabled && showSpecialisedUI;
            Events["DeactivateGenerator"].active  = IsEnabled && showSpecialisedUI;
            Fields["OverallEfficiency"].guiActive = IsEnabled;
            Fields["MaxPowerStr"].guiActive       = IsEnabled;
            Fields["coldBathTemp"].guiActive      = !chargedParticleMode;
            Fields["hotBathTemp"].guiActive       = !chargedParticleMode;

            if (ResearchAndDevelopment.Instance != null)
            {
                Events["RetrofitGenerator"].active = !isupgraded && ResearchAndDevelopment.Instance.Science >= upgradeCost && hasrequiredupgrade;
                upgradeCostStr = ResearchAndDevelopment.Instance.Science.ToString("0") + " / " + upgradeCost;
            }
            else
            {
                Events["RetrofitGenerator"].active = false;
            }

            Fields["upgradeCostStr"].guiActive = !isupgraded && hasrequiredupgrade;

            if (IsEnabled)
            {
                if (play_up && anim != null)
                {
                    play_down                     = true;
                    play_up                       = false;
                    anim[animName].speed          = 1f;
                    anim[animName].normalizedTime = 0f;
                    anim.Blend(animName, 2f);
                }
            }
            else
            {
                if (play_down && anim != null)
                {
                    play_down                     = false;
                    play_up                       = true;
                    anim[animName].speed          = -1f;
                    anim[animName].normalizedTime = 1f;
                    anim.Blend(animName, 2f);
                }
            }

            if (IsEnabled)
            {
                double percentOutputPower = _totalEff * 100.0;
                double outputPowerReport  = -outputPower;
                if (update_count - last_draw_update > 10)
                {
                    OutputPower       = PluginHelper.getFormattedPowerString(outputPowerReport, "0.0", "0.000");
                    OverallEfficiency = percentOutputPower.ToString("0.00") + "%";

                    MaxPowerStr = (_totalEff >= 0)
                        ? !chargedParticleMode
                            ? PluginHelper.getFormattedPowerString(maxThermalPower *_totalEff *powerCustomSettingFraction, "0.0", "0.000")
                            : PluginHelper.getFormattedPowerString(maxChargedPower * _totalEff * powerCustomSettingFraction, "0.0", "0.000")
                        : (0).ToString() + "MW";

                    last_draw_update = update_count;
                }
            }
            else
            {
                OutputPower = "Generator Offline";
            }

            update_count++;
        }
Exemplo n.º 16
0
 private void Window(int windowID)
 {
     bold_label           = new GUIStyle(GUI.skin.label);
     bold_label.fontStyle = FontStyle.Bold;
     if (GUI.Button(new Rect(windowPosition.width - 20, 2, 18, 18), "x"))
     {
         render_window = false;
     }
     GUILayout.BeginVertical();
     GUILayout.BeginHorizontal();
     GUILayout.Label(TypeName, bold_label, GUILayout.ExpandWidth(true));
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (ChargedParticleRatio < 1.0)
     {
         GUILayout.Label("Current Thermal Power", bold_label, GUILayout.Width(150));
         GUILayout.Label(currentTPwr, GUILayout.Width(150));
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         GUILayout.Label("Max Thermal Power", bold_label, GUILayout.Width(150));
         GUILayout.Label(PluginHelper.getFormattedPowerString(MaximumThermalPower) + "_th", GUILayout.Width(150));
         GUILayout.EndHorizontal();
     }
     if (ChargedParticleRatio > 0)
     {
         GUILayout.BeginHorizontal();
         GUILayout.Label("Current Charged Power", bold_label, GUILayout.Width(150));
         GUILayout.Label(currentCPwr, GUILayout.Width(150));
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         GUILayout.Label("Max Charged Power", bold_label, GUILayout.Width(150));
         GUILayout.Label(PluginHelper.getFormattedPowerString(MaximumChargedPower) + "_cp", GUILayout.Width(150));
         GUILayout.EndHorizontal();
     }
     if (current_fuel_mode != null & current_fuel_mode.ReactorFuels != null)
     {
         if (!current_fuel_mode.Aneutronic && breedtritium)
         {
             GUILayout.BeginHorizontal();
             GUILayout.Label("Tritium Breed Rate", bold_label, GUILayout.Width(150));
             GUILayout.Label((tritium_produced_f * 86400.0).ToString("0.000") + " l/day", GUILayout.Width(150));
             GUILayout.EndHorizontal();
         }
         GUILayout.BeginHorizontal();
         GUILayout.Label("Fuel", bold_label, GUILayout.Width(150));
         GUILayout.Label("Usage", bold_label, GUILayout.Width(150));
         GUILayout.EndHorizontal();
         double fuel_lifetime_d = double.MaxValue;
         foreach (ReactorFuel fuel in current_fuel_mode.ReactorFuels)
         {
             double availability = getFuelAvailability(fuel);
             double fuel_use     = total_power_per_frame * fuel.FuelUsePerMJ / TimeWarp.fixedDeltaTime / FuelEfficiency * current_fuel_mode.NormalisedReactionRate * 86400;
             fuel_lifetime_d = Math.Min(fuel_lifetime_d, availability / fuel_use);
             GUILayout.BeginHorizontal();
             GUILayout.Label(fuel.FuelName, bold_label, GUILayout.Width(150));
             GUILayout.Label(fuel_use.ToString("0.0000") + " " + fuel.Unit + "/day", GUILayout.Width(150));
             GUILayout.EndHorizontal();
         }
         GUILayout.BeginHorizontal();
         GUILayout.Label("Current Lifetime");
         GUILayout.Label((double.IsNaN(fuel_lifetime_d) ? "-" : (fuel_lifetime_d).ToString("0.00")) + " days", GUILayout.Width(150));
         GUILayout.EndHorizontal();
     }
     if (!IsNuclear)
     {
         GUILayout.BeginHorizontal();
         if (IsEnabled)
         {
             if (GUILayout.Button("Deactivate", GUILayout.ExpandWidth(true)))
             {
                 DeactivateReactor();
             }
         }
         if (!IsEnabled)
         {
             if (GUILayout.Button("Activate", GUILayout.ExpandWidth(true)))
             {
                 ActivateReactor();
             }
         }
         GUILayout.EndHorizontal();
     }
     else
     {
         if (IsEnabled)
         {
             GUILayout.BeginHorizontal();
             if (GUILayout.Button("Shutdown", GUILayout.ExpandWidth(true)))
             {
                 IsEnabled = false;
             }
             GUILayout.EndHorizontal();
         }
     }
     GUILayout.EndVertical();
     GUI.DragWindow();
 }
 private void UpdatePowerStatusString()
 {
     powerStatusStr = PluginHelper.getFormattedPowerString(recievedPowerKW / GameConstants.ecPerMJ) +
                      " / " + PluginHelper.getFormattedPowerString(currentPowerReq / GameConstants.ecPerMJ);
 }
 public override string GetInfo()
 {
     return(Localizer.Format("#LOC_KSPIE_ComputerCore_getInfo1") + " " + PluginHelper.getFormattedPowerString(megajouleRate) + "\n" +
            Localizer.Format("#LOC_KSPIE_ComputerCore_getInfo2") + PluginHelper.getFormattedPowerString(upgradedMegajouleRate));//"Upgraded Power Requirements: "
 }
Exemplo n.º 19
0
        public override void OnUpdate()
        {
            if (!isChargingForJumpstart && !isSwappingFuelMode && getCurrentResourceDemand(FNResourceManager.FNRESOURCE_MEGAJOULES) > getStableResourceSupply(FNResourceManager.FNRESOURCE_MEGAJOULES) && getResourceBarRatio(FNResourceManager.FNRESOURCE_MEGAJOULES) < 0.1 && IsEnabled && !fusion_alert)
            {
                ScreenMessages.PostScreenMessage("Warning: Fusion Reactor plasma heating cannot be guaranteed, reducing power requirements is recommended.", 10.0f, ScreenMessageStyle.UPPER_CENTER);
                fusion_alert = true;
            }
            else
            {
                fusion_alert = false;
            }

            if (isChargingField.guiActive)
            {
                accumulatedChargeStr = FNGenerator.getPowerFormatString(accumulatedElectricChargeInMW) + " / " + FNGenerator.getPowerFormatString(StartupPower);
            }
            else if (part.vessel.geeForce > startupMaximumGeforce)
            {
                accumulatedChargeStr = part.vessel.geeForce.ToString("0.000") + "g > " + startupMaximumGeforce + "g";
            }
            else
            {
                accumulatedChargeStr = String.Empty;
            }

            Fields["accumulatedChargeStr"].guiActive = plasma_ratio < 1;

            //powerPercentageField.guiActive = !IsEnabled && !isChargingForJumpstart;

            electricPowerMaintenance = PluginHelper.getFormattedPowerString(power_consumed) + " / " + PluginHelper.getFormattedPowerString(LaserPowerRequirements);

            // call base class
            base.OnUpdate();
        }
Exemplo n.º 20
0
        public override void OnUpdate() // is called while in flight
        {
            update_count++;

            if (update_count < FRAME_DELAY)
            {
                return;
            }

            update_count = 0;

            if (_moduleDeployableRadiator != null && (_moduleDeployableRadiator.deployState == ModuleDeployablePart.DeployState.RETRACTED ||
                                                      _moduleDeployableRadiator.deployState == ModuleDeployablePart.DeployState.EXTENDED))
            {
                if (radiatorState != _moduleDeployableRadiator.deployState)
                {
                    part.SendMessage("GeometryPartModuleRebuildMeshData");
                    Debug.Log("[KSPI] - Updating geometry mesh due to radiator deployment.");
                }
                radiatorState = _moduleDeployableRadiator.deployState;
            }

            external_temperature  = FlightGlobals.getExternalTemperature(part.transform.position);
            normalizedAtmosphere  = Math.Min(vessel.atmDensity, 1);
            effectiveRadiatorArea = EffectiveRadiatorArea;
            maxCurrentTemperature = maxAtmosphereTemperature * Math.Max(normalizedAtmosphere, 0) + maxVacuumTemperature * Math.Max(Math.Min(1 - vessel.atmDensity, 1), 0);

            temperatureDifferenceCurrentWithExternal = maxCurrentTemperature - external_temperature;
            temperatureDifferenceMaximumWithExternal = maxRadiatorTemperature - external_temperature;

            thermalPowerConvStrField.guiActive = convectedThermalPower > 0;


            // synchronize states
            if (_moduleDeployableRadiator != null && pivotEnabled && showControls)
            {
                if (_moduleDeployableRadiator.deployState == ModuleDeployablePart.DeployState.EXTENDED)
                {
                    radiatorIsEnabled = true;
                }
                else if (_moduleDeployableRadiator.deployState == ModuleDeployablePart.DeployState.RETRACTED)
                {
                    radiatorIsEnabled = false;
                }
            }

            radiatorIsEnabledField.guiActive       = showControls;
            radiatorIsEnabledField.guiActiveEditor = showControls;

            isAutomatedField.guiActive       = showControls;
            isAutomatedField.guiActiveEditor = showControls;

            pivotEnabledField.guiActive       = showControls;
            pivotEnabledField.guiActiveEditor = showControls;

            if (radiatorIsEnabled && canRadiateHeat)
            {
                thermalPowerDissipStr = PluginHelper.getFormattedPowerString(radiatedThermalPower, "0.0", "0.000");
                thermalPowerConvStr   = PluginHelper.getFormattedPowerString(convectedThermalPower, "0.0", "0.000");
            }
            else
            {
                thermalPowerDissipStr = "disabled";
                thermalPowerConvStr   = "disabled";
            }

            radiatorTempStr = CurrentRadiatorTemperature.ToString("0.0") + "K / " + maxCurrentTemperature.ToString("0.0") + "K";

            partTempStr = part.temperature.ToString("0.0") + "K / " + part.maxTemp.ToString("0.0") + "K";

            if (showColorHeat)
            {
                ColorHeat();
            }
        }
        public override void OnFixedUpdateResourceSuppliable(double fixedDeltaTime)
        {
            if (_solarPanel == null)
            {
                return;
            }

            if (_fieldKerbalismNominalRate != null)
            {
                kerbalism_nominalRate = _fieldKerbalismNominalRate.GetValue <double>(_solarPanelFixer);
                kerbalism_panelState  = _fieldKerbalismPanelStatus.GetValue <string>(_solarPanelFixer);

                var kerbalismPanelStateArray = kerbalism_panelState.Split(' ');

                kerbalism_panelOutput = kerbalismPanelStateArray[0];

                double.TryParse(kerbalism_panelOutput, out kerbalism_panelPower);
            }

            if (_outputResource != null && _solarPanel.deployState == ModuleDeployablePart.DeployState.EXTENDED)
            {
                outputResourceRate           = _outputResource.rate;
                outputResourceCurrentRequest = _outputResource.currentRequest;
            }
            else
            {
                outputResourceRate           = 0;
                outputResourceCurrentRequest = 0;
            }

            if (_outputType == ResourceType.other)
            {
                return;
            }

            chargeRate = _solarPanel.chargeRate;

            double age = (Planetarium.GetUniversalTime() - _solarPanel.launchUT) * 1.15740740740741E-05;

            calculatedEfficency = _solarPanel._efficMult > 0 ? _solarPanel._efficMult :
                                  _solarPanel.temperatureEfficCurve.Evaluate((float)part.skinTemperature) *
                                  _solarPanel.timeEfficCurve.Evaluate((float)age) * _solarPanel.efficiencyMult;

            double maxSupply = 0.0, solarRate = 0.0;

            sunAOA = 0;
            CalculateSolarFlowRate(calculatedEfficency / scale, ref maxSupply, ref solarRate);

            _resourceBuffers?.UpdateBuffers();

            if (_outputResource != null)
            {
                if (kerbalism_panelPower > 0)
                {
                    part.RequestResource(_solarPanel.resourceName, kerbalism_panelPower * fixedDeltaTime);
                }
                else if (_outputResource != null)
                {
                    _outputResource.rate = 0;
                }
                else
                {
                    part.RequestResource(_solarPanel.resourceName, solarRate * fixedDeltaTime);
                }
            }

            // provide power to supply manager
            solar_supply   = _outputType == ResourceType.megajoule ? solarRate : solarRate / GameConstants.ecPerMJ;
            solarMaxSupply = _outputType == ResourceType.megajoule ? maxSupply : maxSupply / GameConstants.ecPerMJ;

            mjSolarSupply = PluginHelper.getFormattedPowerString(supplyFNResourcePerSecondWithMax(solar_supply, solarMaxSupply, ResourceSettings.Config.ElectricPowerInMegawatt));
            mjMaxSupply   = PluginHelper.getFormattedPowerString(solarMaxSupply);
        }