/// <summary> /// Adds flight data for the given body & situation scope. Creates new entry if one doesn't yet exist, or updates one if it exists /// </summary> /// <param name="scope">Scope.</param> /// <param name="flightData">Flight data.</param> /// <param name="flightTime">Flight time.</param> public void AddFlightData(string scope, double flightData, double flightTime) { if (dataBodies == null) { dataBodies = new List <FlightDataBody>(); FlightDataBody bodyData = new FlightDataBody(); bodyData.scope = scope; bodyData.flightData = flightData; bodyData.flightTime = flightTime; dataBodies.Add(bodyData); } else { FlightDataBody bodyData = dataBodies.Find(s => s.scope == scope); if (bodyData != null) { bodyData.flightData = flightData; bodyData.flightTime = flightTime; return; } else { FlightDataBody body = new FlightDataBody(); body.scope = scope; body.flightData = flightData; body.flightTime = flightTime; dataBodies.Add(body); } } }
public static FlightDataBody FromString(string s) { FlightDataBody bodyData = null; string[] sections = s.Split(new char[1] { ',' }); if (sections.Length == 3) { bodyData = new FlightDataBody(); bodyData.scope = sections[0]; bodyData.flightData = double.Parse(sections[1]); bodyData.flightTime = double.Parse(sections[2]); } return(bodyData); }
public void Load(ConfigNode node) { if (node.HasNode("bodyData")) { if (dataBodies == null) { dataBodies = new List <FlightDataBody>(); } else { dataBodies.Clear(); } foreach (ConfigNode bodyNode in node.GetNodes("bodyData")) { FlightDataBody body = new FlightDataBody(); body.Load(bodyNode); dataBodies.Add(body); } } }