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); } }
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; } }
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; } } }