protected override Job TryGiveJob(Pawn pawn)
        {
            Room room = pawn.GetRoom(RegionType.Set_Passable);
            int  num  = 0;

            while ((float)num < JobGiver_MaintainHives.CellsInScanRadius)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[num];
                if (intVec.InBounds(pawn.Map))
                {
                    if (intVec.GetRoom(pawn.Map, RegionType.Set_Passable) == room)
                    {
                        Hive hive = (Hive)pawn.Map.thingGrid.ThingAt(intVec, ThingDefOf.Hive);
                        if (hive != null && pawn.CanReserve(hive, 1, -1, null, false))
                        {
                            CompMaintainable compMaintainable = hive.TryGetComp <CompMaintainable>();
                            if (compMaintainable.CurStage != MaintainableStage.Healthy)
                            {
                                return(new Job(JobDefOf.Maintain, hive));
                            }
                        }
                    }
                }
                num++;
            }
            return(null);
        }
Esempio n. 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(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;
                CompMaintainable compMaintainable = actor.CurJob.targetA.Thing.TryGetComp <CompMaintainable>();
                compMaintainable.Maintained();
            };
            maintain.defaultCompleteMode = ToilCompleteMode.Instant;
            yield return(maintain);

            yield break;
        }
Esempio n. 3
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                switch (num)
                {
                case 0u:
                    this.FailOnDespawnedOrNull(TargetIndex.A);
                    this.$current = Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch);
                    if (!this.$disposing)
                    {
                        this.$PC = 1;
                    }
                    return(true);

                case 1u:
                    prepare = Toils_General.Wait(180, TargetIndex.None);
                    prepare.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
                    prepare.FailOnDespawnedNullOrForbidden(TargetIndex.A);
                    prepare.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
                    this.$current = prepare;
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);

                case 2u:
                {
                    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;
                    this.$current = maintain;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }

                case 3u:
                    this.$PC = -1;
                    break;
                }
                return(false);
            }
Esempio n. 4
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Room room = pawn.GetRoom();

            for (int i = 0; (float)i < CellsInScanRadius; i++)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[i];
                if (intVec.InBounds(pawn.Map) && intVec.GetRoom(pawn.Map) == room)
                {
                    Hive hive = (Hive)pawn.Map.thingGrid.ThingAt(intVec, ThingDefOf.Hive);
                    if (hive != null && pawn.CanReserve(hive))
                    {
                        CompMaintainable compMaintainable = hive.TryGetComp <CompMaintainable>();
                        if (compMaintainable.CurStage != 0 && (!onlyIfDamagingState || compMaintainable.CurStage == MaintainableStage.Damaging))
                        {
                            return(new Job(JobDefOf.Maintain, hive));
                        }
                    }
                }
            }
            return(null);
        }