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 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);
        }