コード例 #1
0
        /// <summary>
        /// Checks that the given type of PartModule is valid.
        /// </summary>
        /// <param name="name">name of the PartModule type</param>
        /// <returns>True if valid, exeption otherwise</returns>
        public static bool ValidatePartModuleType(string name)
        {
            if (ContractDefs.GetModules(name).Count == 0)
            {
                throw new ArgumentException("No PartModules found for type '" + name + "'.");
            }

            return(true);
        }
コード例 #2
0
        private bool PartHasModuleType(Part p, string partModuleType)
        {
            List <string> modules = ContractDefs.GetModules(partModuleType);

            foreach (PartModule pm in p.Modules)
            {
                if (modules.Contains(pm.moduleName))
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
        /// <summary>
        /// Checks that the given type of PartModule is valid.
        /// </summary>
        /// <param name="name">name of the PartModule type</param>
        /// <returns>True if valid, exception otherwise</returns>
        public static bool ValidatePartModuleType(string name)
        {
            // Check if we need to force-initalize the contract definitions
            if (ContractDefs.config == null)
            {
                new ContractDefs();
            }

            if (ContractDefs.GetModules(name).Count == 0)
            {
                throw new ArgumentException("No PartModules found for type '" + name + "'.");
            }

            return(true);
        }
コード例 #4
0
        public override bool RequirementMet(ConfiguredContract contract)
        {
            foreach (string tech in techs)
            {
                ProtoTechNode techNode = ResearchAndDevelopment.Instance.GetTechState(tech);
                if (techNode == null || techNode.state != RDTech.State.Available)
                {
                    return(false);
                }
            }

            foreach (string partModule in partModules)
            {
                bool hasModule = false;
                foreach (AvailablePart part in PartLoader.LoadedPartsList)
                {
                    if (part.partPrefab == null || part.partPrefab.Modules == null)
                    {
                        continue;
                    }

                    if (ResearchAndDevelopment.PartTechAvailable(part))
                    {
                        hasModule = true;
                        break;
                    }
                }

                if (!hasModule)
                {
                    return(false);
                }
            }

            foreach (string partModuleType in partModuleTypes)
            {
                List <string> modules = ContractDefs.GetModules(partModuleType);

                bool hasType = false;
                foreach (string module in modules)
                {
                    foreach (AvailablePart part in PartLoader.LoadedPartsList)
                    {
                        if (part.partPrefab == null || part.partPrefab.Modules == null)
                        {
                            continue;
                        }

                        if (ResearchAndDevelopment.PartTechAvailable(part))
                        {
                            hasType = true;
                            break;
                        }
                    }

                    if (hasType)
                    {
                        break;
                    }
                }

                if (!hasType)
                {
                    return(false);
                }
            }

            return(true);
        }