// This is a utility method that adds the "flightData" value directly public void AddFlightDataForPartName(string partName, float data) { if (partData.ContainsKey(partName)) { partData[partName].AddValue("flightData", data); } else { TestFlightPartData newData = new TestFlightPartData(); newData.PartName = partName; newData.SetValue("flightData", data); partData.Add(partName, newData); } }
// This is a utility method that sets the "researchData" value directly public void SetResearchDataForPartName(string partName, float data) { if (partData.ContainsKey(partName)) { partData[partName].SetValue("researchData", data.ToString()); } else { TestFlightPartData newData = new TestFlightPartData(); newData.PartName = partName; newData.SetValue("researchData", data.ToString()); partData.Add(partName, newData); } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (userSettings != null) { userSettings.Load(); } if (bodySettings != null) { bodySettings.Load(); } InitDataStore(); if (node.HasValue("saveData")) { rawSaveData = node.GetValue("saveData"); } else { rawSaveData = ""; } decodeRawSaveData(); if (partData == null) { partData = new Dictionary <String, TestFlightPartData>(); } else { partData.Clear(); } // TODO: This old method of storing scope specific data is deprecated and needs to be removed in the next major release (Probably 1.4) if (node.HasNode("FLIGHTDATA_PART")) { foreach (ConfigNode partNode in node.GetNodes("FLIGHTDATA_PART")) { PartFlightData partFlightData = new PartFlightData(); partFlightData.Load(partNode); // migrates old data into new noscope layout TestFlightPartData storedPartData = new TestFlightPartData(); storedPartData.PartName = partFlightData.GetPartName(); // Add up all the data and time from the old system for each scope, and then save that as the new migrated vales double totalData = 0; double totalTime = 0; List <TestFlightData> allData = partFlightData.GetFlightData(); foreach (TestFlightData data in allData) { totalData += data.flightData; totalTime += data.flightTime; } storedPartData.SetValue("flightData", totalData.ToString()); storedPartData.SetValue("flightTime", totalTime.ToString()); partData.Add(storedPartData.PartName, storedPartData); } } // new noscope if (node.HasNode("partData")) { foreach (ConfigNode partDataNode in node.GetNodes("partData")) { TestFlightPartData storedPartData = new TestFlightPartData(); storedPartData.Load(partDataNode); partData.Add(storedPartData.PartName, storedPartData); } } }