void EnsureFreshAddLabelCache() { if (tank_module.AvailableVolume != oldAvailableVolume || tank_module.type != oldTankType) { foreach (FuelTank tank in tank_module.tankList) { double maxVol = tank_module.AvailableVolume * tank.utilization; string maxVolStr = KSPUtil.PrintSI(maxVol, "L"); string label = "Max: " + maxVolStr + " (+" + ModuleFuelTanks.FormatMass((float)(tank_module.AvailableVolume * tank.mass)) + " )"; addLabelCache[tank.name] = label; } oldAvailableVolume = tank_module.AvailableVolume; oldTankType = tank_module.type; } }
void AddTank(FuelTank tank) { double maxVol = tank_module.AvailableVolume * tank.utilization; string maxVolStr = KSPUtil.PrintSI(maxVol, "L"); string extraData = "Max: " + maxVolStr + " (+" + ModuleFuelTanks.FormatMass((float)(tank_module.AvailableVolume * tank.mass)) + " )"; GUILayout.Label(extraData, GUILayout.Width(150)); if (GUILayout.Button("Add", GUILayout.Width(120))) { tank.maxAmount = tank_module.AvailableVolume * tank.utilization; tank.amount = tank.fillable ? tank.maxAmount : 0; tank.maxAmountExpression = tank.maxAmount.ToString(); //Debug.LogWarning ("[MFT] Adding tank " + tank.name + " maxAmount: " + tank.maxAmountExpression ?? "null"); } }