示例#1
0
        public static void updateEngineFuelType(FuelTypeISP fuelType, Part part, int engineModuleIndex)
        {
            if (engineModuleIndex < 0)
            {
                return;
            }
            ModuleEngines[] engines = part.GetComponents <ModuleEngines>();
            int             len     = engines.Length;

            if (engineModuleIndex < len)
            {
                ModuleEngines engine = engines[engineModuleIndex];
                engine.propellants.Clear();
                ConfigNode pNode = fuelType.fuelPreset.getPropellantNode(ResourceFlowMode.ALL_VESSEL_BALANCE);
                if (fuelType.atmosphereCurve != null)
                {
                    pNode.AddNode("atmosphereCurve", fuelType.atmosphereCurve.getNode("atmosphereCurve"));
                }
                engine.OnLoad(pNode);
            }
            else
            {
                SSTULog.error("Could not update fuel type - ModuleEngines could not be found for index: " + engineModuleIndex + "  There are not enough modules present in the part: " + len);
            }
        }
示例#2
0
        public static void updateEngineThrust(ModuleEngines engine, float minThrust, float maxThrust)
        {
            engine.minThrust = minThrust;
            engine.maxThrust = maxThrust;
            ConfigNode updateNode = new ConfigNode("MODULE");

            updateNode.AddValue("maxThrust", engine.maxThrust);
            updateNode.AddValue("minThrust", engine.minThrust);
            engine.OnLoad(updateNode);
        }
示例#3
0
        public static void setIspThrustFuelFLow(Part p, float minThrust, float maxThrust,
                                                float atmoIsp, float vacuumIsp, float heatProduction)
        {
            //get module
            ModuleEngines me = getModuleEngines(p);

            //Debug.log("[MUE] setIspThrustFuelFLow with engine  " + me + " for part " + p.partName);

            //heat production
            if (heatProduction >= 0)
            {
                me.heatProduction = heatProduction;
            }


            // ----- change thrust (for info => trust is compute from ips & fuelflow)
            if (minThrust >= 0)
            {
                me.minThrust = minThrust;
            }
            if (maxThrust >= 0)
            {
                me.maxThrust = maxThrust;
            }
            //Debug.log("[MUE] setIspThrustFuelFLow thrust setted to  " + me.minThrust + " => " + me.maxThrust);

            // ----  change isp
            List <Keyframe> newCurve = new List <Keyframe>();

            //add?
            //foreach (Keyframe val in me.atmosphereCurve.Curve.keys)
            //{
            //	newCurve.Add(new Keyframe(val.time, val.value + vacuumIsp));
            //}

            //set?
            //TODO: better tangent calculus
            int i = 0;

            newCurve.Add(new Keyframe(me.atmosphereCurve.Curve.keys[i].time,
                                      (vacuumIsp >= 0 ? vacuumIsp : me.atmosphereCurve.Curve.keys[i].value),
                                      me.atmosphereCurve.Curve.keys[i].inTangent, me.atmosphereCurve.Curve.keys[i].outTangent));
            i++;
            newCurve.Add(new Keyframe(me.atmosphereCurve.Curve.keys[i].time,
                                      (atmoIsp >= 0 ? atmoIsp : me.atmosphereCurve.Curve.keys[i].value),
                                      me.atmosphereCurve.Curve.keys[i].inTangent, me.atmosphereCurve.Curve.keys[i].outTangent));
            i++;
            //copy the other keys
            for (; i < me.atmosphereCurve.Curve.keys.Length; i++)
            {
                newCurve.Add(new Keyframe(me.atmosphereCurve.Curve.keys[i].time,
                                          me.atmosphereCurve.Curve.keys[i].value,
                                          me.atmosphereCurve.Curve.keys[i].inTangent,
                                          me.atmosphereCurve.Curve.keys[i].outTangent));
            }

            me.atmosphereCurve = new FloatCurve(newCurve.ToArray());
            //Debug.log("[MUE] setIspThrustFuelFLow isp0 setted to  " + me.atmosphereCurve.Curve.keys[0].value);
            //Debug.log("[MUE] setIspThrustFuelFLow isp1 setted to  " + me.atmosphereCurve.Curve.keys[1].value);
            if (me.atmosphereCurve.Curve.keys.Length > 2)
            {
                //Debug.log("[MUE] setIspThrustFuelFLow isp2 setted to  " + me.atmosphereCurve.Curve.keys[2].value);

                // ------ change fuel flow
                //TODO: use ModuleEngines.g? or 9.80665 ?
                me.minFuelFlow = (float)(me.minThrust / (9.80665 * me.atmosphereCurve.Curve.keys[0].value));
            }
            me.maxFuelFlow = (float)(me.maxThrust / (9.80665 * me.atmosphereCurve.Curve.keys[0].value));
            //Debug.log("[MUE] setIspThrustFuelFLow FuelFlow setted to  " + me.minFuelFlow + " => " + me.maxFuelFlow);

            //TODO: test if really needed (old code)
            ConfigNode cn = new ConfigNode();

            me.OnSave(cn);
            me.OnLoad(cn);
            //Debug.log("[MUE] setIspThrustFuelFLow save load");
        }