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); }
private double ExecuteRecycling(double deltaTime) { var resourceToProduce = _processedBlueprint.First(r => r.Processed < r.Units); var unitsToProduce = Math.Min(resourceToProduce.Units - resourceToProduce.Processed, deltaTime * adjustedProductivity); Log.Info("resourceToProduce: " + resourceToProduce.Name + ", unitsToProduce: " + unitsToProduce); notEnoughCrew = part.protoModuleCrew.Count < MinimumCrew; notEnoughEC = OseModuleWorkshop.AmountAvailable(this.part, UpkeepResource) < TimeWarp.deltaTime * UpkeepAmount; Error = ""; if (notEnoughCrew) { RecyclerStatus = "Not enough Crew to operate"; Error = RecyclerStatus; } else if (notEnoughEC) { RecyclerStatus = "Not enough " + UpkeepResource; Error = RecyclerStatus; } else { RecyclerStatus = "Recycling " + _processedItem.Part.title; OseModuleWorkshop.RequestResource(this.part, UpkeepResource, TimeWarp.deltaTime * UpkeepAmount); //_broker.RequestResource(part, UpkeepResource, UpkeepAmount, TimeWarp.deltaTime, ResourceFlowMode.ALL_VESSEL); resourceToProduce.Processed += unitsToProduce; progress = (float)(_processedBlueprint.GetProgress() * 100); Log.Info("progress: " + progress); } if (Error != "" && Error != LastError && HighLogic.CurrentGame.Parameters.CustomParams <Workshop_MiscSettings>().showPopup) { PopupDialog.SpawnPopupDialog( new MultiOptionDialog( "OseModuleRecyclerWarning", "Warning\n" + Error + "\n", this.part.partInfo.title, HighLogic.UISkin, CreateOptions() ), false, HighLogic.UISkin ); } LastError = Error; //Return time remaining //return deltaTime - unitsToProduce; double d = deltaTime - deltaTime * (unitsToProduce / (deltaTime * adjustedProductivity)); Log.Info("ExecuteRecycling, returning : " + d); return(d); }
private double ExecuteManufacturing(double deltaTime) { Log.Info("ExecuteManufacturing, deltaTime: " + deltaTime); //Find the first resource that still needs to be processed. var resourceToConsume = _processedBlueprint.First(r => r.Processed < r.Units); //Determine the number of units of the resource to consume. var unitsToConsume = Math.Min(resourceToConsume.Units - resourceToConsume.Processed, deltaTime * adjustedProductivity / _processedBlueprint.Complexity); Log.Info("resourceToConsume: " + resourceToConsume.Name + ", unitsToConsume: " + unitsToConsume); if (part.protoModuleCrew.Count < MinimumCrew) { Status = "Not enough Crew to operate"; } else if (AmountAvailable(UpkeepResource) < TimeWarp.deltaTime * UpkeepAmount) { Status = "Not enough " + UpkeepResource; } else if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && WorkshopOptions.PrintingCostsFunds && Funding.Instance.Funds < _processedBlueprint.Funds) { Status = "Not enough funds to process"; } else if (AmountAvailable(resourceToConsume.Name) < unitsToConsume) { Status = "Not enough " + resourceToConsume.Name; } else { Status = "Printing " + _processedItem.Part.title; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && WorkshopOptions.PrintingCostsFunds && _processedBlueprint.Funds > 0) { Funding.Instance.AddFunds(-_processedBlueprint.Funds, TransactionReasons.Vessels); _processedBlueprint.Funds = 0; } else { _processedBlueprint.Funds = 0; } RequestResource(UpkeepResource, TimeWarp.deltaTime * UpkeepAmount); resourceToConsume.Processed += RequestResource(resourceToConsume.Name, unitsToConsume); progress = (float)(_processedBlueprint.GetProgress() * 100); Log.Info("progress: " + progress); } //Return time remaining //return deltaTime - unitsToConsume; double d = deltaTime - deltaTime * (unitsToConsume / (deltaTime * adjustedProductivity / _processedBlueprint.Complexity)); Log.Info("ExecuteManufacturing, returning : " + d); return(d); }
private void ExecuteManufacturing() { var resourceToConsume = _processedBlueprint.First(r => r.Processed < r.Units); var unitsToConsume = Math.Min(resourceToConsume.Units - resourceToConsume.Processed, TimeWarp.deltaTime * adjustedProductivity); if (part.protoModuleCrew.Count < MinimumCrew) { Status = "Not enough Crew to operate"; } else if (AmountAvailable(UpkeepResource) < TimeWarp.deltaTime) { Status = "Not enough " + UpkeepResource; } else if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && Funding.Instance.Funds < _processedBlueprint.Funds) { Status = "Not enough funds to process"; } else if (AmountAvailable(resourceToConsume.Name) < unitsToConsume) { Status = "Not enough " + resourceToConsume.Name; } else { Status = "Printing " + _processedItem.Part.title; if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER && _processedBlueprint.Funds > 0) { Funding.Instance.AddFunds(-_processedBlueprint.Funds, TransactionReasons.Vessels); _processedBlueprint.Funds = 0; } RequestResource(UpkeepResource, TimeWarp.deltaTime); resourceToConsume.Processed += RequestResource(resourceToConsume.Name, unitsToConsume); progress = (float)(_processedBlueprint.GetProgress() * 100); } }