public static void ChangeJobPriority(Entity colonyEntity, ConstructionJob job, int delta) { var constructingDB = colonyEntity.GetDataBlob <ColonyConstructionDB>(); lock (constructingDB.JobBatchList) //prevent threaded race conditions { //first check that the job does still exsist in the list. if (constructingDB.JobBatchList.Contains(job)) { var currentIndex = constructingDB.JobBatchList.IndexOf(job); var newIndex = currentIndex + delta; if (newIndex <= 0) { constructingDB.JobBatchList.RemoveAt(currentIndex); constructingDB.JobBatchList.Insert(0, job); } else if (newIndex >= constructingDB.JobBatchList.Count - 1) { constructingDB.JobBatchList.RemoveAt(currentIndex); constructingDB.JobBatchList.Add(job); } else { constructingDB.JobBatchList.RemoveAt(currentIndex); constructingDB.JobBatchList.Insert(newIndex, job); } } } }
public static void AddJob(Entity colonyEntity, ConstructionJob job) { var constructingDB = colonyEntity.GetDataBlob <ColonyConstructionDB>(); var factionInfo = colonyEntity.GetDataBlob <OwnedDB>().ObjectOwner.GetDataBlob <FactionInfoDB>(); lock (constructingDB.JobBatchList) //prevent threaded race conditions { //check that this faction does have the design on file. I *think* all this type of construction design will get stored in factionInfo.ComponentDesigns if (factionInfo.ComponentDesigns.ContainsKey(job.ItemGuid)) { constructingDB.JobBatchList.Add(job); } } }
private static void BatchJobItemComplete(Entity colonyEntity, CargoStorageDB storage, ConstructionJob batchJob, ComponentInfoDB designInfo) { var colonyConstruction = colonyEntity.GetDataBlob <ColonyConstructionDB>(); batchJob.NumberCompleted++; batchJob.PointsLeft = designInfo.BuildPointCost; batchJob.MineralsRequired = designInfo.MinerialCosts; batchJob.MineralsRequired = designInfo.MaterialCosts; batchJob.MineralsRequired = designInfo.ComponentCosts; var factionInfo = colonyEntity.GetDataBlob <OwnedDB>().ObjectOwner.GetDataBlob <FactionInfoDB>(); Entity designEntity = factionInfo.ComponentDesigns[batchJob.ItemGuid]; Entity specificComponent = ComponentInstanceFactory.NewInstanceFromDesignEntity(designEntity, colonyEntity.GetDataBlob <OwnedDB>().ObjectOwner); if (batchJob.InstallOn != null) { if (batchJob.InstallOn == colonyEntity || StorageSpaceProcessor.HasEntity(storage, colonyEntity)) { EntityManipulation.AddComponentToEntity(batchJob.InstallOn, specificComponent); ReCalcProcessor.ReCalcAbilities(batchJob.InstallOn); } } else { StorageSpaceProcessor.AddItemToCargo(storage, specificComponent); } if (batchJob.NumberCompleted == batchJob.NumberOrdered) { colonyConstruction.JobBatchList.Remove(batchJob); if (batchJob.Auto) { colonyConstruction.JobBatchList.Add(batchJob); } } }
private static void BatchJobItemComplete(Entity colonyEntity, CargoStorageDB storage, ConstructionJob batchJob, ComponentDesign designInfo) { var colonyConstruction = colonyEntity.GetDataBlob <ConstructionDB>(); batchJob.NumberCompleted++; batchJob.ProductionPointsLeft = designInfo.BuildPointCost; batchJob.MineralsRequired = designInfo.MineralCosts; batchJob.MineralsRequired = designInfo.MaterialCosts; batchJob.MineralsRequired = designInfo.ComponentCosts; ComponentInstance specificComponent = new ComponentInstance(designInfo); if (batchJob.InstallOn != null) { if (batchJob.InstallOn == colonyEntity || StorageSpaceProcessor.HasEntity(storage, colonyEntity.GetDataBlob <CargoAbleTypeDB>())) { EntityManipulation.AddComponentToEntity(batchJob.InstallOn, specificComponent); ReCalcProcessor.ReCalcAbilities(batchJob.InstallOn); } } else { StorageSpaceProcessor.AddCargo(storage, specificComponent, 1); } if (batchJob.NumberCompleted == batchJob.NumberOrdered) { colonyConstruction.JobBatchList.Remove(batchJob); if (batchJob.Auto) { colonyConstruction.JobBatchList.Add(batchJob); } } }