示例#1
0
文件: KSCItem.cs 项目: KvaNTy/RP-0
        private void BuildVesselAndShipNodeConfigs(BuildListVessel blv, ref ConfigNode node)
        {
            var storageItem = new BuildListStorageItem();

            storageItem.FromBuildListVessel(blv);
            var cnTemp = new ConfigNode("KCTVessel");

            cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
            var shipNode = new ConfigNode("ShipNode");

            blv.ShipNode.CopyTo(shipNode);
            cnTemp.AddNode(shipNode);
            node.AddNode(cnTemp);
        }
示例#2
0
文件: KSCItem.cs 项目: vader111/RP-0
        public ConfigNode AsConfigNode()
        {
            KCTDebug.Log("Saving KSC " + KSCName);
            var node = new ConfigNode("KSC");

            node.AddValue("KSCName", KSCName);
            node.AddValue("ActiveLPID", ActiveLaunchPadID);

            var cnVABUp = new ConfigNode("VABUpgrades");

            foreach (int upgrade in VABUpgrades)
            {
                cnVABUp.AddValue("Upgrade", upgrade.ToString());
            }
            node.AddNode(cnVABUp);

            var cnSPHUp = new ConfigNode("SPHUpgrades");

            foreach (int upgrade in SPHUpgrades)
            {
                cnSPHUp.AddValue("Upgrade", upgrade.ToString());
            }
            node.AddNode(cnSPHUp);

            var cnRDUp = new ConfigNode("RDUpgrades");

            foreach (int upgrade in RDUpgrades)
            {
                cnRDUp.AddValue("Upgrade", upgrade.ToString());
            }
            node.AddNode(cnRDUp);

            var cnVABl = new ConfigNode("VABList");

            foreach (BuildListVessel blv in VABList)
            {
                blv.BuildListIndex = BuildList.IndexOf(blv);
                var storageItem = new BuildListStorageItem();
                storageItem.FromBuildListVessel(blv);
                var cnTemp = new ConfigNode("KCTVessel");
                cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
                var shipNode = new ConfigNode("ShipNode");
                blv.ShipNode.CopyTo(shipNode);
                cnTemp.AddNode(shipNode);
                cnVABl.AddNode(cnTemp);
            }
            node.AddNode(cnVABl);

            var cnSPHl = new ConfigNode("SPHList");

            foreach (BuildListVessel blv in SPHList)
            {
                blv.BuildListIndex = BuildList.IndexOf(blv);
                var storageItem = new BuildListStorageItem();
                storageItem.FromBuildListVessel(blv);
                var cnTemp = new ConfigNode("KCTVessel");
                cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
                var shipNode = new ConfigNode("ShipNode");
                blv.ShipNode.CopyTo(shipNode);
                cnTemp.AddNode(shipNode);
                cnSPHl.AddNode(cnTemp);
            }
            node.AddNode(cnSPHl);

            var cnVABWh = new ConfigNode("VABWarehouse");

            foreach (BuildListVessel blv in VABWarehouse)
            {
                var storageItem = new BuildListStorageItem();
                storageItem.FromBuildListVessel(blv);
                var cnTemp = new ConfigNode("KCTVessel");
                cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
                var shipNode = new ConfigNode("ShipNode");
                blv.ShipNode.CopyTo(shipNode);
                cnTemp.AddNode(shipNode);
                cnVABWh.AddNode(cnTemp);
            }
            node.AddNode(cnVABWh);

            var cnSPHWh = new ConfigNode("SPHWarehouse");

            foreach (BuildListVessel blv in SPHWarehouse)
            {
                var storageItem = new BuildListStorageItem();
                storageItem.FromBuildListVessel(blv);
                var cnTemp = new ConfigNode("KCTVessel");
                cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
                var shipNode = new ConfigNode("ShipNode");
                blv.ShipNode.CopyTo(shipNode);
                cnTemp.AddNode(shipNode);
                cnSPHWh.AddNode(cnTemp);
            }
            node.AddNode(cnSPHWh);

            var cnUpgradeables = new ConfigNode("KSCTech");

            foreach (FacilityUpgrade buildingTech in KSCTech)
            {
                var storageItem = new FacilityUpgradeStorageItem();
                storageItem.FromFacilityUpgrade(buildingTech);
                var cn = new ConfigNode("UpgradingBuilding");
                cn = ConfigNode.CreateConfigFromObject(storageItem, cn);
                cnUpgradeables.AddNode(cn);
            }
            node.AddNode(cnUpgradeables);

            var cnVABPlans = new ConfigNode("VABPlans");

            foreach (BuildListVessel blv in VABPlans.Values)
            {
                var storageItem = new BuildListStorageItem();
                storageItem.FromBuildListVessel(blv);
                var cnTemp = new ConfigNode("KCTVessel");
                cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
                var shipNode = new ConfigNode("ShipNode");
                blv.ShipNode.CopyTo(shipNode);
                cnTemp.AddNode(shipNode);
                cnVABPlans.AddNode(cnTemp);
            }
            node.AddNode(cnVABPlans);

            var cnSPHPlans = new ConfigNode("SPHPlans");

            foreach (BuildListVessel blv in SPHPlans.Values)
            {
                var storageItem = new BuildListStorageItem();
                storageItem.FromBuildListVessel(blv);
                var cnTemp = new ConfigNode("KCTVessel");
                cnTemp = ConfigNode.CreateConfigFromObject(storageItem, cnTemp);
                var shipNode = new ConfigNode("ShipNode");
                blv.ShipNode.CopyTo(shipNode);
                cnTemp.AddNode(shipNode);
                cnSPHPlans.AddNode(cnTemp);
            }
            node.AddNode(cnSPHPlans);

            var cnRR = new ConfigNode("Recon_Rollout");

            foreach (ReconRollout rr in Recon_Rollout)
            {
                var storageItem = new ReconRolloutStorageItem();
                storageItem.FromReconRollout(rr);
                var rrCN = new ConfigNode("Recon_Rollout_Item");
                rrCN = ConfigNode.CreateConfigFromObject(storageItem, rrCN);
                cnRR.AddNode(rrCN);
            }
            node.AddNode(cnRR);

            var cnAP = new ConfigNode("Airlaunch_Prep");

            foreach (AirlaunchPrep ap in AirlaunchPrep)
            {
                var storageItem = new AirlaunchPrepStorageItem();
                storageItem.FromAirlaunchPrep(ap);
                var cn = new ConfigNode("Airlaunch_Prep_Item");
                cn = ConfigNode.CreateConfigFromObject(storageItem, cn);
                cnAP.AddNode(cn);
            }
            node.AddNode(cnAP);

            var cnLPs = new ConfigNode("LaunchPads");

            foreach (KCT_LaunchPad lp in LaunchPads)
            {
                ConfigNode lpCN = lp.AsConfigNode();
                lpCN.AddNode(lp.DestructionNode);
                cnLPs.AddNode(lpCN);
            }
            node.AddNode(cnLPs);

            //Cache the regular rates
            var cnCachedVABRates = new ConfigNode("VABRateCache");

            foreach (double rate in VABRates)
            {
                cnCachedVABRates.AddValue("rate", rate);
            }
            node.AddNode(cnCachedVABRates);

            var cnCachedSPHRates = new ConfigNode("SPHRateCache");

            foreach (double rate in SPHRates)
            {
                cnCachedSPHRates.AddValue("rate", rate);
            }
            node.AddNode(cnCachedSPHRates);
            return(node);
        }