コード例 #1
0
        public KCT_KSC FromConfigNode(ConfigNode node)
        {
            VABUpgrades.Clear();
            SPHUpgrades.Clear();
            RDUpgrades.Clear();
            VABList.Clear();
            VABWarehouse.Clear();
            SPHList.Clear();
            SPHWarehouse.Clear();
            KSCTech.Clear();
            //TechList.Clear();
            Recon_Rollout.Clear();
            VABRates.Clear();
            SPHRates.Clear();



            this.KSCName = node.GetValue("KSCName");
            if (!int.TryParse(node.GetValue("ActiveLPID"), out this.ActiveLaunchPadID))
            {
                this.ActiveLaunchPadID = 0;
            }
            ConfigNode vabup = node.GetNode("VABUpgrades");

            foreach (string upgrade in vabup.GetValues("Upgrade"))
            {
                this.VABUpgrades.Add(int.Parse(upgrade));
            }
            ConfigNode sphup = node.GetNode("SPHUpgrades");

            foreach (string upgrade in sphup.GetValues("Upgrade"))
            {
                this.SPHUpgrades.Add(int.Parse(upgrade));
            }
            ConfigNode rdup = node.GetNode("RDUpgrades");

            foreach (string upgrade in rdup.GetValues("Upgrade"))
            {
                this.RDUpgrades.Add(int.Parse(upgrade));
            }

            ConfigNode tmp = node.GetNode("VABList");

            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.VABList.Add(blv);
            }

            tmp = node.GetNode("SPHList");
            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.SPHList.Add(blv);
            }

            tmp = node.GetNode("VABWarehouse");
            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.VABWarehouse.Add(blv);
            }

            tmp = node.GetNode("SPHWarehouse");
            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.SPHWarehouse.Add(blv);
            }

            /* tmp = node.GetNode("TechList");
             * foreach (ConfigNode techNode in tmp.GetNodes("Tech"))
             * {
             *   KCT_TechStorageItem techStorageItem = new KCT_TechStorageItem();
             *   ConfigNode.LoadObjectFromConfig(techStorageItem, techNode);
             *   KCT_TechItem techItem = techStorageItem.ToTechItem();
             *   techItem.protoNode = new ProtoTechNode(techNode.GetNode("ProtoNode"));
             *   this.TechList.Add(techItem);
             * }*/

            tmp = node.GetNode("Recon_Rollout");
            foreach (ConfigNode RRCN in tmp.GetNodes("Recon_Rollout_Item"))
            {
                KCT_Recon_Rollout tempRR = new KCT_Recon_Rollout();
                ConfigNode.LoadObjectFromConfig(tempRR, RRCN);
                Recon_Rollout.Add(tempRR);
            }

            if (node.HasNode("KSCTech"))
            {
                tmp = node.GetNode("KSCTech");
                foreach (ConfigNode upBuild in tmp.GetNodes("UpgradingBuilding"))
                {
                    KCT_UpgradingBuilding tempUP = new KCT_UpgradingBuilding();
                    ConfigNode.LoadObjectFromConfig(tempUP, upBuild);
                    KSCTech.Add(tempUP);
                }
            }

            if (node.HasNode("LaunchPads"))
            {
                LaunchPads.Clear();
                tmp = node.GetNode("LaunchPads");
                foreach (ConfigNode LP in tmp.GetNodes("KCT_LaunchPad"))
                {
                    KCT_LaunchPad tempLP = new KCT_LaunchPad("LP0");
                    ConfigNode.LoadObjectFromConfig(tempLP, LP);
                    tempLP.DestructionNode = LP.GetNode("DestructionState");
                    LaunchPads.Add(tempLP);
                }
            }

            if (node.HasNode("VABRateCache"))
            {
                foreach (string rate in node.GetNode("VABRateCache").GetValues("rate"))
                {
                    double r;
                    if (double.TryParse(rate, out r))
                    {
                        VABRates.Add(r);
                    }
                }
            }

            if (node.HasNode("SPHRateCache"))
            {
                foreach (string rate in node.GetNode("SPHRateCache").GetValues("rate"))
                {
                    double r;
                    if (double.TryParse(rate, out r))
                    {
                        SPHRates.Add(r);
                    }
                }
            }

            return(this);
        }
コード例 #2
0
ファイル: KCT_KSC.cs プロジェクト: tivec/KCT
        public KCT_KSC FromConfigNode(ConfigNode node)
        {
            VABUpgrades.Clear();
            SPHUpgrades.Clear();
            RDUpgrades.Clear();
            VABList.Clear();
            VABWarehouse.Clear();
            SPHList.Clear();
            SPHWarehouse.Clear();
            VABPlans.Clear();
            SPHPlans.Clear();
            KSCTech.Clear();
            //TechList.Clear();
            Recon_Rollout.Clear();
            AirlaunchPrep.Clear();
            VABRates.Clear();
            SPHRates.Clear();

            this.KSCName = node.GetValue("KSCName");
            if (!int.TryParse(node.GetValue("ActiveLPID"), out this.ActiveLaunchPadID))
            {
                this.ActiveLaunchPadID = 0;
            }
            ConfigNode vabup = node.GetNode("VABUpgrades");

            foreach (string upgrade in vabup.GetValues("Upgrade"))
            {
                this.VABUpgrades.Add(int.Parse(upgrade));
            }
            ConfigNode sphup = node.GetNode("SPHUpgrades");

            foreach (string upgrade in sphup.GetValues("Upgrade"))
            {
                this.SPHUpgrades.Add(int.Parse(upgrade));
            }
            ConfigNode rdup = node.GetNode("RDUpgrades");

            foreach (string upgrade in rdup.GetValues("Upgrade"))
            {
                this.RDUpgrades.Add(int.Parse(upgrade));
            }

            ConfigNode tmp = node.GetNode("VABList");

            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.VABList.Add(blv);
            }

            tmp = node.GetNode("SPHList");
            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.SPHList.Add(blv);
            }

            tmp = node.GetNode("VABWarehouse");
            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.VABWarehouse.Add(blv);
            }

            tmp = node.GetNode("SPHWarehouse");
            foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
            {
                KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                ConfigNode.LoadObjectFromConfig(listItem, vessel);
                KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                blv.shipNode = vessel.GetNode("ShipNode");
                blv.KSC      = this;
                this.SPHWarehouse.Add(blv);
            }

            if (node.TryGetNode("VABPlans", ref tmp))
            {
                if (tmp.HasNode("KCTVessel"))
                {
                    foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
                    {
                        KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                        ConfigNode.LoadObjectFromConfig(listItem, vessel);
                        KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                        blv.shipNode = vessel.GetNode("ShipNode");
                        blv.KSC      = this;
                        if (this.VABPlans.ContainsKey(blv.shipName))
                        {
                            this.VABPlans.Remove(blv.shipName);
                        }

                        this.VABPlans.Add(blv.shipName, blv);
                    }
                }
            }

            if (node.TryGetNode("SPHPlans", ref tmp))
            {
                if (tmp.HasNode("KCTVessel"))
                {
                    foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel"))
                    {
                        KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem();
                        ConfigNode.LoadObjectFromConfig(listItem, vessel);
                        KCT_BuildListVessel blv = listItem.ToBuildListVessel();
                        blv.shipNode = vessel.GetNode("ShipNode");
                        blv.KSC      = this;
                        if (this.SPHPlans.ContainsKey(blv.shipName))
                        {
                            this.SPHPlans.Remove(blv.shipName);
                        }
                        this.SPHPlans.Add(blv.shipName, blv);
                    }
                }
            }

            tmp = node.GetNode("Recon_Rollout");
            foreach (ConfigNode RRCN in tmp.GetNodes("Recon_Rollout_Item"))
            {
                KCT_Recon_Rollout tempRR = new KCT_Recon_Rollout();
                ConfigNode.LoadObjectFromConfig(tempRR, RRCN);
                Recon_Rollout.Add(tempRR);
            }

            if (node.TryGetNode("Airlaunch_Prep", ref tmp))
            {
                foreach (ConfigNode APCN in tmp.GetNodes("Airlaunch_Prep_Item"))
                {
                    KCT_AirlaunchPrep temp = new KCT_AirlaunchPrep();
                    ConfigNode.LoadObjectFromConfig(temp, APCN);
                    AirlaunchPrep.Add(temp);
                }
            }

            if (node.HasNode("KSCTech"))
            {
                tmp = node.GetNode("KSCTech");
                foreach (ConfigNode upBuild in tmp.GetNodes("UpgradingBuilding"))
                {
                    KCT_UpgradingBuilding tempUP = new KCT_UpgradingBuilding();
                    tempUP.Load(upBuild);
                    KSCTech.Add(tempUP);
                }
            }

            if (node.HasNode("LaunchPads"))
            {
                LaunchPads.Clear();
                tmp = node.GetNode("LaunchPads");
                foreach (ConfigNode LP in tmp.GetNodes("KCT_LaunchPad"))
                {
                    KCT_LaunchPad tempLP = new KCT_LaunchPad("LP0");
                    ConfigNode.LoadObjectFromConfig(tempLP, LP);
                    tempLP.DestructionNode = LP.GetNode("DestructionState");
                    LaunchPads.Add(tempLP);
                }
            }

            if (node.HasNode("VABRateCache"))
            {
                foreach (string rate in node.GetNode("VABRateCache").GetValues("rate"))
                {
                    double r;
                    if (double.TryParse(rate, out r))
                    {
                        VABRates.Add(r);
                    }
                }
            }

            if (node.HasNode("SPHRateCache"))
            {
                foreach (string rate in node.GetNode("SPHRateCache").GetValues("rate"))
                {
                    double r;
                    if (double.TryParse(rate, out r))
                    {
                        SPHRates.Add(r);
                    }
                }
            }

            return(this);
        }