Exemple #1
0
        private Job TryStartNewDoBillJob(Pawn pawn, ActivityTask task, Building_ReligiousBuildingFacility giver)
        {
            Job job1 = HaulStuffOffBillGiverJob(pawn, giver, (Thing)null);

            if (job1 != null)
            {
                return(job1);
            }
            ActivityJob job2 = new ActivityJob()
            {
                def     = MiscDefOf.DoReligionActivity,
                targetA = (LocalTargetInfo)((Thing)giver)
            };

            job2.targetQueueB = new List <LocalTargetInfo>(this.chosenIngThings.Count);
            job2.countQueue   = new List <int>(this.chosenIngThings.Count);
            for (int index = 0; index < this.chosenIngThings.Count; ++index)
            {
                job2.targetQueueB.Add((LocalTargetInfo)this.chosenIngThings[index].Thing);
                job2.countQueue.Add(this.chosenIngThings[index].Count);
            }
            job2.haulMode     = HaulMode.ToCellNonStorage;
            job2.activityTask = task;
            return(job2);
        }
Exemple #2
0
 public ActivityTaskSchedule(Building_ReligiousBuildingFacility facility)
 {
     this.facility = facility;
     if (Scribe.mode == LoadSaveMode.Inactive)
     {
         CreateSchedule();
     }
 }
Exemple #3
0
        public override Job JobOnThing(Pawn pawn, Thing thing, bool forced = false)
        {
            Building_ReligiousBuildingFacility giver = thing as Building_ReligiousBuildingFacility;

            if ((giver.TaskSchedule.TodayTasks.Count() == 0 || (!pawn.CanReserve((LocalTargetInfo)thing, 1, -1, (ReservationLayerDef)null, forced) || thing.IsBurning() || thing.IsForbidden(pawn))))
            {
                return((Job)null);
            }
            return(this.StartOrResumeBillJob(pawn, giver));
        }
Exemple #4
0
 private static Job HaulStuffOffBillGiverJob(Pawn pawn, Building_ReligiousBuildingFacility giver, Thing thingToIgnore)
 {
     foreach (IntVec3 ingredientStackCell in giver.IngredientStackCells)
     {
         Thing t = pawn.Map.thingGrid.ThingAt(ingredientStackCell, ThingCategory.Item);
         if (t != null && t != thingToIgnore)
         {
             return(HaulAIUtility.HaulAsideJobFor(pawn, t));
         }
     }
     return((Job)null);
 }
 public static IEnumerable <Building_ReligiousBuildingFacility> GlobalActivityGivers()
 {
     foreach (Map map in Find.Maps)
     {
         foreach (Thing thing in map.listerThings.AllThings.OfType <Building_ReligiousBuildingFacility>())
         {
             Building_ReligiousBuildingFacility giver = thing as Building_ReligiousBuildingFacility;
             if (giver == null)
             {
                 Log.ErrorOnce("Found non-bill-giver tagged as PotentialActivityGiver", 13389774, false);
             }
             else
             {
                 yield return(giver);
             }
         }
         foreach (Thing thing2 in map.listerThings.ThingsMatching(ThingRequest.ForGroup(ThingRequestGroup.MinifiedThing)))
         {
             Building_ReligiousBuildingFacility giver2 = thing2.GetInnerIfMinified() as Building_ReligiousBuildingFacility;
             if (giver2 != null)
             {
                 yield return(giver2);
             }
         }
     }
     foreach (Caravan caravan in Find.WorldObjects.Caravans)
     {
         foreach (Thing thing3 in caravan.AllThings)
         {
             Building_ReligiousBuildingFacility giver3 = thing3.GetInnerIfMinified() as Building_ReligiousBuildingFacility;
             if (giver3 != null)
             {
                 yield return(giver3);
             }
         }
     }
 }
Exemple #6
0
        private Job StartOrResumeBillJob(Pawn pawn, Building_ReligiousBuildingFacility giver)
        {
            ActivityTaskSchedule schedule = giver.TaskSchedule;

            foreach (ActivityTask task in schedule.TodayTasks)
            {
                if ((Find.TickManager.TicksGame >= task.LastIngredientSearchFailTicks + ReCheckFailedBillTicksRange.RandomInRange || FloatMenuMakerMap.makingFor == pawn))
                {
                    task.LastIngredientSearchFailTicks = 0;
                    if (task.ShouldDoNow() && task.PawnAllowedToStartAnew(pawn))
                    {
                        if (!TryFindRestrictedIngridients(task, pawn, giver, chosenIngThings) && !TryFindBestTaskIngredients(task, pawn, giver, chosenIngThings))
                        {
                            if (FloatMenuMakerMap.makingFor != pawn)
                            {
                                task.LastIngredientSearchFailTicks = Find.TickManager.TicksGame;
                            }
                            else
                            {
                                JobFailReason.Is("MissingMaterials".Translate(), task.Label);
                            }
                            this.chosenIngThings.Clear();
                        }
                        else
                        {
                            Job job = this.TryStartNewDoBillJob(pawn, task, giver);
                            this.chosenIngThings.Clear();
                            return(job);
                        }
                    }
                }
            }

            this.chosenIngThings.Clear();
            return((Job)null);
        }