IEnumerator DelayedDecouplerCheck(FlightJointTracker joint, Vessel owner) { FixedJoint[] tempJoints = new FixedJoint[2]; if (joint.ParentStillValid(0)) { tempJoints[0] = joint.parts[0].gameObject.AddComponent <FixedJoint>(); tempJoints[0].connectedBody = joint.parents[0].part.Rigidbody; } if (joint.ParentStillValid(1)) { tempJoints[1] = joint.parts[1].gameObject.AddComponent <FixedJoint>(); tempJoints[1].connectedBody = joint.parents[1].part.Rigidbody; } yield return(new WaitForFixedUpdate()); if (tempJoints[0] != null) { DestroyImmediate(tempJoints[0]); } if (tempJoints[1] != null) { DestroyImmediate(tempJoints[1]); } log.debug("Running DelayedDecouplerCheck on " + owner.vesselName); joint.PostDecouplerCheck(); }
public Vessel findDictEntry(FlightJointTracker jt) { for (int i = trackedJoints.Count - 1; i >= 0; i--) { if (trackedJoints.Values.ElementAt(i).Contains(jt)) { return(trackedJoints.Keys.ElementAt(i)); } } return(null); }
IEnumerator DelayedBreak(FlightJointTracker joint, Vessel owner) { yield return(new WaitForFixedUpdate()); log.debug("Running DelayedBreak on " + owner.vesselName); if (!joint.linkCreated) { joint.Destroy(); trackedJoints[owner].Remove(joint); } }
private void parseAttachNodes(AttachNode parentNode, List <AttachNode> childNodes, Vessel vessel = null) { if (vessel == null) { vessel = parentNode.owner.vessel; } for (int i = 0; i < childNodes.Count; i++) { FlightJointTracker existingTracker = allJoints.FirstOrDefault((FlightJointTracker jt) => jt.nodes.Contains(parentNode) && jt.nodes.Contains(childNodes[i])); if (existingTracker == null) { trackedJoints[vessel].Add(new FlightJointTracker(parentNode, childNodes[i])); } else if (!trackedJoints[vessel].Contains(existingTracker)) { trackedJoints[vessel].Add(existingTracker); Vessel currentListing = findDictEntry(existingTracker); if (currentListing != null) { trackedJoints[currentListing].Remove(existingTracker); } } } }