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"); }