Exemplo n.º 1
0
        /// <summary>
        /// Scan the provided part and all its children recursively, looking for any of them that have
        /// a ModuleVesselCategorizer.  Add any found modules to the list.
        /// </summary>
        /// <param name="root"></param>
        /// <param name="toInitialize"></param>
        private static void CollectToInitializerList(Part root, List <ModuleVesselCategorizer> toInitialize)
        {
            if (root == null)
            {
                return;
            }
            ModuleVesselCategorizer module = ModuleVesselCategorizer.FindFirst(root);

            if (module != null)
            {
                toInitialize.Add(module);
            }
            if (root.children == null)
            {
                return;
            }
            for (int i = 0; i < root.children.Count; ++i)
            {
                CollectToInitializerList(root.children[i], toInitialize);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Finds the first ModuleVesselCategorizer on the current ship construct, aside
        /// from any module in the supplied list. Returns that module, or null if none exists.
        /// </summary>
        /// <param name="excluded"></param>
        /// <returns></returns>
        private static ModuleVesselCategorizer FindFirstNotInList(List <ModuleVesselCategorizer> excluded)
        {
            ShipConstruct ship = CurrentShipConstruct;

            if (ship == null)
            {
                return(null);
            }
            for (int i = 0; i < ship.Parts.Count; ++i)
            {
                Part part = ship.Parts[i];
                ModuleVesselCategorizer module = ModuleVesselCategorizer.FindFirst(part);
                if (module == null)
                {
                    continue;
                }
                if (excluded.Contains(module))
                {
                    continue;
                }
                return(module);
            }
            return(null); // nope, there isn't one
        }