protected virtual double ProduceReactorProduct(ReactorProduct product, double produce_amount) { var effectiveAmount = produce_amount / FuelEfficiency; if (!product.ProduceGlobal) { if (part.Resources.Contains(product.FuelName)) { double availableStorage = part.Resources[product.FuelName].maxAmount - part.Resources[product.FuelName].amount; double possibleAmount = Math.Min(effectiveAmount, availableStorage); part.Resources[product.FuelName].amount += possibleAmount; return effectiveAmount * product.Density; } else return 0; } part.RequestResource(product.FuelName, -effectiveAmount); return effectiveAmount * product.Density; }
protected double GetFuelAvailability(ReactorProduct product) { if (product == null) UnityEngine.Debug.LogError("[KSPI] - GetFuelAvailability product null"); if (!product.ProduceGlobal) { if (part.Resources.Contains(product.FuelName)) return part.Resources[product.FuelName].amount; else return 0; } if (HighLogic.LoadedSceneIsFlight) return part.GetConnectedResources(product.FuelName).Sum(rs => rs.amount); else return part.FindAmountOfAvailableFuel(product.FuelName, 4); }