예제 #1
0
 public void AddResources(bool fillTanks)
 {
     foreach (TankResource resource in tankType.resources)
     {
         float amount = TotalVolume * resource.unitsPerVolume * parent.VolumeScale;
         Part.AddOrCreateResource(resource.resourceDefinition, amount, fillTanks ? amount : -1f);
     }
 }
예제 #2
0
        private void UpsertResource(bool fillTanks, bool zeroAmount)
        {
            float maxAmount = getVolumeDelegate() * tankResource.unitsPerVolume;
            float amount;

            if (zeroAmount && fillTanks)
            {
                amount = 0f;
            }
            else
            {
                amount = maxAmount * filledProportion;
            }
            PartResource partResource = part.AddOrCreateResource(tankResource.resourceDefinition, maxAmount, amount, fillTanks);

            if (tweakable.HasValue)
            {
                partResource.isTweakable = tweakable.Value;
            }
        }
예제 #3
0
        private void AddResources(bool fillTanks)
        {
            foreach (TankResource resource in tankType.resources)
            {
                float amount = TotalVolume * resource.unitsPerVolume * parent.VolumeScale;
                float filledProportion;
                if (HighLogic.LoadedSceneIsFlight && fillTanks)
                {
                    filledProportion = 0;
                }
                else
                {
                    filledProportion = (resource.percentFilled ?? percentFilled ?? tankType.percentFilled ?? 100f) * 0.01f;
                }
                PartResource partResource = Part.AddOrCreateResource(resource.resourceDefinition, amount, amount * filledProportion, fillTanks);

                bool?tweakable = resourcesTweakable ?? tankType.resourcesTweakable;

                if (tweakable.HasValue)
                {
                    partResource.isTweakable = tweakable.Value;
                }
            }
        }