public static bool isFuelTank(Part p)
{
if (p == null) {
ASPConsoleStuff.AAprint ("isFuelTank.p is null!");
return false;
}
PartResourceList rl = p.Resources;
if (rl == null) {
ASPConsoleStuff.printPart ("isFuelTank: Part is NOT a fuel tank, no resources", p);
return false;
}
if (rl.Count == 0) {
ASPConsoleStuff.printPart ("isFuelTank: Part is NOT a fuel tank, no resources", p);
return false;
}
// Check if this part has any resource that would actually flow through a fuel line
PartResourceDefinition resource;
foreach (PartResource pr in rl.dict.Values) {
ASPConsoleStuff.printPart ("isFuelTank: part has resource named: " + pr.resourceName, p);
resource = PartResourceLibrary.Instance.GetDefinition (pr.resourceName);
if (resource.resourceFlowMode == ResourceFlowMode.STACK_PRIORITY_SEARCH) {
ASPConsoleStuff.printPart ("isFuelTank: Part IS a fuel tank, has flowable resource: " + pr.resourceName, p);
return true;
} else {
ASPConsoleStuff.printPart ("isFuelTank: resource is not flowable: " + resource.resourceFlowMode.ToString (), p);
}
}
return false;
}