/// <summary> /// Deduct used amount from resource tanks /// </summary> internal void ProcessResources() { // Leave resource processing to Kerbalism if it is there if (DetectKerbalism.Found()) { return; } IResourceBroker broker = new ResourceBroker(); if (fuelCells.Use) { var iList = fuelCells.InputResources; for (int i = 0; i < iList.Count; i++) { iList[i].MaximumAmountAvailable -= broker.RequestResource(vessel.rootPart, iList[i].Name, iList[i].CurrentAmountUsed, 1, ResourceFlowMode.ALL_VESSEL); iList[i].CurrentAmountUsed = 0; } } for (int i = 0; i < propellants.Count; i++) { propellants[i].MaximumAmountAvailable -= broker.RequestResource(vessel.rootPart, propellants[i].Name, propellants[i].CurrentAmountUsed, 1, ResourceFlowMode.ALL_VESSEL); propellants[i].CurrentAmountUsed = 0; } }
private double ExecuteManufacturing(double deltaTime) { var resourceToProduce = _processedBlueprint.First(r => r.Processed < r.Units); var unitsToProduce = Math.Min(resourceToProduce.Units - resourceToProduce.Processed, deltaTime * adjustedProductivity); if (part.protoModuleCrew.Count < MinimumCrew) { Status = "Not enough Crew to operate"; } else if (_broker.AmountAvailable(part, UpkeepResource, TimeWarp.deltaTime, ResourceFlowMode.ALL_VESSEL) < TimeWarp.deltaTime) { Status = "Not enough " + UpkeepResource; } else { Status = "Recycling " + _processedItem.Part.title; _broker.RequestResource(part, UpkeepResource, UpkeepAmount, TimeWarp.deltaTime, ResourceFlowMode.ALL_VESSEL); _broker.StoreResource(part, resourceToProduce.Name, unitsToProduce, TimeWarp.deltaTime, ResourceFlowMode.ALL_VESSEL); resourceToProduce.Processed += unitsToProduce; progress = (float)(_processedBlueprint.GetProgress() * 100); } //Return time remaining return(deltaTime - unitsToProduce); }
/// <summary> /// Deduct used amount from resource tanks /// </summary> internal void ProcessResources() { IResourceBroker broker = new ResourceBroker(); if (fuelCells.Use) { var iList = fuelCells.InputResources; for (int i = 0; i < iList.Count; i++) { iList[i].MaximumAmountAvailable -= broker.RequestResource(vessel.rootPart, iList[i].Name, iList[i].CurrentAmountUsed, 1, ResourceFlowMode.ALL_VESSEL); iList[i].CurrentAmountUsed = 0; } } for (int i = 0; i < propellants.Count; i++) { propellants[i].MaximumAmountAvailable -= broker.RequestResource(vessel.rootPart, propellants[i].Name, propellants[i].CurrentAmountUsed, 1, ResourceFlowMode.ALL_VESSEL); propellants[i].CurrentAmountUsed = 0; } }
public double SubtractResource(string resourceName, double amount) { var available = _broker.AmountAvailable( _vessel.rootPart, resourceName, TimeWarp.fixedDeltaTime, ResourceFlowMode.ALL_VESSEL); var amountToRequest = Math.Min(available, amount); _broker.RequestResource( _vessel.rootPart, resourceName, amountToRequest, TimeWarp.fixedDeltaTime, ResourceFlowMode.ALL_VESSEL); return(amountToRequest); }
private void ConsumeFuel() { var res = Fuels[CurrentFuelIndex]; broker.RequestResource(part, res.name, FuelRate, 1, res.resourceFlowMode); }
private void ConsumeFuel() { var res = Fuels[CurrentFuelIndex]; broker.RequestResource(part, res.name, 1, 1, ""); }