コード例 #1
0
 private Job StartOrResumeBillJob(Pawn pawn, IBillGiver giver)
 {
     for (int i = 0; i < giver.BillStack.Count; i++)
     {
         Bill bill = giver.BillStack[i];
         if ((bill.recipe.requiredGiverWorkType == null || bill.recipe.requiredGiverWorkType == base.def.workType) && (Find.TickManager.TicksGame >= bill.lastIngredientSearchFailTicks + WorkGiver_DoBill.ReCheckFailedBillTicksRange.RandomInRange || FloatMenuMakerMap.makingFor == pawn))
         {
             bill.lastIngredientSearchFailTicks = 0;
             if (bill.ShouldDoNow() && bill.PawnAllowedToStartAnew(pawn))
             {
                 if (bill.recipe.PawnSatisfiesSkillRequirements(pawn))
                 {
                     Bill_ProductionWithUft bill_ProductionWithUft = bill as Bill_ProductionWithUft;
                     if (bill_ProductionWithUft != null)
                     {
                         if (bill_ProductionWithUft.BoundUft != null)
                         {
                             if (bill_ProductionWithUft.BoundWorker == pawn && pawn.CanReserveAndReach(bill_ProductionWithUft.BoundUft, PathEndMode.Touch, Danger.Deadly, 1, -1, null, false) && !bill_ProductionWithUft.BoundUft.IsForbidden(pawn))
                             {
                                 return(WorkGiver_DoBill.FinishUftJob(pawn, bill_ProductionWithUft.BoundUft, bill_ProductionWithUft));
                             }
                             continue;
                         }
                         UnfinishedThing unfinishedThing = WorkGiver_DoBill.ClosestUnfinishedThingForBill(pawn, bill_ProductionWithUft);
                         if (unfinishedThing != null)
                         {
                             return(WorkGiver_DoBill.FinishUftJob(pawn, unfinishedThing, bill_ProductionWithUft));
                         }
                     }
                     if (!WorkGiver_DoBill.TryFindBestBillIngredients(bill, pawn, (Thing)giver, this.chosenIngThings))
                     {
                         if (FloatMenuMakerMap.makingFor != pawn)
                         {
                             bill.lastIngredientSearchFailTicks = Find.TickManager.TicksGame;
                         }
                         else
                         {
                             JobFailReason.Is(WorkGiver_DoBill.MissingMaterialsTranslated);
                         }
                         continue;
                     }
                     return(this.TryStartNewDoBillJob(pawn, bill, giver));
                 }
                 JobFailReason.Is(WorkGiver_DoBill.MissingSkillTranslated);
             }
         }
     }
     return(null);
 }
コード例 #2
0
 private Job StartOrResumeBillJob(Pawn pawn, IBillGiver giver)
 {
     for (int i = 0; i < giver.BillStack.Count; i++)
     {
         Bill bill = giver.BillStack[i];
         if (bill.recipe.requiredGiverWorkType == null || bill.recipe.requiredGiverWorkType == this.def.workType)
         {
             if (Find.TickManager.TicksGame >= bill.lastIngredientSearchFailTicks + WorkGiver_DoBill.ReCheckFailedBillTicksRange.RandomInRange || FloatMenuMakerMap.makingFor == pawn)
             {
                 bill.lastIngredientSearchFailTicks = 0;
                 if (bill.ShouldDoNow())
                 {
                     if (bill.PawnAllowedToStartAnew(pawn))
                     {
                         SkillRequirement skillRequirement = bill.recipe.FirstSkillRequirementPawnDoesntSatisfy(pawn);
                         if (skillRequirement != null)
                         {
                             JobFailReason.Is("UnderRequiredSkill".Translate(skillRequirement.minLevel), bill.Label);
                         }
                         else
                         {
                             Bill_ProductionWithUft bill_ProductionWithUft = bill as Bill_ProductionWithUft;
                             if (bill_ProductionWithUft != null)
                             {
                                 if (bill_ProductionWithUft.BoundUft != null)
                                 {
                                     if (bill_ProductionWithUft.BoundWorker != pawn || !pawn.CanReserveAndReach(bill_ProductionWithUft.BoundUft, PathEndMode.Touch, Danger.Deadly, 1, -1, null, false) || bill_ProductionWithUft.BoundUft.IsForbidden(pawn))
                                     {
                                         goto IL_1D0;
                                     }
                                     return(WorkGiver_DoBill.FinishUftJob(pawn, bill_ProductionWithUft.BoundUft, bill_ProductionWithUft));
                                 }
                                 else
                                 {
                                     UnfinishedThing unfinishedThing = WorkGiver_DoBill.ClosestUnfinishedThingForBill(pawn, bill_ProductionWithUft);
                                     if (unfinishedThing != null)
                                     {
                                         return(WorkGiver_DoBill.FinishUftJob(pawn, unfinishedThing, bill_ProductionWithUft));
                                     }
                                 }
                             }
                             if (WorkGiver_DoBill.TryFindBestBillIngredients(bill, pawn, (Thing)giver, this.chosenIngThings))
                             {
                                 Job result = this.TryStartNewDoBillJob(pawn, bill, giver);
                                 this.chosenIngThings.Clear();
                                 return(result);
                             }
                             if (FloatMenuMakerMap.makingFor != pawn)
                             {
                                 bill.lastIngredientSearchFailTicks = Find.TickManager.TicksGame;
                             }
                             else
                             {
                                 JobFailReason.Is(WorkGiver_DoBill.MissingMaterialsTranslated, bill.Label);
                             }
                             this.chosenIngThings.Clear();
                         }
                     }
                 }
             }
         }
         IL_1D0 :;
     }
     this.chosenIngThings.Clear();
     return(null);
 }