コード例 #1
0
        // Token: 0x0600041E RID: 1054 RVA: 0x0002CA54 File Offset: 0x0002AE54
        protected override Job TryGiveJob(Pawn pawn)
        {
            Region region = pawn.GetRegion(RegionType.Set_Passable);

            if (region == null)
            {
                return(null);
            }
            IntVec3 hiveCell;

            if (!XenomorphUtil.ClosestReachableParentHivelike(pawn).DestroyedOrNull())
            {
                hiveCell = XenomorphUtil.ClosestReachableParentHivelike(pawn).Position;
            }
            else if (!XenomorphUtil.ClosestReachableHiveSlime(pawn).DestroyedOrNull())
            {
                hiveCell = XenomorphUtil.ClosestReachableHiveSlime(pawn).Position;
            }
            else
            {
                hiveCell = pawn.mindState.duty.focus.Cell;
            }
            for (int i = 0; i < 40; i++)
            {
                IntVec3 randomCell = region.RandomCell;

                for (int j = 0; j < 8; j++)
                {
                    IntVec3 c = randomCell + GenAdj.AdjacentCellsAround[j];
                    if (c.InBounds(pawn.Map))
                    {
                        Thing thing = c.GetFirstHaulable(pawn.Map);
                        //    Log.Message(string.Format("thing: {0}", thing));
                        if (thing != null && (thing.def.passability == Traversability.Impassable || thing.def.IsDoor) && thing.def.size == IntVec2.One && thing.def != ThingDefOf.CollapsedRocks && pawn.CanReserve(thing, 1, -1, null, false) && XenomorphUtil.DistanceBetween(thing.Position, pawn.mindState.duty.focus.Cell) >= minClearingRange && XenomorphUtil.DistanceBetween(thing.Position, pawn.mindState.duty.focus.Cell) <= maxClearingRange)
                        {
                            return(XenomorphUtil.HaulAsideJobFor(pawn, thing, hiveCell, maxClearingRange));
                        }
                    }
                }
            }
            return(null);
        }