setContainerPercents() public method

public setContainerPercents ( float percents, float totalVolume ) : void
percents float
totalVolume float
return void
Ejemplo n.º 1
0
        /// <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 updateContainerVolume()
        {
            SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>();

            if (vc != null)
            {
                float   tankPercent = 100 - supportPercent;
                float   monoPercent = supportPercent;
                float[] pcts        = new float[2];
                pcts[0] = tankPercent * 0.01f;
                pcts[1] = monoPercent * 0.01f;
                vc.setContainerPercents(pcts, totalTankVolume * 1000f);
            }
            else
            {
                //real-fuels handling....
                SSTUModInterop.onPartFuelVolumeUpdate(part, totalTankVolume * 1000f);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the associated VolumeContainer with any changes to part volume from this module
        /// </summary>
        private void updateContainerVolume()
        {
            float liters = calcTotalVolume();
            SSTUVolumeContainer container = part.GetComponent <SSTUVolumeContainer>();

            if (container == null)
            {
                SSTUModInterop.onPartFuelVolumeUpdate(part, liters);
                return;
            }
            int len = container.numberOfContainers;

            float[] percents = new float[len];
            float   total    = liters;
            float   val;

            for (int i = 0; i < len; i++)
            {
                val         = calcVolume(i);
                percents[i] = val / total;
            }
            container.setContainerPercents(percents, total);
        }