//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; } } return(connectedParts); }
void GetOtherPart(ModuleGrappleNode grapple, ConnectedPartSet cp) { // The claw is a very unfriendly part. All the important fields // private. AttachNode grappleNode = (AttachNode)grappleNodeField.GetValue(grapple); if (grappleNode != null && grappleNode.attachedPart != null) { var vi = grapple.vesselInfo; cp.Add(grappleNode.attachedPart, vi.name); } }
void GetOtherPart(IStageSeparator separator, ConnectedPartSet cp) { AttachNode node = null; if (separator is ModuleAnchoredDecoupler) { node = (separator as ModuleAnchoredDecoupler).ExplosiveNode; } else if (separator is ModuleDecouple) { node = (separator as ModuleDecouple).ExplosiveNode; } else if (separator is ModuleDockingNode) { // if referenceNode.attachedPart is not null, then the port // was attached in the editor and may be separated later, // otherwise, need to check for the port having been docked. // if referenceNode itself is null, then the port cannot be // docked in the editor (eg, inline docking port) var port = separator as ModuleDockingNode; Part otherPart = null; if (partMap.TryGetValue(port.dockedPartUId, out otherPart)) { if (port.vesselInfo != null) { var vi = port.vesselInfo; cp.Add(otherPart, vi.name); return; } } node = port.referenceNode; if (node == null) { //Debug.LogFormat ("[RMResourceManager] docking port null"); return; } } if (node == null) { // separators detach on both ends (and all surface attachments?) // and thus don't keep track of the node(s), so return the parent Part p = (separator as PartModule).part; if (p.parent != null) { cp.Add(p.parent, "separator"); } return; } if (node.attachedPart != null) { cp.Add(node.attachedPart, "decoupler"); } }
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); } } }
void GetOtherPart(ELLaunchpad pad, ConnectedPartSet cp) { // no need to worry about something attached via a node as // hopefully that part is a decoupler of some sort, otherwise // the pad is probably unusable, and surface attached parts // don't matter too much, either. // if pad.control is ever null, bigger problems are afoot if (pad.control.craftRoot != null) { var vi = pad.control.vesselInfo; cp.Add(pad.control.craftRoot, vi.name); } }
void GetOtherPart(KASJointCableBase joint, ConnectedPartSet cp) { if (joint.isLinked) { var srcVessel = joint.linkSource.part.vessel; var dstVessel = joint.linkTarget.part.vessel; if (srcVessel == dstVessel && joint.persistedTgtVesselInfo != null) { cp.Add(joint.linkTarget.part, joint.persistedTgtVesselInfo.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 } return(connectedParts); }
//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); }