コード例 #1
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            var crewNodes = node.GetNodes(CrewMemberInfo.ConfigNodeName);

            foreach (ConfigNode n in crewNodes)
            {
                crew.Add(CrewMemberInfo.Load(n));
            }
            //crew
            var allCrew = HighLogic.CurrentGame.CrewRoster.Crew;

            foreach (var c in allCrew)
            {
                if (crew.FindIndex(c_ => c_.name == c.name) == -1)
                {
                    crew.Add(new CrewMemberInfo(c.name, "", Guid.Empty));
                }
            }

            var allVessels = FlightGlobals.Vessels;

            this.Log(allVessels.Count.ToString());
            foreach (Vessel v in allVessels)
            {
                var currentCrew = v.GetVesselCrew();
                foreach (ProtoCrewMember pcm in currentCrew)
                {
                    int idx = crew.FindIndex(c => c.name == pcm.name);
                    if (idx == -1)
                    {
                        this.LogError("not found");
                    }
                    crew[idx].vesselName = v.GetName();
                    crew[idx].vesselId   = v.id;
                }
            }
            //Loading CuriePlaceEmitters
            var nodes = node.GetNodes(CuriePlaceEmitter.ConfigNodeName);

            foreach (var n in nodes)
            {
                placeEmitters.Add(CuriePlaceEmitter.Load(n));
                this.Log("PlaceEmitter for " + placeEmitters[placeEmitters.Count - 1].bodyName + " loaded from save");
            }
            var defaultNodes = GameDatabase.Instance.GetConfigNode("Curie/CurieSettings").GetNodes(CuriePlaceEmitter.ConfigNodeName);

            this.Log(defaultNodes.GetLength(0).ToString());
            foreach (var n in defaultNodes)
            {
                this.Log(n.ToString());
                if (placeEmitters.FindIndex(pe => pe.bodyName == n.GetValue("bodyName")) != -1)
                {
                    continue;
                }
                placeEmitters.Add(CuriePlaceEmitter.Load(n));
                this.Log("PlaceEmitter for " + placeEmitters[placeEmitters.Count - 1].bodyName + " loaded from config");
            }
        }
コード例 #2
0
        public static CrewMemberInfo Load(ConfigNode node)
        {
            string name       = Utilities.GetValue(node, "name", "Unknown");
            string vesselName = Utilities.GetValue(node, "vesselName", "");
            Guid   vesselId;

            if (node.HasValue("vesselId"))
            {
                vesselId = new Guid(node.GetValue("vesselId"));
            }
            else
            {
                vesselId = Guid.Empty;
            }

            CrewMemberInfo info = new CrewMemberInfo(name, vesselName, vesselId);

            info.doze = Utilities.GetValue(node, "doze", 0);

            return(info);
        }