Exemple #1
0
        // Updates the given part either to the latest model (updateToLatestModel=TRUE) or to the model defined by its
        // KRnDModule.
        public static void UpdatePart(Part part, bool update_to_latest_model)
        {
            PartUpgrades upgrades_to_apply;

            if (update_to_latest_model)
            {
                if (upgrades.TryGetValue(SanitizePartName(part.name), out upgrades_to_apply))
                {
                    // Apply upgrades from global list:
                    UpdatePart(part, upgrades_to_apply);
                }
                else
                {
                    // No Upgrades found, apply base-stats:
                    upgrades_to_apply = new PartUpgrades();
                    UpdatePart(part, upgrades_to_apply);
                }
            }
            else
            {
                // Extract current upgrades of the part and set those stats:
                var rnd_module = PartStats.GetKRnDModule(part);
                if (rnd_module != null && (upgrades_to_apply = rnd_module.GetCurrentUpgrades()) != null)
                {
                    // Apply upgrades from the RnD-Module:
                    UpdatePart(part, upgrades_to_apply);
                }
                else
                {
                    // No Upgrades found, apply base-stats:
                    upgrades_to_apply = new PartUpgrades();
                    UpdatePart(part, upgrades_to_apply);
                }
            }
        }
Exemple #2
0
        public override void OnLoad(ConfigNode node)
        {
            try {
                ValueConstants.OnLoad(node);

                double time = DateTime.Now.Ticks;

                KRnD.upgrades.Clear();

                var upgrade_nodes = node.GetNode("upgrades");
                if (upgrade_nodes != null)
                {
                    foreach (var upgrade_node in upgrade_nodes.GetNodes())
                    {
                        var upgrade = PartUpgrades.CreateFromConfigNode(upgrade_node);
                        KRnD.upgrades.Add(upgrade_node.name, upgrade);
                    }

                    // Update global part-list with new upgrades from the saved-game:
                    var upgrades_applied = KRnD.UpdateGlobalParts();

                    // If we started with an active vessel, update that vessel:
                    var vessel = FlightGlobals.ActiveVessel;
                    if (vessel)
                    {
                        KRnD.UpdateVessel(vessel);
                    }

                    time = (DateTime.Now.Ticks - time) / TimeSpan.TicksPerSecond;
                    Debug.Log("[KRnD] retrieved and applied " + upgrades_applied.ToString() + " upgrades in " + time.ToString("0.000s"));
                }

                var gui_settings = node.GetNode("gui");
                if (gui_settings != null)
                {
                    if (gui_settings.HasValue("left"))
                    {
                        KRnDUI.windowPosition.xMin = (float)double.Parse(gui_settings.GetValue("left"));
                    }
                    if (gui_settings.HasValue("top"))
                    {
                        KRnDUI.windowPosition.yMin = (float)double.Parse(gui_settings.GetValue("top"));
                    }
                }
            } catch (Exception e) {
                Debug.LogError("[KRnD] OnLoad(): " + e);
            }
        }
Exemple #3
0
        public static int UpdateBatteryCharge(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var electric_charge = PartStats.GetElectricCharge(part);

            if (electric_charge == null)
            {
                return(0);
            }

            var max_charge      = Math.Round(u_constants.CalculateImprovementValue(original_stats.batteryCharge, upgrades_to_apply.batteryCharge));
            var percentage_full = electric_charge.amount / electric_charge.maxAmount;

            electric_charge.maxAmount = max_charge;
            electric_charge.amount    = max_charge * percentage_full;
            return(0);
        }
Exemple #4
0
 public static int ImproveChargeRate(PartUpgrades store)
 {
     return(++store.efficiencyMult);
 }
Exemple #5
0
        public static int UpdateCrashTolerance(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var landing_leg = PartStats.GetModuleWheelBase(part);

            if (landing_leg)
            {
                part.crashTolerance = u_constants.CalculateImprovementValue(original_stats.crashTolerance, upgrades_to_apply.crashTolerance);
            }

            return(0);
        }
Exemple #6
0
        public static int UpdateElConverter(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var converter_list = PartStats.GetModuleElConverterList(part);

            if (converter_list == null)
            {
                return(0);
            }

            foreach (var converter in converter_list)
            {
                converter.Rate = u_constants.CalculateImprovementValue(original_stats.ELConverter, upgrades_to_apply.elConverter);
            }


#if false
            var el_converter = PartStats.GetModuleElConverter(part);
            if (el_converter)
            {
                el_converter.Rate = u_constants.CalculateImprovementValue(original_stats.ELConverter, upgrades_to_apply.elConverter);
            }
#endif

            return(0);
        }
Exemple #7
0
        // Updates the global dictionary of available parts with the current set of upgrades (should be
        // executed for example when a new game starts or an existing game is loaded).
        public static int UpdateGlobalParts()
        {
            var upgrades_applied = 0;

            try {
                if (upgrades == null)
                {
                    throw new Exception("upgrades-dictionary missing");
                }
                foreach (var part in PartLoader.LoadedPartsList)
                {
                    try {
                        PartUpgrades upgrade;
                        if (!upgrades.TryGetValue(part.name, out upgrade))
                        {
                            upgrade = new PartUpgrades();                                                                        // If there are no upgrades, reset the part.
                        }
                        // Update the part to its latest model:
                        UpdatePart(part.partPrefab, true);

                        // Rebuild the info-screen:
                        var converter_module_number = 0;                      // There might be multiple modules of this type
                        var engine_module_number    = 0;                      // There might be multiple modules of this type
                        foreach (var info in part.moduleInfos)
                        {
                            if (info.moduleName.ToLower() == "engine")
                            {
                                var engines = PartStats.GetModuleEnginesList(part.partPrefab);
                                if (engines != null && engines.Count > 0)
                                {
                                    var engine = engines[engine_module_number];
                                    info.info        = engine.GetInfo();
                                    info.primaryInfo = engine.GetPrimaryField();
                                    engine_module_number++;
                                }
                            }
                            else if (info.moduleName.ToLower() == "rcs")
                            {
                                var rcs = PartStats.GetModuleRCS(part.partPrefab);
                                if (rcs)
                                {
                                    info.info = rcs.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "reaction wheel")
                            {
                                var reaction_wheel = PartStats.GetModuleReactionWheel(part.partPrefab);
                                if (reaction_wheel)
                                {
                                    info.info = reaction_wheel.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "deployable solar panel")
                            {
                                var solar_panel = PartStats.GetModuleDeployableSolarPanel(part.partPrefab);
                                if (solar_panel)
                                {
                                    info.info = GetSolarPanelInfo(solar_panel);
                                }
                            }
                            else if (info.moduleName.ToLower() == "landing leg")
                            {
                                var landing_leg = PartStats.GetModuleWheelBase(part.partPrefab);
                                if (landing_leg)
                                {
                                    info.info = landing_leg.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "fission generator")
                            {
                                var fission_generator = PartStats.GetFissionGenerator(part.partPrefab);
                                if (fission_generator)
                                {
                                    info.info = fission_generator.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "generator")
                            {
                                var generator = PartStats.GetModuleGenerator(part.partPrefab);
                                if (generator)
                                {
                                    info.info = generator.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "data transmitter")
                            {
                                var antenna = PartStats.GetModuleDataTransmitter(part.partPrefab);
                                if (antenna)
                                {
                                    info.info = antenna.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "science lab")
                            {
                                var lab = PartStats.GetModuleScienceLab(part.partPrefab);
                                if (lab)
                                {
                                    info.info = lab.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "active radiator")
                            {
                                var lab = PartStats.GetModuleActiveRadiator(part.partPrefab);
                                if (lab)
                                {
                                    info.info = lab.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "resource converter")
                            {
                                var converter_list = PartStats.GetModuleResourceConverterList(part.partPrefab);
                                if (converter_list == null || converter_list.Count <= 0)
                                {
                                    continue;
                                }
                                var converter = converter_list[converter_module_number];
                                info.info = converter.GetInfo();
                                converter_module_number++;
                            }
                            else if (info.moduleName.ToLower() == "parachute")
                            {
                                var parachute = PartStats.GetModuleParachute(part.partPrefab);
                                if (parachute)
                                {
                                    info.info = parachute.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "resource harvester")
                            {
                                var harvester = PartStats.GetModuleResourceHarvester(part.partPrefab);
                                if (harvester)
                                {
                                    info.info = harvester.GetInfo();
                                }
                            }
                            else if (info.moduleName.ToLower() == "custom-built fairing")
                            {
                                var fairing = PartStats.GetModuleProceduralFairing(part.partPrefab);
                                if (fairing)
                                {
                                    info.info = fairing.GetInfo();
                                }
                            }
                        }

                        var fuel_resources  = PartStats.GetFuelResources(part.partPrefab);
                        var electric_charge = PartStats.GetElectricCharge(part.partPrefab);
                        // The Resource-Names are not always formatted the same way, eg "Electric Charge" vs "ElectricCharge", so we do some reformatting.
                        foreach (var info in part.resourceInfos)
                        {
                            if (electric_charge != null && info.resourceName.Replace(" ", "").ToLower() == electric_charge.resourceName.Replace(" ", "").ToLower())
                            {
                                info.info        = electric_charge.GetInfo();
                                info.primaryInfo = "<b>" + info.resourceName + ":</b> " + electric_charge.maxAmount;
                            }
                            else if (fuel_resources != null)
                            {
                                foreach (var fuel_resource in fuel_resources)
                                {
                                    if (info.resourceName.Replace(" ", "").ToLower() == fuel_resource.resourceName.Replace(" ", "").ToLower())
                                    {
                                        info.info        = fuel_resource.GetInfo();
                                        info.primaryInfo = "<b>" + info.resourceName + ":</b> " + fuel_resource.maxAmount;
                                        break;
                                    }
                                }
                            }
                        }

                        upgrades_applied++;
                    } catch (Exception e) {
                        Debug.LogError("[KRnD] updateGlobalParts(" + part.title + "): " + e);
                    }
                }
            } catch (Exception e) {
                Debug.LogError("[KRnD] updateGlobalParts(): " + e);
            }

            return(upgrades_applied);
        }
Exemple #8
0
        public static int UpdateParachuteStrength(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            // Parachute Strength:
            var parachute = PartStats.GetModuleParachute(part);

            if (parachute)
            {
                // The safe deployment-speed is derived from the temperature
                parachute.chuteMaxTemp = original_stats.chuteMaxTemp * u_constants.CalculateImprovementFactor(upgrades_to_apply.parachuteStrength);
            }

            return(0);
        }
Exemple #9
0
        public static int UpdateFuelCapacity(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            // Fuel Capacity:
            var fuel_resources = PartStats.GetFuelResources(part);

            if (fuel_resources == null || original_stats.fuelCapacities == null)
            {
                return(0);
            }

            double improvement_factor = u_constants.CalculateImprovementFactor(upgrades_to_apply.fuelCapacity);

            foreach (var fuel_resource in fuel_resources)
            {
                if (!original_stats.fuelCapacities.ContainsKey(fuel_resource.resourceName))
                {
                    continue;
                }
                var original_capacity = original_stats.fuelCapacities[fuel_resource.resourceName];
                var new_capacity      = Math.Round(original_capacity * improvement_factor);
                var percentage_full   = fuel_resource.amount / fuel_resource.maxAmount;

                fuel_resource.maxAmount = new_capacity;
                fuel_resource.amount    = new_capacity * percentage_full;
            }

            return(0);
        }
Exemple #10
0
        public static int UpdateGeneratorEfficiency(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var generator = PartStats.GetModuleGenerator(part);

            if (generator)
            {
                foreach (var output_resource in generator.resHandler.outputResources)
                {
                    if (!original_stats.generatorEfficiency.TryGetValue(output_resource.name, out var original_rate))
                    {
                        continue;
                    }
                    output_resource.rate = u_constants.CalculateImprovementValue(original_rate, upgrades_to_apply.generatorEfficiency);
                }
            }

            var fission_generator = PartStats.GetFissionGenerator(part);

            if (fission_generator)
            {
                var power_generation = u_constants.CalculateImprovementValue(original_stats.fissionPowerGeneration, upgrades_to_apply.generatorEfficiency);
                PartStats.SetGenericModuleValue(fission_generator, "PowerGeneration", power_generation);
            }

            return(0);
        }
Exemple #11
0
        public static int UpdatePacketSize(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var antenna = PartStats.GetModuleDataTransmitter(part);

            if (antenna)
            {
                antenna.packetSize = u_constants.CalculateImprovementValue(original_stats.packetSize, upgrades_to_apply.packetSize);
            }

            return(0);
        }
Exemple #12
0
 public static int ImproveMaxTemperature(PartUpgrades store)
 {
     return(++store.maxTemperature);
 }
Exemple #13
0
 public static int ImproveFuelCapacity(PartUpgrades store)
 {
     return(++store.fuelCapacity);
 }
Exemple #14
0
 public static int ImproveParachuteStrength(PartUpgrades store)
 {
     return(++store.parachuteStrength);
 }
Exemple #15
0
 public static int ImproveConverterEfficiency(PartUpgrades store)
 {
     return(++store.converterEfficiency);
 }
Exemple #16
0
 public static int ImproveGeneratorEfficiency(PartUpgrades store)
 {
     return(++store.generatorEfficiency);
 }
Exemple #17
0
 public static int ImproveBatteryCharge(PartUpgrades store)
 {
     return(++store.batteryCharge);
 }
Exemple #18
0
 public static int ImproveCrashTolerance(PartUpgrades store)
 {
     return(++store.crashTolerance);
 }
Exemple #19
0
        public static int UpdateConverterEfficiency(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            // Converter Efficiency:
            var converter_list = PartStats.GetModuleResourceConverterList(part);

            if (converter_list == null)
            {
                return(0);
            }

            foreach (var converter in converter_list)
            {
                if (!original_stats.converterEfficiency.TryGetValue(converter.ConverterName, out var original_output_resources))
                {
                    continue;
                }

                // Since KSP 1.2 this can't be done in a foreach anymore, we have to read and write back the entire ResourceRatio-Object:
                for (var i = 0; i < converter.outputList.Count; i++)
                {
                    var resource_ratio = converter.outputList[i];
                    if (!original_output_resources.TryGetValue(resource_ratio.ResourceName, out var original_ratio))
                    {
                        continue;
                    }

                    resource_ratio.Ratio    = u_constants.CalculateImprovementValue(original_ratio, upgrades_to_apply.converterEfficiency);
                    converter.outputList[i] = resource_ratio;
                }
            }

            return(0);
        }
Exemple #20
0
        public static int UpdateDryMass(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            part.prefabMass = part.mass = u_constants.CalculateImprovementValue(original_stats.dryMass, upgrades_to_apply.dryMass);

            // Dry Mass also improves fairing mass:
            var fairing_module = PartStats.GetModuleProceduralFairing(part);

            if (fairing_module)
            {
                fairing_module.UnitAreaMass = u_constants.CalculateImprovementValue(original_stats.fairingAreaMass, upgrades_to_apply.dryMass);
            }

            return(0);
        }
Exemple #21
0
        public static int UpdateDataStorage(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var science_lab = PartStats.GetModuleScienceLab(part);

            if (science_lab)
            {
                science_lab.dataStorage = u_constants.CalculateImprovementValue(original_stats.dataStorage, upgrades_to_apply.dataStorage);
            }

            var science_converter = PartStats.GetModuleScienceConverter(part);

            if (science_converter)
            {
                science_converter.scienceCap = u_constants.CalculateImprovementValue(original_stats.scienceCap, upgrades_to_apply.dataStorage);
            }

            return(0);
        }
Exemple #22
0
 public static int UpdateMaxTemperature(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
 {
     part.skinMaxTemp = u_constants.CalculateImprovementValue(original_stats.skinMaxTemp, upgrades_to_apply.maxTemperature);
     part.maxTemp     = u_constants.CalculateImprovementValue(original_stats.intMaxTemp, upgrades_to_apply.maxTemperature);
     return(0);
 }
Exemple #23
0
        public static int UpdateResourceHarvester(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            // Resource Harvester
            var harvester = PartStats.GetModuleResourceHarvester(part);

            if (harvester)
            {
                harvester.Efficiency = u_constants.CalculateImprovementValue(original_stats.resourceHarvester, upgrades_to_apply.resourceHarvester);
            }

            // TODO: Update surface harvester module too?
            return(0);
        }
Exemple #24
0
        public static int UpdateFuelFlow(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var upgrade_factor = u_constants.CalculateImprovementFactor(upgrades_to_apply.fuelFlow);
            var engine_modules = PartStats.GetModuleEnginesList(part);
            var rcs_module     = PartStats.GetModuleRCS(part);

            if (engine_modules == null && !rcs_module)
            {
                return(0);
            }

            for (var i = 0; i < original_stats.maxFuelFlows.Count; i++)
            {
                var max_fuel_flow = original_stats.maxFuelFlows[i] * upgrade_factor;
                if (engine_modules != null)
                {
                    engine_modules[i].maxFuelFlow = max_fuel_flow;
                }
                else if (rcs_module)
                {
                    rcs_module.thrusterPower = max_fuel_flow;                     // There is only one rcs-module
                }
            }

            return(0);
        }
Exemple #25
0
        public static int UpdateActiveRadiator(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var radiator = PartStats.GetModuleActiveRadiator(part);

            if (radiator)
            {
                radiator.maxEnergyTransfer = u_constants.CalculateImprovementValue(original_stats.maxEnergyTransfer, upgrades_to_apply.maxEnergyTransfer);
            }

            return(0);
        }
Exemple #26
0
        public static int UpdateISPVacAtm(UpgradeConstants data_vac, UpgradeConstants data_atm, Part part, PartStats original_stats, PartUpgrades isp)
        {
            List <ModuleEngines> engine_modules = PartStats.GetModuleEnginesList(part);
            ModuleRCS            rcs_module     = PartStats.GetModuleRCS(part);

            if (engine_modules == null && !rcs_module)
            {
                return(0);
            }

            var improvement_factor_vac = data_vac.CalculateImprovementFactor(isp.ispVac);
            var improvement_factor_atm = data_atm.CalculateImprovementFactor(isp.ispAtm);

            for (var i = 0; i < original_stats.atmosphereCurves.Count; i++)
            {
                var is_air_breather = false;
                if (engine_modules != null)
                {
                    is_air_breather = engine_modules[i].engineType == EngineType.Turbine ||
                                      engine_modules[i].engineType == EngineType.Piston ||
                                      engine_modules[i].engineType == EngineType.ScramJet;
                }
                var fc = new FloatCurve();
                for (var v = 0; v < original_stats.atmosphereCurves[i].Curve.length; v++)
                {
                    var frame = original_stats.atmosphereCurves[i].Curve[v];

                    var pressure = frame.time;
                    //var value = frame.value;


                    float factor_at_this_pressure = 1;
                    if (is_air_breather && original_stats.atmosphereCurves[i].Curve.length == 1)
                    {
                        factor_at_this_pressure = improvement_factor_atm;                         // Air-breathing engines have a pressure curve starting at 0, but they should use Atm. as improvement factor.
                    }
                    else if (Math.Abs(pressure) < Single.Epsilon)
                    {
                        factor_at_this_pressure = improvement_factor_vac;                         // In complete vacuum
                    }
                    else if (pressure >= 1)
                    {
                        factor_at_this_pressure = improvement_factor_atm;                         // At lowest kerbal atmosphere
                    }
                    else
                    {
                        factor_at_this_pressure = (1 - pressure) * improvement_factor_vac + pressure * improvement_factor_atm;                         // Mix both
                    }

                    var new_value = frame.value * factor_at_this_pressure;
                    fc.Add(pressure, new_value);
                }

                if (engine_modules != null)
                {
                    engine_modules[i].atmosphereCurve = fc;
                }
                else if (rcs_module)
                {
                    rcs_module.atmosphereCurve = fc;                     // There is only one rcs-module
                }
            }

            return(0);
        }
Exemple #27
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary> Updates the given part with all upgrades provided in "upgradesToApply".</summary>
        ///
        /// <exception cref="Exception"> Thrown when an exception error condition occurs.</exception>
        ///
        /// <param name="part">				 The part.</param>
        /// <param name="upgrades_to_apply"> The upgrades to apply.</param>
        public static void UpdatePart(Part part, PartUpgrades upgrades_to_apply)
        {
            try {
                // Find all relevant modules of this part:
                var rnd_module = PartStats.GetKRnDModule(part);
                if (rnd_module == null)
                {
                    return;
                }
                if (upgrades == null)
                {
                    throw new Exception("upgrades-dictionary missing");
                }
                if (originalStats == null)
                {
                    throw new Exception("original-stats-dictionary missing");
                }

                // Get the part-name ("):
                var part_name = SanitizePartName(part.name);

                // Get the original part-stats:
                if (!originalStats.TryGetValue(part_name, out var original_stats))
                {
                    throw new Exception("no original-stats for part '" + part_name + "'");
                }

                /*
                 * Updates the part to match the upgrade levels specified in the upgrades_to_apply parameter. This provides the hard
                 * link between the ValueConstants class, the upgrade level field in PartUpgrades class, and the algorithm to actually
                 * update the part -- sometimes the algorithm is simple, but could be more complex such as with ISP efficiency
                 * curves.
                 */
                foreach (var u in ValueConstants.upgradeDatabase)
                {
                    if (u.Value.applyUpgradeFunction != null)
                    {
                        u.Value.applyUpgradeFunction(u.Value, part, original_stats, upgrades_to_apply);
                    }
                    else
                    {
                        if (u.Key == StringConstants.ISP_VAC)
                        {
                            UpdateISPVacAtm(ValueConstants.GetData(StringConstants.ISP_VAC), ValueConstants.GetData(StringConstants.ISP_ATM), part, original_stats, upgrades_to_apply);
                        }
                    }
                }

#if false
                UpdateDryMass(ValueConstants.GetData(StringConstants.DRY_MASS), part, original_stats, upgrades_to_apply);
                UpdateMaxTemperature(ValueConstants.GetData(StringConstants.MAX_TEMPERATURE), part, original_stats, upgrades_to_apply);
                UpdateFuelFlow(ValueConstants.GetData(StringConstants.FUEL_FLOW), part, original_stats, upgrades_to_apply);
                UpdateISPVacAtm(ValueConstants.GetData(StringConstants.ISP_VAC), ValueConstants.GetData(StringConstants.ISP_ATM), part, original_stats, upgrades_to_apply);
                UpdateTorque(ValueConstants.GetData(StringConstants.TORQUE), part, original_stats, upgrades_to_apply);
                UpdateChargeRate(ValueConstants.GetData(StringConstants.CHARGE_RATE), part, original_stats, upgrades_to_apply);
                UpdateCrashTolerance(ValueConstants.GetData(StringConstants.CRASH_TOLERANCE), part, original_stats, upgrades_to_apply);
                UpdateBatteryCharge(ValueConstants.GetData(StringConstants.BATTERY_CHARGE), part, original_stats, upgrades_to_apply);
                UpdateGeneratorEfficiency(ValueConstants.GetData(StringConstants.GENERATOR_EFFICIENCY), part, original_stats, upgrades_to_apply);
                UpdateConverterEfficiency(ValueConstants.GetData(StringConstants.CONVERTER_EFFICIENCY), part, original_stats, upgrades_to_apply);
                UpdateAntennaPower(ValueConstants.GetData(StringConstants.ANTENNA_POWER), part, original_stats, upgrades_to_apply);
                UpdatePacketSize(ValueConstants.GetData(StringConstants.PACKET_SIZE), part, original_stats, upgrades_to_apply);
                UpdateDataStorage(ValueConstants.GetData(StringConstants.DATA_STORAGE), part, original_stats, upgrades_to_apply);
                UpdateParachuteStrength(ValueConstants.GetData(StringConstants.PARACHUTE_STRENGTH), part, original_stats, upgrades_to_apply);
                UpdateResourceHarvester(ValueConstants.GetData(StringConstants.RESOURCE_HARVESTER), part, original_stats, upgrades_to_apply);
                UpdateFuelCapacity(ValueConstants.GetData(StringConstants.FUEL_CAPACITY), part, original_stats, upgrades_to_apply);
                UpdateActiveRadiator(ValueConstants.GetData(StringConstants.ENERGY_TRANSFER), part, original_stats, upgrades_to_apply);
                UpdateElConverter(ValueConstants.GetData(StringConstants.EL_CONVERTER), part, original_stats, upgrades_to_apply);
#endif


                /*
                 * Update the RnD module to reflect the upgrades specified.
                 */
                rnd_module.ApplyUpgrades(upgrades_to_apply);
            } catch (Exception e) {
                Debug.LogError("[KRnD] updatePart(" + part.name + "): " + e);
            }
        }
Exemple #28
0
        public static int UpdateTorque(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var reaction_wheel = PartStats.GetModuleReactionWheel(part);

            if (!reaction_wheel)
            {
                return(0);
            }

            var torque = u_constants.CalculateImprovementValue(original_stats.torqueStrength, upgrades_to_apply.torqueStrength);

            reaction_wheel.PitchTorque = torque;
            reaction_wheel.YawTorque   = torque;
            reaction_wheel.RollTorque  = torque;
            return(0);
        }
Exemple #29
0
        public static int UpdateChargeRate(UpgradeConstants u_constants, Part part, PartStats original_stats, PartUpgrades upgrades_to_apply)
        {
            var solar_panel = PartStats.GetModuleDeployableSolarPanel(part);

            if (solar_panel)
            {
                solar_panel.efficiencyMult = u_constants.CalculateImprovementValue(original_stats.efficiencyMult, upgrades_to_apply.efficiencyMult);
            }

            return(0);
        }
Exemple #30
0
 public static int ImproveDataStorage(PartUpgrades store)
 {
     return(++store.dataStorage);
 }