public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue <string>(configNode, "basename", x => basename = x, this);

            int index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "CONDITION"))
            {
                DataNode childDataNode = new DataNode("CONDITION_" + index++, dataNode, this);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(childDataNode);
                    CloseBase.ConditionDetail cd = new CloseBase.ConditionDetail();
                    valid &= ConfigNodeUtil.ParseValue <CloseBase.ConditionDetail.Condition>(child, "condition", x => cd.condition = x, this);
                    valid &= ConfigNodeUtil.ParseValue <string>(child, "parameter", x => cd.parameter = x, this, "", x => ValidateMandatoryParameter(x, cd.condition));
                    conditions.Add(cd);
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);
                }
            }
            valid &= ConfigNodeUtil.ValidateMandatoryChild(configNode, "CONDITION", this);

            return(valid);
        }
Exemple #2
0
        public static OrbitGenerator Create(ConfigNode configNode, CelestialBody defaultBody, OrbitGeneratorFactory factory)
        {
            OrbitGenerator obGenerator = new OrbitGenerator();

            bool valid = true;
            int  index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode))
            {
                DataNode dataNode = new DataNode("ORBIT_" + index++, factory.dataNode, factory);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);

                    OrbitData obData = new OrbitData(child.name);

                    // Get settings that differ by type
                    if (child.name == "FIXED_ORBIT")
                    {
                        valid       &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory);
                        obData.orbit = new OrbitSnapshot(ConfigNodeUtil.GetChildNode(child, "ORBIT")).Load();
                    }
                    else if (child.name == "RANDOM_ORBIT")
                    {
                        valid &= ConfigNodeUtil.ParseValue <OrbitType>(child, "type", x => obData.orbitType = x, factory);
                        valid &= ConfigNodeUtil.ParseValue <int>(child, "count", x => obData.count = x, factory, 1, x => Validation.GE(x, 1));
                    }
                    else
                    {
                        throw new ArgumentException("Unrecognized orbit node: '" + child.name + "'");
                    }

                    // Get target body
                    valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", x => obData.orbit.referenceBody = x, factory, defaultBody, Validation.NotNull);

                    // Add to the list
                    obGenerator.orbits.Add(obData);
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(factory.dataNode);
                }
            }

            allOrbitGenerators.Add(obGenerator);

            return(valid ? obGenerator : null);
        }
        public static SpawnKerbal Create(ConfigNode configNode, CelestialBody defaultBody, SpawnKerbalFactory factory)
        {
            SpawnKerbal spawnKerbal = new SpawnKerbal();

            bool valid = true;

            foreach (ConfigNode child in configNode.GetNodes("KERBAL"))
            {
                KerbalData kerbal = new KerbalData();

                // Get name
                if (child.HasValue("name"))
                {
                    kerbal.name = child.GetValue("name");
                }

                // Get celestial body
                valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", ref kerbal.body, factory, defaultBody, Validation.NotNull);

                // Get orbit
                valid       &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory);
                kerbal.orbit = new OrbitSnapshot(child.GetNode("ORBIT")).Load();
                kerbal.orbit.referenceBody = kerbal.body;

                // Get landed stuff
                if (child.HasValue("lat") && child.HasValue("lon") && child.HasValue("alt"))
                {
                    valid        &= ConfigNodeUtil.ParseValue <double>(child, "lat", ref kerbal.latitude, factory);
                    valid        &= ConfigNodeUtil.ParseValue <double>(child, "lon", ref kerbal.longitude, factory);
                    valid        &= ConfigNodeUtil.ParseValue <double>(child, "alt", ref kerbal.altitude, factory);
                    kerbal.landed = true;
                }

                // Get owned flag
                if (child.HasValue("owned"))
                {
                    valid &= ConfigNodeUtil.ParseValue <bool>(configNode, "owned", ref kerbal.owned, factory, false);
                }

                // Add to the list
                spawnKerbal.kerbals.Add(kerbal);
            }

            return(valid ? spawnKerbal : null);
        }
Exemple #4
0
        public static OrbitGenerator Create(ConfigNode configNode, CelestialBody defaultBody, OrbitGeneratorFactory factory)
        {
            OrbitGenerator obGenerator = new OrbitGenerator();

            bool valid = true;

            foreach (ConfigNode child in configNode.GetNodes())
            {
                int count = child.HasValue("count") ? Convert.ToInt32(child.GetValue("count")) : 1;
                for (int i = 0; i < count; i++)
                {
                    OrbitData obData = new OrbitData(child.name);

                    // Get settings that differ by type
                    if (child.name == "FIXED_ORBIT")
                    {
                        valid       &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory);
                        obData.orbit = new OrbitSnapshot(child.GetNode("ORBIT")).Load();
                    }
                    else if (child.name == "RANDOM_ORBIT")
                    {
                        valid &= ConfigNodeUtil.ParseValue <OrbitType>(child, "type", ref obData.orbitType, factory);
                        valid &= ConfigNodeUtil.ParseValue <double>(configNode, "difficulty", ref obData.difficulty, factory, 1.0, x => Validation.GE(x, 0.0));
                    }
                    else
                    {
                        throw new ArgumentException("Unrecognized orbit node: '" + child.name + "'");
                    }

                    // Get target body
                    valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", ref obData.orbit.referenceBody, factory, defaultBody, Validation.NotNull);

                    // Add to the list
                    obGenerator.orbits.Add(obData);
                }

                allOrbitGenerators.Add(obGenerator);
            }

            return(valid ? obGenerator : null);
        }
Exemple #5
0
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue <TriggeredBehaviour.State>(configNode, "onState", x => onState = x, this, TriggeredBehaviour.State.CONTRACT_SUCCESS);
            if (onState == TriggeredBehaviour.State.PARAMETER_COMPLETED || onState == TriggeredBehaviour.State.PARAMETER_FAILED)
            {
                valid &= ConfigNodeUtil.ParseValue <List <string> >(configNode, "parameter", x => parameter = x, this);
            }

            kerbalInfo = new List <ChangeKerbalType.KerbalInfo>();
            int index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "KERBAL_INFO"))
            {
                string   kerbInfoNode  = "KERBAL_INFO" + index++;
                DataNode childDataNode = new DataNode(kerbInfoNode, dataNode, this);

                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(childDataNode);
                    ChangeKerbalType.KerbalInfo kerb = new ChangeKerbalType.KerbalInfo();
                    kerbalInfo.Add(kerb);

                    valid &= ConfigNodeUtil.ParseValue <Kerbal>(child, "kerbal", x => kerb.kerbal = x, this);
                    valid &= ConfigNodeUtil.ParseValue <ProtoCrewMember.KerbalType?>(child, "kerbalType", x => kerb.kerbalType = x, this, (ProtoCrewMember.KerbalType?)null);
                    valid &= ConfigNodeUtil.ParseValue <string>(child, "trait", x => kerb.trait = x, this, "");
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);
                }
            }
            valid &= ConfigNodeUtil.ValidateMandatoryChild(configNode, "KERBAL_INFO", this);

            return(valid);
        }
        public static SpawnKerbal Create(ConfigNode configNode, SpawnKerbalFactory factory)
        {
            SpawnKerbal spawnKerbal = new SpawnKerbal();

            bool valid = true;
            int  index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "KERBAL"))
            {
                DataNode dataNode = new DataNode("KERBAL_" + index++, factory.dataNode, factory);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);

                    KerbalData kd = new KerbalData();

                    // Use an expression to default - then it'll work for dynamic contracts
                    if (!child.HasValue("targetBody"))
                    {
                        child.AddValue("targetBody", "@/targetBody");
                    }
                    valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", x => kd.body = x, factory);

                    // Get landed stuff
                    if (child.HasValue("lat") && child.HasValue("lon") || child.HasValue("pqsCity"))
                    {
                        kd.landed = true;
                        if (child.HasValue("pqsCity"))
                        {
                            string pqsCityStr = null;
                            valid &= ConfigNodeUtil.ParseValue <string>(child, "pqsCity", x => pqsCityStr = x, factory);
                            if (pqsCityStr != null)
                            {
                                try
                                {
                                    kd.pqsCity = kd.body.GetComponentsInChildren <PQSCity>(true).Where(pqs => pqs.name == pqsCityStr).First();
                                }
                                catch (Exception e)
                                {
                                    LoggingUtil.LogError(typeof(WaypointGenerator), "Couldn't load PQSCity with name '" + pqsCityStr + "'");
                                    LoggingUtil.LogException(e);
                                    valid = false;
                                }
                            }
                            valid &= ConfigNodeUtil.ParseValue <Vector3d>(child, "pqsOffset", x => kd.pqsOffset = x, factory, new Vector3d());

                            // Don't expect these to load anything, but do it to mark as initialized
                            valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => kd.latitude = x, factory, 0.0);
                            valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => kd.longitude = x, factory, 0.0);
                        }
                        else
                        {
                            valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => kd.latitude = x, factory);
                            valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => kd.longitude = x, factory);
                        }

                        valid &= ConfigNodeUtil.ParseValue <float>(child, "heading", x => kd.heading = x, factory, 0.0f);
                    }
                    // Get orbit
                    else if (child.HasNode("ORBIT"))
                    {
                        // Don't expect these to load anything, but do it to mark as initialized
                        valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => kd.latitude = x, factory, 0.0);
                        valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => kd.longitude = x, factory, 0.0);

                        valid &= ConfigNodeUtil.ParseValue <Orbit>(child, "ORBIT", x => kd.orbit = x, factory);
                    }
                    else
                    {
                        // Will error
                        valid &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory);
                    }

                    valid &= ConfigNodeUtil.ParseValue <double?>(child, "alt", x => kd.altitude = x, factory, (double?)null);

                    if (child.HasValue("kerbal"))
                    {
                        valid &= ConfigNodeUtil.ParseValue <Kerbal>(child, "kerbal", x => kd.kerbal = x, factory);
                    }
                    else
                    {
                        // Default gender
                        if (!child.HasValue("gender"))
                        {
                            child.AddValue("gender", "Random()");
                        }
                        valid &= ConfigNodeUtil.ParseValue <ProtoCrewMember.Gender>(child, "gender", x => kd.kerbal.gender = x, factory);

                        // Default name
                        if (!child.HasValue("name"))
                        {
                            child.AddValue("name", "RandomKerbalName(@gender)");
                        }
                        valid &= ConfigNodeUtil.ParseValue <string>(child, "name", x => { kd.kerbal.name = x; if (kd.kerbal.pcm != null)
                                                                                          {
                                                                                              kd.kerbal.pcm.ChangeName(x);
                                                                                          }
                                                                    },
                                                                    factory);
                    }

                    // Get additional stuff
                    valid &= ConfigNodeUtil.ParseValue <bool>(child, "owned", x => kd.owned = x, factory, false);
                    valid &= ConfigNodeUtil.ParseValue <bool>(child, "addToRoster", x => kd.addToRoster = x, factory, true);
                    valid &= ConfigNodeUtil.ParseValue <ProtoCrewMember.KerbalType>(child, "kerbalType", x => kd.kerbal.kerbalType = x, factory, ProtoCrewMember.KerbalType.Unowned);

                    // Check for unexpected values
                    valid &= ConfigNodeUtil.ValidateUnexpectedValues(child, factory);

                    // Add to the list
                    spawnKerbal.kerbals.Add(kd);
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(factory.dataNode);
                }
            }

            return(valid ? spawnKerbal : null);
        }
        public static SpawnVessel Create(ConfigNode configNode, CelestialBody defaultBody, SpawnVesselFactory factory)
        {
            SpawnVessel spawnVessel = new SpawnVessel();

            bool valid = true;
            int  index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "VESSEL"))
            {
                DataNode dataNode = new DataNode("VESSEL_" + index++, factory.dataNode, factory);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);

                    VesselData vessel = new VesselData();

                    // Get name
                    if (child.HasValue("name"))
                    {
                        vessel.name = child.GetValue("name");
                    }

                    // Get paths
                    vessel.craftURL   = ConfigNodeUtil.ParseValue <string>(child, "craftURL");
                    vessel.flagURL    = ConfigNodeUtil.ParseValue <string>(child, "flagURL", (string)null);
                    vessel.vesselType = ConfigNodeUtil.ParseValue <VesselType>(child, "vesselType", VesselType.Ship);

                    // Get celestial body
                    valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", x => vessel.body = x, factory, defaultBody, Validation.NotNull);

                    // Get landed stuff
                    if (child.HasValue("lat") && child.HasValue("lon"))
                    {
                        valid        &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => vessel.latitude = x, factory);
                        valid        &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => vessel.longitude = x, factory);
                        valid        &= ConfigNodeUtil.ParseValue <double?>(child, "alt", x => vessel.altitude = x, factory, (double?)null);
                        vessel.landed = true;
                    }
                    // Get orbit
                    else
                    {
                        valid       &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory);
                        vessel.orbit = new OrbitSnapshot(ConfigNodeUtil.GetChildNode(child, "ORBIT")).Load();
                        vessel.orbit.referenceBody = vessel.body;
                    }

                    // Get additional flags
                    valid &= ConfigNodeUtil.ParseValue <bool>(child, "owned", x => vessel.owned = x, factory, false);

                    // Handle the CREW nodes
                    foreach (ConfigNode crewNode in ConfigNodeUtil.GetChildNodes(child, "CREW"))
                    {
                        int count = 1;
                        valid &= ConfigNodeUtil.ParseValue <int>(crewNode, "count", x => count = x, factory, 1);
                        for (int i = 0; i < count; i++)
                        {
                            CrewData cd = new CrewData();

                            // Read crew details
                            valid &= ConfigNodeUtil.ParseValue <string>(crewNode, "name", x => cd.name = x, factory, (string)null);
                            valid &= ConfigNodeUtil.ParseValue <bool>(crewNode, "addToRoster", x => cd.addToRoster = x, factory, true);

                            // Add the record
                            vessel.crew.Add(cd);
                        }
                    }

                    // Add to the list
                    spawnVessel.vessels.Add(vessel);
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(factory.dataNode);
                }
            }

            return(valid ? spawnVessel : null);
        }
Exemple #8
0
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            int index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "DIALOG_BOX"))
            {
                string   dialogBoxNode = "DIALOG_BOX_" + index++;
                DataNode childDataNode = new DataNode(dialogBoxNode, dataNode, this);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(childDataNode);
                    DialogBox.DialogDetail detail = new DialogBox.DialogDetail();
                    details.Add(detail);

                    valid &= ConfigNodeUtil.ParseValue <DialogBox.TriggerCondition>(child, "condition", x => detail.condition = x, this);
                    valid &= ConfigNodeUtil.ParseValue <DialogBox.Position>(child, "position", x => detail.position = x, this, DialogBox.Position.LEFT);
                    valid &= ConfigNodeUtil.ParseValue <float>(child, "width", x => detail.width = x, this, 0.8f, x => Validation.Between(x, 0.0f, 1.0f));
                    valid &= ConfigNodeUtil.ParseValue <float>(child, "height", x => detail.height = x, this, 0.0f, x => Validation.Between(x, 0.0f, 1.0f));
                    valid &= ConfigNodeUtil.ParseValue <string>(child, "title", x => detail.title = x, this, "");
                    valid &= ConfigNodeUtil.ParseValue <Color>(child, "titleColor", x => detail.titleColor = x, this, Color.white);
                    valid &= ConfigNodeUtil.ParseValue <string>(child, "parameter", x => detail.parameter = x, this, (string)null,
                                                                x => ValidateMandatoryParameter(x, detail.condition));

                    int sectionIndex = 0;
                    foreach (ConfigNode sectionNode in child.GetNodes())
                    {
                        DataNode sectionDataNode = new DataNode(dialogBoxNode + "_" + sectionIndex++, childDataNode, this);
                        ConfigNodeUtil.SetCurrentDataNode(sectionDataNode);

                        if (sectionNode.name == "TEXT")
                        {
                            DialogBox.TextSection section = new DialogBox.TextSection();
                            detail.sections.Add(section);

                            // Parse the text twice, once to ensure parsability, the other to get the unexpanded text
                            valid &= ConfigNodeUtil.ParseValue <string>(sectionNode, "text", x => { }, this);
                            if (valid)
                            {
                                section.text = ConfigNodeUtil.ParseValue <string>(sectionNode, "text");
                            }

                            valid &= ConfigNodeUtil.ParseValue <Color>(sectionNode, "textColor", x => section.textColor = x, this, new Color(0.8f, 0.8f, 0.8f));
                            valid &= ConfigNodeUtil.ParseValue <int>(sectionNode, "fontSize", x => section.fontSize = x, this, 20);
                        }
                        else if (sectionNode.name == "IMAGE")
                        {
                            DialogBox.ImageSection section = new DialogBox.ImageSection();
                            detail.sections.Add(section);

                            valid &= ConfigNodeUtil.ParseValue <string>(sectionNode, "url", x => section.imageURL = x, this, ValidateImageURL);
                            valid &= ConfigNodeUtil.ParseValue <string>(sectionNode, "characterName",
                                                                        x => { section.characterName = x; section.showName = !string.IsNullOrEmpty(x); }, this, "");

                            valid &= ConfigNodeUtil.ParseValue <Color>(sectionNode, "textColor", x => section.textColor = x, this, new Color(0.729f, 0.855f, 0.333f));
                        }
                        else if (sectionNode.name == "INSTRUCTOR")
                        {
                            DialogBox.InstructorSection section = new DialogBox.InstructorSection();
                            detail.sections.Add(section);

                            valid &= ConfigNodeUtil.ParseValue <string>(sectionNode, "name", x => section.name = x, this);
                            valid &= ConfigNodeUtil.ParseValue <bool>(sectionNode, "showName", x => section.showName = x, this, true);
                            valid &= ConfigNodeUtil.ParseValue <string>(sectionNode, "characterName", x => section.characterName = x, this, "");
                            valid &= ConfigNodeUtil.ParseValue <Color>(sectionNode, "textColor", x => section.textColor = x, this, new Color(0.729f, 0.855f, 0.333f));
                            valid &= ConfigNodeUtil.ParseValue <DialogBox.InstructorSection.Animation?>(sectionNode, "animation", x => section.animation = x, this,
                                                                                                        (DialogBox.InstructorSection.Animation?)null);
                        }
                        else if (sectionNode.name == "KERBAL")
                        {
                            DialogBox.KerbalSection section = new DialogBox.KerbalSection();
                            detail.sections.Add(section);

                            valid &= ConfigNodeUtil.ParseValue <bool>(sectionNode, "showName", x => section.showName = x, this, true);
                            valid &= ConfigNodeUtil.ParseValue <string>(sectionNode, "characterName", x => section.characterName = x, this, "");
                            valid &= ConfigNodeUtil.ParseValue <ProtoCrewMember.Gender>(sectionNode, "gender", x => section.gender = x, this, ProtoCrewMember.Gender.Male);
                            valid &= ConfigNodeUtil.ParseValue <Color>(sectionNode, "textColor", x => section.textColor = x, this, new Color(0.729f, 0.855f, 0.333f));

                            valid &= ConfigNodeUtil.ParseValue <int>(sectionNode, "crewIndex", x => section.crewIndex = x, this, 0);
                            valid &= ConfigNodeUtil.ParseValue <List <string> >(sectionNode, "excludeName", x => section.excludeName = x, this, new List <string>());
                        }
                        else if (sectionNode.name == "BREAK")
                        {
                            DialogBox.BreakSection section = new DialogBox.BreakSection();
                            detail.sections.Add(section);
                        }
                    }
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);
                }
            }
            valid &= ConfigNodeUtil.ValidateMandatoryChild(configNode, "DIALOG_BOX", this);

            return(valid);
        }
Exemple #9
0
        public static SpawnKerbal Create(ConfigNode configNode, CelestialBody defaultBody, SpawnKerbalFactory factory)
        {
            SpawnKerbal spawnKerbal = new SpawnKerbal();

            bool valid = true;
            int  index = 0;

            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "KERBAL"))
            {
                DataNode dataNode = new DataNode("KERBAL_" + index++, factory.dataNode, factory);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);

                    KerbalData kerbal = new KerbalData();

                    // Get name
                    if (child.HasValue("name"))
                    {
                        kerbal.name = child.GetValue("name");
                    }

                    // Get celestial body
                    valid &= ConfigNodeUtil.ParseValue <CelestialBody>(child, "targetBody", x => kerbal.body = x, factory, defaultBody, Validation.NotNull);

                    // Get landed stuff
                    if (child.HasValue("lat") && child.HasValue("lon") || child.HasValue("pqsCity"))
                    {
                        kerbal.landed = true;
                        if (child.HasValue("pqsCity"))
                        {
                            string pqsCityStr = null;
                            valid &= ConfigNodeUtil.ParseValue <string>(child, "pqsCity", x => pqsCityStr = x, factory);
                            if (pqsCityStr != null)
                            {
                                try
                                {
                                    kerbal.pqsCity = kerbal.body.GetComponentsInChildren <PQSCity>(true).Where(pqs => pqs.name == pqsCityStr).First();
                                }
                                catch (Exception e)
                                {
                                    LoggingUtil.LogError(typeof(WaypointGenerator), "Couldn't load PQSCity with name '" + pqsCityStr + "'");
                                    LoggingUtil.LogException(e);
                                    valid = false;
                                }
                            }
                            valid &= ConfigNodeUtil.ParseValue <Vector3d>(child, "pqsOffset", x => kerbal.pqsOffset = x, factory, new Vector3d());
                        }
                        else
                        {
                            valid &= ConfigNodeUtil.ParseValue <double>(child, "lat", x => kerbal.latitude = x, factory);
                            valid &= ConfigNodeUtil.ParseValue <double>(child, "lon", x => kerbal.longitude = x, factory);
                        }
                    }
                    // Get orbit
                    else if (child.HasNode("ORBIT"))
                    {
                        kerbal.orbit = new OrbitSnapshot(ConfigNodeUtil.GetChildNode(child, "ORBIT")).Load();
                        kerbal.orbit.referenceBody = kerbal.body;
                    }
                    else
                    {
                        // Will error
                        valid &= ConfigNodeUtil.ValidateMandatoryChild(child, "ORBIT", factory);
                    }

                    valid &= ConfigNodeUtil.ParseValue <double?>(child, "alt", x => kerbal.altitude = x, factory, (double?)null);

                    // Get additional flags
                    valid &= ConfigNodeUtil.ParseValue <bool>(child, "owned", x => kerbal.owned = x, factory, false);
                    valid &= ConfigNodeUtil.ParseValue <bool>(child, "addToRoster", x => kerbal.addToRoster = x, factory, true);

                    // Add to the list
                    spawnKerbal.kerbals.Add(kerbal);
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(factory.dataNode);
                }
            }

            return(valid ? spawnKerbal : null);
        }