コード例 #1
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            if (HiveUtility.JobGivenRecentTick(pawn, "BI_Maintain"))
            {
                return(null);
            }
            Queen queen = HiveUtility.FindQueen(pawn);

            if (queen != null && JobGiver_InsectGather.WithinHive(pawn, pawn, true))
            {
                List <Egg> eggs = queen.spawnedEggs;
                if (eggs != null && eggs.Any())
                {
                    foreach (Egg egg in eggs)
                    {
                        if (egg != null && pawn.CanReserve(egg))
                        {
                            CompMaintainable compMaintainable = egg.TryGetComp <CompMaintainable>();
                            if (compMaintainable != null && compMaintainable.CurStage != MaintainableStage.Healthy)
                            {
                                return(new Job(DefDatabase <JobDef> .GetNamed("BI_Maintain"), egg));
                            }
                        }
                    }
                }
            }
            return(null);
        }
コード例 #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOnDespawnedOrNull(TargetIndex.A);
            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch));

            Toil prepare = Toils_General.Wait(MaintainTicks, 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;
                CompMaintainable compMaintainable = actor.CurJob.targetA.Thing.TryGetComp <CompMaintainable>();
                compMaintainable.Maintained();
            };
            maintain.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(maintain);
        }