public static bool onPartFuelVolumeUpdate(Part part, float liters)
{
SSTUVolumeContainer vc = part.GetComponent<SSTUVolumeContainer>();
if (vc != null)
{
vc.onVolumeUpdated(liters);
return true;
}
Type moduleFuelTank = null;
if (isRFInstalled())
{
moduleFuelTank = Type.GetType("RealFuels.Tanks.ModuleFuelTanks,RealFuels");
if (moduleFuelTank == null)
{
MonoBehaviour.print("ERROR: Set to use RealFuels, and RealFuels is installed, but no RealFuels-ModuleFuelTank PartModule found.");
return false;
}
}
else if (isMFTInstalled())
{
moduleFuelTank = Type.GetType("RealFuels.Tanks.ModuleFuelTanks,modularFuelTanks");
if (moduleFuelTank == null)
{
MonoBehaviour.print("ERROR: Set to use ModularFuelTanks, and ModularFuelTanks is installed, but no ModularFuelTanks-ModuleFuelTank PartModule found.");
return false;
}
}
else
{
MonoBehaviour.print("ERROR: Config is for part: "+part+" is set to use RF/MFT, but neither RF nor MFT is installed, cannot update part volumes through them. Please check your configs and/or patches for errors.");
return false;
}
PartModule pm = (PartModule)part.GetComponent(moduleFuelTank);
if (pm == null)
{
MonoBehaviour.print("ERROR! Could not find ModuleFuelTank in part for RealFuels/MFT for type: "+moduleFuelTank);
return false;
}
MethodInfo mi = moduleFuelTank.GetMethod("ChangeTotalVolume");
double volumeLiters = liters;
mi.Invoke(pm, new System.Object[] { volumeLiters, false });
MethodInfo mi2 = moduleFuelTank.GetMethod("CalculateMass");
mi2.Invoke(pm, new System.Object[] { });
updatePartResourceDisplay(part);
String message = "SSTUModInterop - Set RF/MFT total tank volume to: " + volumeLiters + " Liters for part: " + part.name;
MonoBehaviour.print(message);
return true;
}