示例#1
0
        public List <string> MeetsFacilityRequirements(bool highestFacility = true)
        {
            List <string> failedReasons = new List <string>();

            if (!KCT_Utilities.CurrentGameIsCareer())
            {
                return(failedReasons);
            }

            ShipTemplate template = new ShipTemplate();

            template.LoadShip(shipNode);

            if (this.type == BuildListVessel.ListType.VAB)
            {
                LaunchPad selectedPad = highestFacility ? GameStates.ActiveKSC.GetHighestLevelLaunchPad() : GameStates.ActiveKSC.ActiveLPInstance;
                float     launchpadNormalizedLevel = 1.0f * selectedPad.level / GameStates.BuildingMaxLevelCache["LaunchPad"];

                if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(launchpadNormalizedLevel, true))
                {
                    failedReasons.Add("Mass limit exceeded");
                }
                if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding), true))
                {
                    failedReasons.Add("Part Count limit exceeded");
                }
                PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(launchpadNormalizedLevel, true));
                if (!sizeCheck.Test())
                {
                    failedReasons.Add("Size limits exceeded");
                }
            }
            else if (this.type == BuildListVessel.ListType.SPH)
            {
                if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false))
                {
                    failedReasons.Add("Mass limit exceeded");
                }
                if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), false))
                {
                    failedReasons.Add("Part Count limit exceeded");
                }
                PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false));
                if (!sizeCheck.Test())
                {
                    failedReasons.Add("Size limits exceeded");
                }
            }
            return(failedReasons);
        }
示例#2
0
文件: KSC.cs 项目: ntwest/KCT
        /// <summary>
        /// Finds the highest level LaunchPad on the KSC
        /// </summary>
        /// <returns>The instance of the highest level LaunchPad</returns>
        public LaunchPad GetHighestLevelLaunchPad()
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(GetHighestLevelLaunchPad);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                LaunchPad highest = LaunchPads[0];

                foreach (LaunchPad pad in LaunchPads)
                {
                    if (pad.level > highest.level)
                    {
                        highest = pad;
                    }
                }
                return(highest);
            }
        }
示例#3
0
文件: KSC.cs 项目: ntwest/KCT
        public SpaceCenterConstruction FromConfigNode(ConfigNode node)
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(AsConfigNode);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                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"))
                {
                    BuildListStorage.BuildListItem listItem = new BuildListStorage.BuildListItem();
                    ConfigNode.LoadObjectFromConfig(listItem, vessel);
                    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"))
                {
                    BuildListStorage.BuildListItem listItem = new BuildListStorage.BuildListItem();
                    ConfigNode.LoadObjectFromConfig(listItem, vessel);
                    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"))
                {
                    BuildListStorage.BuildListItem listItem = new BuildListStorage.BuildListItem();
                    ConfigNode.LoadObjectFromConfig(listItem, vessel);
                    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"))
                {
                    BuildListStorage.BuildListItem listItem = new BuildListStorage.BuildListItem();
                    ConfigNode.LoadObjectFromConfig(listItem, vessel);
                    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"))
                {
                    Recon_Rollout tempRR = new 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"))
                    {
                        UpgradingBuilding tempUP = new 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"))
                    {
                        LaunchPad tempLP = new 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);
            }
        }