protected override Job TryGiveJob(Pawn pawn) { List <Thing> foundIngredients; List <int> foundIngredientsCount; if (!AIRobot_Helper.GetAllNeededIngredients(pawn, DefDatabase <ThingDef> .GetNamed(ingredientDefName), this.ingredientCount, out foundIngredients, out foundIngredientsCount) || foundIngredients == null || foundIngredients.Count == 0) { return(null); } //Log.Error("foundIngredients="+foundIngredients.Count.ToString() + " " + "foundIngredientsCount="+foundIngredientsCount.Count.ToString()); List <LocalTargetInfo> ingredientsLTI = new List <LocalTargetInfo>(); foreach (Thing t in foundIngredients) { ingredientsLTI.Add(t); } X2_JobDriver_RepairStationRobot repairRobot = new X2_JobDriver_RepairStationRobot(); Job job = new Job(DefDatabase <JobDef> .GetNamed(this.jobDefName), this.rechargeStation, foundIngredients[0], disabledRobot); job.targetQueueB = ingredientsLTI; job.countQueue = foundIngredientsCount; return(job); }
public static Job GetStationRepairJob(Pawn pawn, X2_Building_AIRobotRechargeStation station, Dictionary <ThingDef, int> resources) { string jobDefName = "AIRobot_RepairStationRobot"; List <Thing> foundIngredients = new List <Thing>(); List <int> foundIngredientsCount = new List <int>(); List <Thing> workIngredients = new List <Thing>(); List <int> workIngredientCount = new List <int>(); foreach (ThingDef ingredientDef in resources.Keys) { if (!AIRobot_Helper.GetAllNeededIngredients(pawn, ingredientDef, resources[ingredientDef], out workIngredients, out workIngredientCount) || workIngredients == null || workIngredients.Count == 0) { return(null); } foundIngredients.AddRange(workIngredients); foundIngredientsCount.AddRange(workIngredientCount); } X2_JobDriver_RepairStationRobot repairRobot = new X2_JobDriver_RepairStationRobot(); Job job = new Job(DefDatabase <JobDef> .GetNamed(jobDefName), station, null, station.Position); job.count = 1; job.targetQueueB = new List <LocalTargetInfo>(); //new List<LocalTargetInfo>(foundIngredients.Count); job.countQueue = new List <int>(foundIngredients.Count); for (int i = 0; i < foundIngredients.Count; i++) { job.targetQueueB.Add(foundIngredients[i]); job.countQueue.Add(foundIngredientsCount[i]); } job.haulMode = HaulMode.ToCellNonStorage; return(job); }