public void changeThrust()
{
try
{
ModuleEngines mE = (ModuleEngines)part.Modules["ModuleEngines"];
float mThrust = (float)Math.Round(mE.atmosphereCurve.Evaluate(0) * part.Resources["SolidFuel"].maxAmount * part.Resources["SolidFuel"].info.density * 9.81f / burnTime, 2);
mE.maxThrust = mThrust;
mE.heatProduction = (float)Math.Round((200f + 5200f / Math.Pow((burnTime + 20f), 0.75f)) * 0.5f * part.maxTemp / 3600f);
if (part.Modules.Contains("ModuleEngineConfigs"))
{
var mEC = part.Modules["ModuleEngineConfigs"];
if (mEC != null)
{
//mEC.SendMessage("ChangeThrust", mThrust);
// thanks to ferram
Type engineType = mEC.GetType();
//
engineType.GetMethod("ChangeThrust").Invoke(mEC, new object[] { mThrust });
// unneeded - engineType.GetMethod("SetConfiguration").Invoke(mEC, new object[] { null });
/*List<ConfigNode> configs = (List<ConfigNode>)mEC.Fields.GetValue("configs");
ConfigNode cfg = configs.Find(c => c.GetValue("name").Equals("Normal"));
cfg.SetValue("maxThrust", mThrust.ToString());
mEC.GetType().GetField("configs").SetValue(mEC, configs);*/
}
}
}
catch (Exception e)
{
print("*ST* ChangeThrust, caught " + e.Message);
}
}