static void SetWarpMode(TimeWarp.Modes mode) { if (TimeWarp.WarpMode != mode) { TimeWarp.fetch.Mode = mode; TimeWarp.SetRate(0, true); } }
// Return which of the two rates arrays is to be used for the given mode: private static float[] GetRateArrayForMode(TimeWarp.Modes whichMode) { switch (whichMode) { case TimeWarp.Modes.HIGH: return(TimeWarp.fetch.warpRates); case TimeWarp.Modes.LOW: return(TimeWarp.fetch.physicsWarpRates); } return(new float[0]); }
public ListValue <ScalarValue> GetRatesList(TimeWarp.Modes warpMode) { float[] ratesArray = GetRateArrayForMode(warpMode); ListValue <ScalarValue> ratesKOSList = new ListValue <ScalarValue>(); // Have to convert the elements one at a time from (float) to (ScalarDoubleValue): foreach (float val in ratesArray) { ratesKOSList.Add(val); } return(ratesKOSList); }
// Return which of the two rates arrays is to be used for the given mode: private float[] GetRateArrayForMode(TimeWarp.Modes whichMode) { float[] rateArray; switch (whichMode) { case TimeWarp.Modes.HIGH: rateArray = TimeWarp.fetch.warpRates; break; case TimeWarp.Modes.LOW: rateArray = TimeWarp.fetch.physicsWarpRates; break; default: throw new Exception(string.Format("WARP MODE {0} unknown to kOS - did KSP's API change?", TimeWarp.WarpMode.ToString())); } return(rateArray); }
static void SetWarpFactor(TimeWarp.Modes mode, int factor) { SetWarpMode(mode); TimeWarp.SetRate(factor, false); }