addResource() public méthode

Add a resource, by units, setting/adjusting fill and max units by the units specified
public addResource ( String name, float fillMaxUnits ) : void
name String
fillMaxUnits float
Résultat void
Exemple #1
0
 public SSTUResourceList addResources(float volume, SSTUResourceList list)
 {
     int rawFuelUnits = (int)(volume * unitsPerCubicMeter);
     int units;
     foreach (SSTUFuelEntry entry in fuelEntries)
     {
         units = entry.ratio * rawFuelUnits;
         list.addResource(entry.resourceName, units);
     }
     return list;
 }
Exemple #2
0
        public void getResources(SSTUResourceList list)
        {
            int   len = subContainerData.Length;
            float unitsMax;
            float unitsFill;

            for (int i = 0; i < len; i++)
            {
                if (subContainerData[i].unitRatio > 0)
                {
                    unitsMax  = subContainerData[i].resourceUnits;
                    unitsFill = unitsMax * subContainerData[i].fillPercentage;
                    list.addResource(subContainerData[i].name, unitsFill, unitsMax);
                }
            }
        }
 /// <summary>
 /// Updates the min/max quantities of resource in the part based on the current 'totalFuelVolume' field and currently set fuel type
 /// </summary>
 private void updatePartResources()
 {
     if (useRF)
     {
         return;
     }
     float reserveFuelVolume = totalFuelVolume * fuelReserveRatio;
     float fuelUsableVolume = totalFuelVolume - reserveFuelVolume;
     float currentDiameterScale = currentTankDiameter / defaultTankDiameter;
     float currentHeightScale = currentTankHeight / defaultTankHeight;
     float energyReserve = defaultElectricCharge * currentDiameterScale * currentHeightScale;
     SSTUResourceList resourceList = new SSTUResourceList();
     currentFuelTypeData.addResources(fuelUsableVolume, resourceList);
     reserveFuelTypeData.addResources(reserveFuelVolume, resourceList);
     resourceList.addResource("ElectricCharge", energyReserve);
     resourceList.setResourcesToPart(part, true);
 }