private Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver) { Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (job != null) { return(job); } Job job2 = new Job(JobDefOf.DoBill, (Thing)giver); if (bill.recipe is MagicRecipeDef) { job2 = new Job(TorannMagicDefOf.JobDriver_DoMagicBill, (Thing)giver); } job2.targetQueueB = new List <LocalTargetInfo>(chosenIngThings.Count); job2.countQueue = new List <int>(chosenIngThings.Count); for (int i = 0; i < chosenIngThings.Count; i++) { job2.targetQueueB.Add(chosenIngThings[i].Thing); job2.countQueue.Add(chosenIngThings[i].Count); } job2.haulMode = HaulMode.ToCellNonStorage; job2.bill = bill; return(job2); }
private Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver) { // 材料の運搬先に物があった場合(邪魔なものがある場合)、それをどかす処理 var job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (job != null) { return(job); } // レシピ実行(本命) var job2 = CreateNewJob(bill.recipe.GetModExtension <DefExtension_WaterRecipe>()); if (job2 == null) { return(null); } job2.targetA = giver as Thing; job2.targetQueueB = new List <LocalTargetInfo>(this.chosenIngThings.Count); job2.countQueue = new List <int>(this.chosenIngThings.Count); for (int i = 0; i < this.chosenIngThings.Count; i++) { job2.targetQueueB.Add(this.chosenIngThings[i].thing); job2.countQueue.Add(this.chosenIngThings[i].count); } job2.targetC = GetBillGiverRootCell(giver as Thing, pawn); job2.haulMode = HaulMode.ToCellNonStorage; job2.bill = bill; return(job2); }
private static Job FinishUftJob(Pawn pawn, UnfinishedThing uft, Bill_ProductionWithUft bill) { if (uft.Creator != pawn) { Log.Error("Tried to get FinishUftJob for " + pawn + " finishing " + uft + " but its creator is " + uft.Creator); return(null); } Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, bill.billStack.billGiver, uft); if (job != null && job.targetA.Thing != uft) { return(job); } Job job2 = new Job(JobDefOf.DoBill, (Thing)bill.billStack.billGiver); job2.bill = bill; job2.targetQueueB = new List <LocalTargetInfo> { uft }; job2.countQueue = new List <int> { 1 }; job2.haulMode = HaulMode.ToCellNonStorage; return(job2); }
public static Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver, List <ThingCount> chosenIngThings, out Job haulOffJob, bool dontCreateJobIfHaulOffRequired = true) { Job job = null; haulOffJob = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (haulOffJob != null && dontCreateJobIfHaulOffRequired) { return(haulOffJob); } if (bill.recipe != PurpleIvyDefOf.PI_AlienStudyRecipe) { job = JobMaker.MakeJob(JobDefOf.DoBill, (Thing)giver); } else { job = JobMaker.MakeJob(PurpleIvyDefOf.PI_ConductResearchOnAliens, (Thing)giver); } job.targetQueueB = new List <LocalTargetInfo>(chosenIngThings.Count); job.countQueue = new List <int>(chosenIngThings.Count); for (int i = 0; i < chosenIngThings.Count; i++) { job.targetQueueB.Add(chosenIngThings[i].Thing); job.countQueue.Add(chosenIngThings[i].Count); } job.haulMode = HaulMode.ToCellNonStorage; job.bill = bill; return(job); }
private Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver, Thing chosen) { Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (job != null) { return(job); } Job job2 = new Job(jobDef, (Thing)giver, chosen); job2.count = 1; job2.haulMode = HaulMode.ToCellNonStorage; job2.bill = bill; return(job2); }
public static Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver, List <ThingCount> chosenIngThings, out Job haulOffJob, bool dontCreateJobIfHaulOffRequired = true) { Job job = null; haulOffJob = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (haulOffJob != null && dontCreateJobIfHaulOffRequired) { return(haulOffJob); } if (bill.recipe != PurpleIvyDefOf.PI_BiomaterialsStudyRecipe) { job = JobMaker.MakeJob(JobDefOf.DoBill, (Thing)giver); } else { job = JobMaker.MakeJob(PurpleIvyDefOf.PI_BiomaterialsStudy, (Thing)giver); } job.targetQueueB = new List <LocalTargetInfo>(chosenIngThings.Count); job.countQueue = new List <int>(chosenIngThings.Count); for (int i = 0; i < chosenIngThings.Count; i++) { job.targetQueueB.Add(chosenIngThings[i].Thing); job.countQueue.Add(chosenIngThings[i].Count); } job.haulMode = HaulMode.ToCellNonStorage; job.bill = bill; ThingDef def = job.targetQueueB.First().Thing.def; if (job.bill.recipe == PurpleIvyDefOf.PI_BiomaterialsStudyRecipe) { foreach (var data in PurpleIvyData.BioStudy[def]) { if (data.PrerequisitesCompleted && data.TechprintsApplied == 0 && pawn.Map.listerThings.ThingsOfDef (ThingDef.Named("Techprint_" + data.defName)).Count == 0) { job.targetB = ThingMaker.MakeThing(ThingDef.Named("Techprint_" + data.defName)); } } } return(job); }
protected virtual Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver) { Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (job != null) { return(job); } Job job2 = new Job(TechJobDefOf.TrainWeapon, (Thing)giver); if (chosenIngThings.Any()) //to acomodate PractiseWeapon, which uses no ingredient. { job2.targetQueueB = new List <LocalTargetInfo>(chosenIngThings.Count); job2.countQueue = new List <int>(chosenIngThings.Count); job2.targetQueueB.Add(chosenIngThings[0].Thing); job2.countQueue.Add(chosenIngThings[0].Count); } job2.haulMode = HaulMode.ToCellNonStorage; job2.bill = bill; return(job2); }
protected virtual Job TryStartNewDoBillJob(Pawn pawn, Bill bill, IBillGiver giver) { Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (job != null) { return(job); } Job job2 = new Job(TechJobDefOf.TrainWeapon, (Thing)giver); job2.targetQueueB = new List <LocalTargetInfo>(chosenIngThings.Count); job2.countQueue = new List <int>(chosenIngThings.Count); for (int i = 0; i < chosenIngThings.Count; i++) { job2.targetQueueB.Add(chosenIngThings[i].Thing); job2.countQueue.Add(chosenIngThings[i].Count); } job2.haulMode = HaulMode.ToCellNonStorage; job2.bill = bill; return(job2); }
public new static Job FinishUftJob(Pawn pawn, UnfinishedThing uft, Bill_ProductionWithUft bill) { if (pawn.TryGetComp <CompKnowledge>().expertise.Where(x => !x.Key.IsFinished && x.Value >= 1f && x.Key.LabelCap == uft.Stuff.stuffProps.stuffAdjective).Any() == false) { return(null); } Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, bill.billStack.billGiver, uft); if (job != null && job.targetA.Thing != uft) { return(job); } Job job2 = JobMaker.MakeJob(TechJobDefOf.DocumentTech, (Thing)bill.billStack.billGiver); job2.bill = bill; job2.targetQueueB = new List <LocalTargetInfo> { uft }; job2.countQueue = new List <int> { 1 }; job2.haulMode = HaulMode.ToCellNonStorage; return(job2); }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { MicroWorkGiverDef mdef = def as MicroWorkGiverDef; if (mdef == null) { return(null); } LocalTargetInfo target = t; if (!pawn.CanReserve(target, 1, -1, null, forced) || t.IsBurning() || t.IsForbidden(pawn)) { return(null); } List <Building> list = new List <Building>(); foreach (var user in mdef.recipeDef.AllRecipeUsers) { List <Building> buildings = t.Map.listerBuildings.AllBuildingsColonistOfDef(user).Where( x => !x.IsForbidden(pawn) && pawn.CanReserve(x, 1, -1, null, forced) && (x as IBillGiver) != null && (x as IBillGiver).CurrentlyUsableForBills() && pawn.CanReach(x, PathEndMode.InteractionCell, Danger.Deadly)).ToList(); list.AddRange(buildings); } if (list.NullOrEmpty()) { return(null); } // list.SortBy(x => x.TryGetComp <CompRefuelable>() == null || x.TryGetComp <CompRefuelable>().HasFuel ? 0f : 99999f + x.Position.DistanceTo(t.Position)); Thing building = null; foreach (var l in list) { CompRefuelable compRefuelable = l.TryGetComp <CompRefuelable>(); if (compRefuelable != null && !compRefuelable.HasFuel) { if (RefuelWorkGiverUtility.CanRefuel(pawn, l, forced)) { return(RefuelWorkGiverUtility.RefuelJob(pawn, l, forced, null, null)); } } else { building = l; break; } } Job job = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, building as IBillGiver, null); if (job != null) { return(job); } job = new Job(mdef.jobDef, building); job.targetQueueB = new List <LocalTargetInfo>(1); job.countQueue = new List <int>(1); job.targetQueueB.Add(t); job.countQueue.Add(1); job.haulMode = HaulMode.ToCellNonStorage; Bill bill = mdef.recipeDef.MakeNewBill(); Bill_Production bp = bill as Bill_Production; if (bp != null) { bp.repeatCount++; bp.SetStoreMode(BillStoreModeDefOf.DropOnFloor); } job.bill = bill; return(job); }
public override Job JobOnThing(Pawn pawn, Thing bench, bool forced = false) { var giver = bench as IBillGiver; if (giver == null || !ThingIsUsableBillGiver(bench) || !giver.CurrentlyUsableForBills() || !giver.BillStack.AnyShouldDoNow || bench.IsBurning() || bench.IsForbidden(pawn)) { return(null); } if (!pawn.CanReserve(bench)) { return(null); } if (!pawn.CanReserveAndReach(bench.InteractionCell, PathEndMode.OnCell, Danger.Some)) { return(null); } giver.BillStack.RemoveIncompletableBills(); // clears off workbench var jobHaul = WorkGiverUtility.HaulStuffOffBillGiverJob(pawn, giver, null); if (jobHaul != null) { return(jobHaul); } foreach (var bill in giver.BillStack) { if ((bill.recipe.requiredGiverWorkType != null && bill.recipe.requiredGiverWorkType != def.workType) || (Find.TickManager.TicksGame < bill.lastIngredientSearchFailTicks + ReCheckFailedBillTicksRange.RandomInRange && FloatMenuMakerMap.makingFor != pawn) || !bill.ShouldDoNow() || !bill.PawnAllowedToStartAnew(pawn)) { continue; } if (!bill.recipe.PawnSatisfiesSkillRequirements(pawn)) { JobFailReason.Is(_missingSkillTranslated); return(null); } var damagedItems = FindDamagedItems(pawn, bench, bill); if (damagedItems == null) { JobFailReason.Is(_benchNoItemsTranslated); return(null); } Debug.PrintList("JobOnThing.damagedItems", damagedItems); foreach (var item in damagedItems) { if (TryFindBestBillIngredients(bill, pawn, bench, chosenIngThings, item)) { return(StartNewRepairJob(bill, giver, item, chosenIngThings)); } } if (FloatMenuMakerMap.makingFor != pawn) { bill.lastIngredientSearchFailTicks = Find.TickManager.TicksGame; } } JobFailReason.Is(_benchNoMaterialsTranslated); return(null); }