private static bool IsEnginePlate(Part thePart) { ModuleDecouple mdec = thePart.GetModule <ModuleDecouple>(); if (mdec != null && mdec.IsStageable()) { ModuleDynamicNodes mdyn = thePart.GetModule <ModuleDynamicNodes>(); if (mdyn != null) { return(true); } } return(false); }
private int DecoupledInStage(Part thePart) { int stage = -1; Part original = thePart; while (thePart != null) { if (thePart.inverseStage > stage) { ModuleDecouple mdec = thePart.GetModule <ModuleDecouple>(); ModuleDockingNode mdock = thePart.GetModule <ModuleDockingNode>(); ModuleAnchoredDecoupler manch = thePart.GetModule <ModuleAnchoredDecoupler>(); if (mdec != null) { ModuleDynamicNodes mdyn = thePart.GetModule <ModuleDynamicNodes>(); if (mdyn != null) { //engine plate if (original == thePart) { //checking self, make sure not upside down if (thePart.FindAttachNodeByPart(thePart.parent).id == "bottom") //leaves with stage { stage = thePart.inverseStage; } } else if (original.parent != null && original.parent == thePart) { //plate direct child. if (thePart.FindAttachNodeByPart(original).id == "bottom") { stage = thePart.inverseStage; //goodbye! } } else { stage = thePart.inverseStage; //decouple. } } else { //regular decoupler if (original == thePart) { //checking self if (mdec.isOmniDecoupler || thePart.FindAttachNodeByPart(thePart.parent).id == "top") //leaves with stage { stage = thePart.inverseStage; } } else { stage = thePart.inverseStage; } } } if (manch != null) //radial decouple { if (original == thePart) { //checking self if (thePart.FindAttachNodeByPart(thePart.parent).id == "top") //leaves with stage { stage = thePart.inverseStage; } } else { stage = thePart.inverseStage; } } if (mdock != null) //docking port { if (original == thePart) { //checking self, never leaves. } else { stage = thePart.inverseStage; } } } thePart = thePart.parent; } return(stage); }