public static IList <IList <double> > DVStats() { IList <IList <double> > stats = new List <IList <double> >(); MechJebCore activejeb = GetJeb(); if (activejeb != null) { MechJebModuleStageStats activestats = activejeb.GetComputerModule("MechJebModuleStageStats") as MechJebModuleStageStats; if (activestats != null) { activestats.RequestUpdate(activejeb); int len = activestats.atmoStats.Length; for (int i = 0; i < len; i++) { IList <double> stage = new List <double>(); stage.Add(activestats.atmoStats[i].deltaV); stage.Add(activestats.vacStats[i].deltaV); stage.Add(activestats.atmoStats[i].StartTWR(1)); stage.Add(activestats.vacStats[i].StartTWR(1)); stage.Add(activestats.atmoStats[i].deltaTime); stats.Add(stage); } } } return(stats); }
public object ProcessVariable(string variable) { activeJeb = vessel.GetMasterMechJeb(); switch (variable) { case "MECHJEBAVAILABLE": if (activeJeb != null) { return(1); } return(-1); case "DELTAV": if (activeJeb != null) { MechJebModuleStageStats stats = activeJeb.GetComputerModule <MechJebModuleStageStats>(); stats.RequestUpdate(this); return(stats.vacStats.Sum(s => s.deltaV)); } return(null); case "DELTAVSTAGE": if (activeJeb != null) { MechJebModuleStageStats stats = activeJeb.GetComputerModule <MechJebModuleStageStats>(); stats.RequestUpdate(this); return(stats.vacStats[stats.vacStats.Length - 1].deltaV); } return(null); case "PREDICTEDLANDINGERROR": // If there's a failure at any step, exit with a -1. // The landing prediction system can be costly, and it // expects someone to be registered with it for it to run. // So, we'll have a MechJebRPM button to enable landing // predictions. And maybe add it in to the MJ menu. if (activeJeb != null && activeJeb.target.PositionTargetExists == true) { var predictor = activeJeb.GetComputerModule <MechJebModuleLandingPredictions>(); if (predictor != null && predictor.enabled) { ReentrySimulation.Result result = predictor.GetResult(); if (result != null && result.outcome == ReentrySimulation.Outcome.LANDED) { // We're going to hit something! double error = Vector3d.Distance(vessel.mainBody.GetRelSurfacePosition(result.endPosition.latitude, result.endPosition.longitude, 0), vessel.mainBody.GetRelSurfacePosition(activeJeb.target.targetLatitude, activeJeb.target.targetLongitude, 0)); return(error); } } } return(-1); } return(null); }