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_RepairDamagedRobot repairRobot = new X2_JobDriver_RepairDamagedRobot(); Job job = new Job(DefDatabase <JobDef> .GetNamed(this.jobDefName), this.rechargeStation, foundIngredients[0], disabledRobot); job.targetQueueB = ingredientsLTI; job.countQueue = foundIngredientsCount; return(job); }
private void StartRepairJob2(Pawn pawn) { List <Thing> foundIngredients, foundIngredients2; List <int> foundIngredientsCount, foundIngredients2Count; if (!AIRobot_Helper.GetAllNeededIngredients(pawn, DefDatabase <ThingDef> .GetNamed(ingredientDefName), this.ingredientNeedCount, out foundIngredients, out foundIngredientsCount) || foundIngredients == null || foundIngredients.Count == 0) { return; } if (!AIRobot_Helper.GetAllNeededIngredients(pawn, DefDatabase <ThingDef> .GetNamed(ingredient2DefName), this.ingredient2NeedCount, out foundIngredients2, out foundIngredients2Count) || foundIngredients2 == null || foundIngredients2.Count == 0) { return; } //Log.Error("foundIngredients="+foundIngredients.Count.ToString() + " " + "foundIngredientsCount="+foundIngredientsCount.Count.ToString()); X2_JobDriver_RepairDamagedRobot repairRobot = new X2_JobDriver_RepairDamagedRobot(); Job job = new Job(DefDatabase <JobDef> .GetNamed(this.jobDefName_repair), this.rechargestation, this, rechargestation.Position); job.count = 1; job.targetQueueB = new List <LocalTargetInfo>(foundIngredients.Count + foundIngredients2.Count); job.countQueue = new List <int>(foundIngredients.Count + foundIngredients2.Count); job.targetQueueB.Add(this); job.countQueue.Add(1); for (int i = 0; i < foundIngredients.Count; i++) { job.targetQueueB.Add(foundIngredients[i]); job.countQueue.Add(foundIngredientsCount[i]); } for (int i = 0; i < foundIngredients2.Count; i++) { job.targetQueueB.Add(foundIngredients2[i]); job.countQueue.Add(foundIngredients2Count[i]); } job.haulMode = HaulMode.ToCellNonStorage; pawn.jobs.StopAll(); pawn.jobs.StartJob(job); //Log.Error("Pawn.CurJob:" + pawn.CurJob.def.defName); //Log.Error("Job: "+ job.def.defName + " Ingredients: "+ foundIngredientsCount[0].ToString()); }
private void StartRepairJob(Pawn pawn) { List <Thing> foundIngredients; List <int> foundIngredientsCount; List <Thing> foundIngredients2; List <int> foundIngredients2Count; if (!AIRobot_Helper.GetAllNeededIngredients(pawn, DefDatabase <ThingDef> .GetNamed(ingredientDefName), this.ingredientNeedCount, out foundIngredients, out foundIngredientsCount) || foundIngredients == null || foundIngredients.Count == 0) { return; } if (!AIRobot_Helper.GetAllNeededIngredients(pawn, DefDatabase <ThingDef> .GetNamed(ingredient2DefName), this.ingredient2NeedCount, out foundIngredients2, out foundIngredients2Count) || foundIngredients == null || foundIngredients.Count == 0) { return; } //Log.Error("foundIngredients="+foundIngredients.Count.ToString() + " " + "foundIngredientsCount="+foundIngredientsCount.Count.ToString()); List <LocalTargetInfo> ingredientsLTI = new List <LocalTargetInfo>(); foreach (Thing t in foundIngredients) { ingredientsLTI.Add(t); } foreach (Thing t in foundIngredients2) { ingredientsLTI.Add(t); } X2_JobDriver_RepairDamagedRobot repairRobot = new X2_JobDriver_RepairDamagedRobot(); Job job = new Job(DefDatabase <JobDef> .GetNamed(this.jobDefName_repair), this.rechargestation, foundIngredients[0], this); job.targetQueueB = ingredientsLTI; job.countQueue = foundIngredientsCount; pawn.jobs.StopAll(); pawn.jobs.StartJob(job); Log.Error("Pawn.CurJob:" + pawn.CurJob.def.defName); //Log.Error("Job: "+ job.def.defName + " Ingredients: "+ foundIngredientsCount[0].ToString()); }