public ProductionInProgress LineStart(Character character, ProductionLine productionLine, Container sourceContainer, int cycles, bool useCorporationWallet, out bool hasBonus) { var cprg = productionLine.GetOrCreateCalibrationProgram(this); var components = cprg.Components; //search for components var foundComponents = ProductionHelper.SearchForAvailableComponents(sourceContainer, components).ToList(); var materialMultiplier = CalculateFinalMaterialMultiplier(character, productionLine.GetMaterialPoints(), productionLine.TargetDefinition, out hasBonus); if (cprg.IsMissionRelated) { //clamp the material multiplier at 1.0 //so it can ask less that in the mission but never more var preMatMult = materialMultiplier; materialMultiplier = materialMultiplier.Clamp(); Logger.Info("pre material multiplier:" + preMatMult + " -> " + materialMultiplier); } //match components var itemsNeeded = ProductionHelper.ProcessComponentRequirement(ProductionInProgressType.massProduction, foundComponents, cycles, materialMultiplier, components); //put them to storage long[] reservedEids; ProductionHelper.ReserveComponents_noSQL(itemsNeeded, StorageEid, sourceContainer, out reservedEids).ThrowIfError(); //calculate time var productionTimeSeconds = cycles * CalculateFinalProductionTimeSeconds(character, cprg.TargetDefinition, productionLine.GetTimePoints()); productionTimeSeconds = GetShortenedProductionTime(productionTimeSeconds); if (cprg.IsMissionRelated) { productionTimeSeconds = 10; } var newProduction = ProductionInProgressFactory(); newProduction.startTime = DateTime.Now; newProduction.finishTime = DateTime.Now.AddSeconds(productionTimeSeconds); newProduction.type = ProductionInProgressType.massProduction; newProduction.character = character; newProduction.facilityEID = Eid; newProduction.resultDefinition = productionLine.TargetDefinition; newProduction.totalProductionTimeSeconds = productionTimeSeconds; newProduction.baseEID = Parent; newProduction.pricePerSecond = cprg.IsMissionRelated ? 0.0 : GetPricePerSecond(productionLine.TargetDefinition); newProduction.ReservedEids = reservedEids; newProduction.amountOfCycles = cycles; newProduction.useCorporationWallet = useCorporationWallet; if (!newProduction.TryWithdrawCredit()) { //not enough money return(null); } //save to sql newProduction.InsertProductionInProgess(); //set running production id to line ProductionLine.SetRunningProductionId(productionLine.Id, newProduction.ID).ThrowIfError(); productionLine.DecreaseRounds(); sourceContainer.Save(); Transaction.Current.OnCommited(() => { //add to ram ProductionProcessor.AddToRunningProductions(newProduction); }); //send info to client newProduction.SendProductionEventToCorporationMembersOnCommitted(Commands.ProductionRemoteStart); return(newProduction); }