예제 #1
0
        private bool find_connected_workshops(Part next_part, HashSet <uint> visited)
        {
#if DEBUG
            this.Log($"Searching for CWS and AWS in {next_part.GetID()}");
#endif
            if (next_part == null || visited.Contains(next_part.persistentId))
            {
                return(false);
            }
            visited.Add(next_part.persistentId);
            if (connected_construction_ws == null)
            {
                connected_construction_ws =
                    next_part.FindModuleImplementing <ConstructionWorkshop>();
            }
            if (connected_assembly_ws == null)
            {
                connected_assembly_ws =
                    next_part.FindModuleImplementing <AssemblyWorkshop>();
            }
#if DEBUG
            this.Log($"Found so far: CWS: {connected_construction_ws.GetID()}, AWS: {connected_assembly_ws.GetID()}");
#endif
            if (connected_construction_ws != null && connected_assembly_ws != null)
            {
                return(true);
            }
            foreach (var d in next_part.FindModulesImplementing <ModuleDockingNode>())
            {
                var docked_part = vessel[d.dockedPartUId];
                if (find_connected_workshops(docked_part, visited))
                {
                    return(true);
                }
            }
            if (find_connected_workshops(next_part.parent, visited))
            {
                return(true);
            }
            for (int i = 0, len = next_part.children.Count; i < len; i++)
            {
                if (find_connected_workshops(next_part.children[i], visited))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #2
0
        private void find_connected_workshops()
        {
            connected_assembly_ws     = null;
            connected_construction_ws = null;
            var visited_parts = new HashSet <uint> {
                part.persistentId
            };

            if (construction_port != null)
            {
                var docked_part = vessel[construction_port.dockedPartUId];
                if (find_connected_workshops(docked_part, visited_parts))
                {
                    return;
                }
            }
            if (construction_node != null)
            {
                find_connected_workshops(construction_node.attachedPart, visited_parts);
            }
        }