internal Decoupler(Part part) { Part = part; decoupler = new Compatibility.ModuleDecoupler(part.InternalPart); if (decoupler.Instance == null) { throw new ArgumentException("Part is not a decoupler"); } }
public static int DecoupledAt(this Part part) { int stage = -1; do { int candidate = -1; var parent = part.parent; var decoupler = new Compatibility.ModuleDecoupler(part); // If the part will decouple itself from its parent, use the parts activation stage if (part.HasModule <LaunchClamp> ()) { candidate = part.inverseStage; } else if (decoupler.Instance != null && decoupler.IsEnabled) { if (decoupler.IsOmniDecoupler) { candidate = part.inverseStage; } else if (parent != null && decoupler.ExplosiveNode != null && decoupler.ExplosiveNode.attachedPart == parent) { candidate = part.inverseStage; } } // If the part will be decoupled by its parent, use the parents activation stage if (candidate == -1 && parent != null) { if (decoupler.Instance != null) { if (decoupler.IsOmniDecoupler && decoupler.IsEnabled) { candidate = parent.inverseStage; } else if (decoupler.ExplosiveNode != null && decoupler.ExplosiveNode.attachedPart == part) { candidate = parent.inverseStage; } } } stage = Math.Max(candidate, stage); part = part.parent; } while (part != null); return(stage); }