// Token: 0x0600001E RID: 30 RVA: 0x00003530 File Offset: 0x00001730 private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind) { Toil toil = new Toil(); toil.initAction = delegate() { Pawn actor = toil.actor; bool flag = actor.carryTracker.CarriedThing == null; if (flag) { string str = "JumpToAlsoCollectTargetInQueue run on "; Pawn pawn = actor; Log.Error(str + ((pawn != null) ? pawn.ToString() : null) + " who is not carrying something.", false); } else { bool full = actor.carryTracker.Full; if (!full) { Job curJob = actor.jobs.curJob; List <LocalTargetInfo> targetQueue = curJob.GetTargetQueue(ind); bool flag2 = targetQueue.NullOrEmpty <LocalTargetInfo>(); if (!flag2) { for (int i = 0; i < targetQueue.Count; i++) { bool flag3 = GenAI.CanUseItemForWork(actor, targetQueue[i].Thing); if (flag3) { bool flag4 = targetQueue[i].Thing.CanStackWith(actor.carryTracker.CarriedThing); if (flag4) { bool flag5 = (float)(actor.Position - targetQueue[i].Thing.Position).LengthHorizontalSquared <= 64f; if (flag5) { int num = (actor.carryTracker.CarriedThing != null) ? actor.carryTracker.CarriedThing.stackCount : 0; int num2 = curJob.countQueue[i]; num2 = Mathf.Min(num2, targetQueue[i].Thing.def.stackLimit - num); num2 = Mathf.Min(num2, actor.carryTracker.AvailableStackSpace(targetQueue[i].Thing.def)); bool flag6 = num2 > 0; if (flag6) { curJob.count = num2; curJob.SetTarget(ind, targetQueue[i].Thing); List <int> countQueue; int index; (countQueue = curJob.countQueue)[index = i] = countQueue[index] - num2; bool flag7 = curJob.countQueue[i] <= 0; if (flag7) { curJob.countQueue.RemoveAt(i); targetQueue.RemoveAt(i); } actor.jobs.curDriver.JumpToToil(gotoGetTargetToil); break; } } } } } } } } }; return(toil); }
private static Toil JumpToCollectNextIntoHandsForBill(Toil gotoGetTargetToil, TargetIndex ind) { const float MaxDist = 8; Toil toil = new Toil(); toil.initAction = () => { Pawn actor = toil.actor; if (actor.carryTracker.CarriedThing == null) { Log.Error("JumpToAlsoCollectTargetInQueue run on " + actor + " who is not carrying something."); return; } //Early-out if (actor.carryTracker.Full) { return; } Job curJob = actor.jobs.curJob; var targetQueue = curJob.GetTargetQueue(ind); if (targetQueue.NullOrEmpty()) { return; } //Find an item in the queue matching what you're carrying for (int i = 0; i < targetQueue.Count; i++) { //Can't use item - skip if (!GenAI.CanUseItemForWork(actor, targetQueue[i].Thing)) { continue; } //Cannot stack with thing in hands - skip if (!targetQueue[i].Thing.CanStackWith(actor.carryTracker.CarriedThing)) { continue; } //Too far away - skip if ((actor.Position - targetQueue[i].Thing.Position).LengthHorizontalSquared > MaxDist * MaxDist) { continue; } //Determine num in hands int numInHands = (actor.carryTracker.CarriedThing == null) ? 0 : actor.carryTracker.CarriedThing.stackCount; //Determine num to take int numToTake = curJob.countQueue[i]; numToTake = Mathf.Min(numToTake, targetQueue[i].Thing.def.stackLimit - numInHands); numToTake = Mathf.Min(numToTake, actor.carryTracker.AvailableStackSpace(targetQueue[i].Thing.def)); //Won't take any - skip if (numToTake <= 0) { continue; } //Set me to go get it curJob.count = numToTake; curJob.SetTarget(ind, targetQueue[i].Thing); //Remove the amount to take from the num to bring list //Remove from queue if I'm going to take all curJob.countQueue[i] -= numToTake; if (curJob.countQueue[i] <= 0) { curJob.countQueue.RemoveAt(i); targetQueue.RemoveAt(i); } //Jump to toil actor.jobs.curDriver.JumpToToil(gotoGetTargetToil); return; } }; return(toil); }