public RaiseResourceMaxChanged ( PartResource resource, double amount ) : void | ||
resource | PartResource | |
amount | double | |
return | void |
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"); }
void UpdateTank(double value) { PartResource partResource = resource; ModuleFuelTanks.UnmanagedResource unmanagedResource = null; double unmanagedAmount = 0; double unmanagedMaxAmount = 0; if (module.unmanagedResources != null) { module.unmanagedResources.TryGetValue(partResource.resourceName, out unmanagedResource); } if (unmanagedResource != null) { unmanagedAmount = unmanagedResource.amount; unmanagedMaxAmount = unmanagedResource.maxAmount; } if (value > partResource.maxAmount) { // If expanding, modify it to be less than overfull double maxQty = (module.AvailableVolume * utilization) + partResource.maxAmount - unmanagedMaxAmount; if (maxQty < value) { value = maxQty; } } // Do nothing if unchanged if (value + unmanagedMaxAmount == 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 + unmanagedMaxAmount; module.RaiseResourceMaxChanged(partResource, value); //print ("Set new maxAmount"); if (newAmount + unmanagedAmount != partResource.amount) { partResource.amount = newAmount + unmanagedAmount; 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 + unmanagedMaxAmount; RaiseResourceMaxChanged(sym, symResc, value); if (newAmount != symResc.amount) { symResc.amount = newAmount + unmanagedAmount; RaiseResourceInitialChanged(sym, symResc, newAmount); } } } //print ("Symmetry set"); }