Example #1
0
        // Token: 0x06000333 RID: 819 RVA: 0x0001FB8C File Offset: 0x0001DF8C
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            Toil prepare = Toils_General.Wait(180, TargetIndex.None);

            prepare.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A);
            prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            yield return(prepare);

            Toil maintain = new Toil();

            maintain.initAction = delegate()
            {
                Pawn actor = maintain.actor;
                CompMaintainableLike compMaintainable = actor.CurJob.targetA.Thing.TryGetComp <CompMaintainableLike>();
                compMaintainable.Maintained();
            };
            maintain.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(maintain);

            yield break;
        }
        // Token: 0x0600041B RID: 1051 RVA: 0x0002C940 File Offset: 0x0002AD40
        protected override Job TryGiveJob(Pawn pawn)
        {
            ThingDef hiveDef = null;
            List <ThingDef_HiveLike> hivedefs = DefDatabase <ThingDef_HiveLike> .AllDefsListForReading.FindAll(x => x.Faction == pawn.Faction.def);

            foreach (ThingDef_HiveLike hivedef in hivedefs)
            {
                if (pawn.jobs.debugLog)
                {
                    pawn.jobs.DebugLogEvent(string.Format("JobGiver_MaintainHiveLikes found hiveDef: {0} for {1}", hiveDef, pawn));
                }
                if (hivedef.Faction == pawn.Faction.def)
                {
                    hiveDef = hivedef;
                    if (pawn.jobs.debugLog)
                    {
                        pawn.jobs.DebugLogEvent(string.Format("JobGiver_MaintainHiveLikes set hiveDef: {0} for {1}", hiveDef, pawn));
                    }
                    break;
                }
            }
            Room room = pawn.GetRoom(RegionType.Set_Passable);
            int  num  = 0;

            while ((float)num < JobGiver_MaintainHiveLikes.CellsInScanRadius)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(pawn.Map))
                {
                    if (intVec.GetRoom(pawn.Map, RegionType.Set_Passable) == room)
                    {
                        HiveLike hivelike = (HiveLike)pawn.Map.thingGrid.ThingAt(intVec, hiveDef);
                        if (hivelike != null && pawn.CanReserve(hivelike, 1, -1, null, false))
                        {
                            CompMaintainableLike compMaintainable = hivelike.TryGetComp <CompMaintainableLike>();
                            if (compMaintainable != null && compMaintainable.CurStage != MaintainableStage.Healthy)
                            {
                                if (!this.onlyIfDamagingState || compMaintainable.CurStage == MaintainableStage.Damaging)
                                {
                                    return(new Job(XenomorphDefOf.RRY_Job_Xenomorph_MaintainHive, hivelike));
                                }
                            }
                        }
                    }
                }
                num++;
            }
            return(null);
        }