void GetOtherPart(KASModuleStrut strut, ConnectedPartSet cp) { Part otherPart = null; if (partMap.TryGetValue(strut.dockedPartID, out otherPart)) { if (strut.vesselInfo != null) { var vi = strut.vesselInfo; cp.Add(otherPart, vi.name); } } }
//FIXME rework for multiple connections ConnectedPartSet ConnectedParts(Part part) { var connectedParts = new ConnectedPartSet(); for (int i = part.Modules.Count; i-- > 0;) { var module = part.Modules[i]; // This covers radial and stack decouplers and separators, // launch clamps, and docking ports. var separator = module as IStageSeparator; if (separator != null) { GetOtherPart(separator, connectedParts); continue; } // The claw is on its own as it is never staged (I guess). var grapple = module as ModuleGrappleNode; if (grapple != null) { GetOtherPart(grapple, connectedParts); continue; } // EL's launchpad module is very much on its own. No need // to worry about survey stations as the built vessel is // never attached, nor disposable pads as they self // destruct. var pad = module as ELLaunchpad; if (pad != null) { GetOtherPart(pad, connectedParts); continue; } //FIXME need to add KAS connectors if (module.moduleName == "KASModuleStrut") { // legacy pipe connector var kasStrut = new KASModuleStrut(module); GetOtherPart(kasStrut, connectedParts); continue; } if (module.moduleName == "KASLinkResourceConnector") { // new resoruce connector. works when undocked! // however, can be used to dock the vessel, in which // case KASJointCableBase is to be checked, or even // just connected on the same vessel (just ignore) var peer = new ILinkPeer(module); if (CheckKASLink(peer)) { continue; } } if (module.moduleName == "KASLinkTargetBase") { // new resoruce connector. works when undocked! // however, can be used to dock the vessel, in which // case KASJointCableBase is to be checked, or even // just connected on the same vessel (just ignore) var peer = new ILinkPeer(module); if (peer.cfgLinkType == "MdHose" && CheckKASLink(peer)) { continue; } } if (module.moduleName == "KASJointCableBase") { var kasJoint = new KASJointCableBase(module); GetOtherPart(kasJoint, connectedParts); } } return(connectedParts); }