void UpdateTank(double value)
{
PartResource partResource = resource;
if (value > partResource.maxAmount)
{
// If expanding, modify it to be less than overfull
double maxQty = module.AvailableVolume * utilization + partResource.maxAmount;
if (maxQty < value)
{
value = maxQty;
}
}
// Do nothing if unchanged
if (value == partResource.maxAmount)
{
return;
}
//Debug.LogWarning ("[MFT] Updating tank from API " + name + " amount: " + value);
maxAmountExpression = null;
// Keep the same fill fraction
double newAmount = value * fillFraction;
partResource.maxAmount = value;
module.RaiseResourceMaxChanged(partResource, value);
//print ("Set new maxAmount");
if (newAmount != partResource.amount)
{
partResource.amount = newAmount;
module.RaiseResourceInitialChanged(partResource, newAmount);
}
// Update symmetry counterparts.
if (HighLogic.LoadedSceneIsEditor && propagate)
{
foreach (Part sym in part.symmetryCounterparts)
{
PartResource symResc = sym.Resources[name];
symResc.maxAmount = value;
PartMessageService.Send <PartResourceMaxAmountChanged> (this, sym, symResc, value);
if (newAmount != symResc.amount)
{
symResc.amount = newAmount;
PartMessageService.Send <PartResourceInitialAmountChanged> (this, sym, symResc, newAmount);
}
}
}
//print ("Symmetry set");
}