Ejemplo n.º 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 == ListType.VAB)
            {
                KCT_LaunchPad selectedPad = highestFacility ? KCT_GameStates.ActiveKSC.GetHighestLevelLaunchPad() : KCT_GameStates.ActiveKSC.ActiveLPInstance;
                float         launchpadNormalizedLevel = 1.0f * selectedPad.level / KCT_GameStates.BuildingMaxLevelCache["LaunchPad"];

                double totalMass = GetTotalMass();
                if (totalMass > GameVariables.Instance.GetCraftMassLimit(launchpadNormalizedLevel, true))
                {
                    failedReasons.Add($"Mass limit exceeded, currently at {totalMass:N} tons");
                }
                if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding), true))
                {
                    failedReasons.Add("Part Count limit exceeded");
                }
                CraftWithinSizeLimits sizeCheck = new CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(launchpadNormalizedLevel, true));
                if (!sizeCheck.Test())
                {
                    failedReasons.Add("Size limits exceeded");
                }
            }
            else if (this.type == ListType.SPH)
            {
                double totalMass = GetTotalMass();
                if (totalMass > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false))
                {
                    failedReasons.Add($"Mass limit exceeded, currently at {totalMass:N} tons");
                }
                if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), false))
                {
                    failedReasons.Add("Part Count limit exceeded");
                }
                CraftWithinSizeLimits sizeCheck = new CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false));
                if (!sizeCheck.Test())
                {
                    failedReasons.Add("Size limits exceeded");
                }
            }

            Dictionary <AvailablePart, int> lockedParts = GetLockedParts();

            if (lockedParts?.Count > 0)
            {
                var msg = KCT_Utilities.ConstructLockedPartsWarning(lockedParts);
                failedReasons.Add(msg);
            }

            return(failedReasons);
        }