public override void OnLoad(ConfigNode node) { ConfigNode node_vessels = node.GetNode("Scanners"); if (node_vessels != null) { print("SCANsat Controller: Loading " + node_vessels.CountNodes.ToString() + " known vessels"); foreach (ConfigNode node_vessel in node_vessels.GetNodes("Vessel")) { Guid id = new Guid(node_vessel.GetValue("guid")); string stext = node_vessel.GetValue("sensors"); if (stext != null && stext != "") { int sensors = Convert.ToInt32(stext); if (sensors != 0) { registerSensor(id, (SCANdata.SCANtype)sensors, 0, 0, 0, 0); } } foreach (ConfigNode node_sensor in node_vessel.GetNodes("Sensor")) { int sensor = Convert.ToInt32(node_sensor.GetValue("type")); double fov = Convert.ToDouble(node_sensor.GetValue("fov")); double min_alt = Convert.ToDouble(node_sensor.GetValue("min_alt")); double max_alt = Convert.ToDouble(node_sensor.GetValue("max_alt")); double best_alt = Convert.ToDouble(node_sensor.GetValue("best_alt")); registerSensor(id, (SCANdata.SCANtype)sensor, fov, min_alt, max_alt, best_alt); } } } ConfigNode node_progress = node.GetNode("Progress"); if (node_progress != null) { foreach (ConfigNode node_body in node_progress.GetNodes("Body")) { string body_name = node_body.GetValue("Name"); print("SCANsat Controller: Loading map for " + body_name); SCANdata body_data = getData(body_name); try { string mapdata = node_body.GetValue("Map"); body_data.deserialize(mapdata); } catch (Exception e) { print(e.ToString()); print(e.StackTrace); // fail somewhat gracefully; don't make the save unloadable } body_data.disabled = Convert.ToBoolean(node_body.GetValue("Disabled")); } } }
public override void OnLoad(ConfigNode node) { body_data.Clear(); ConfigNode node_vessels = node.GetNode("Scanners"); if (node_vessels != null) { print("SCANsat Controller: Loading " + node_vessels.CountNodes.ToString() + " known vessels"); foreach (ConfigNode node_vessel in node_vessels.GetNodes("Vessel")) { Guid id = new Guid(node_vessel.GetValue("guid")); string stext = node_vessel.GetValue("sensors"); if (stext != null && stext != "") { int sensors = Convert.ToInt32(stext); if (sensors != 0) { registerSensor(id, (SCANdata.SCANtype)sensors, 0, 0, 0, 0); } } foreach (ConfigNode node_sensor in node_vessel.GetNodes("Sensor")) { int sensor = Convert.ToInt32(node_sensor.GetValue("type")); double fov = Convert.ToDouble(node_sensor.GetValue("fov")); double min_alt = Convert.ToDouble(node_sensor.GetValue("min_alt")); double max_alt = Convert.ToDouble(node_sensor.GetValue("max_alt")); double best_alt = Convert.ToDouble(node_sensor.GetValue("best_alt")); registerSensor(id, (SCANdata.SCANtype)sensor, fov, min_alt, max_alt, best_alt); } } } ConfigNode node_progress = node.GetNode("Progress"); if (node_progress != null) { foreach (ConfigNode node_body in node_progress.GetNodes("Body")) { string body_name = node_body.GetValue("Name"); print("SCANsat Controller: Loading map for " + body_name); CelestialBody body = FlightGlobals.Bodies.FirstOrDefault(b => b.name == body_name); if (body != null) { SCANdata data = SCANUtil.getData(body); try { string mapdata = node_body.GetValue("Map"); data.deserialize(mapdata); } catch (Exception e) { print(e.ToString()); print(e.StackTrace); // fail somewhat gracefully; don't make the save unloadable } data.disabled = Convert.ToBoolean(node_body.GetValue("Disabled")); } } } if (!warned && SCANversions.SCANurl != "SCANsat/Plugins" && !string.IsNullOrEmpty(SCANversions.SCANurl)) { //Complain if SCANsat is installed in the wrong place ScreenMessages.PostScreenMessage(string.Format("SCANsat plugin installed in the wrong directory: {0}. Installation location should be:/nKerbal Space Program/GameData/SCANsat/Plugins/SCANsat.dll", SCANversions.SCANurl), 15f, ScreenMessageStyle.UPPER_CENTER); warned = true; } }