public static IntVec3 SpotToChewStandingNear(Pawn pawn, Thing ingestible)
        {
            IntVec3             root         = pawn.Position;
            Room                rootRoom     = pawn.GetRoom(RegionType.Set_Passable);
            bool                desperate    = false;
            bool                ignoreDanger = false;
            float               maxDist      = 4f;
            Predicate <IntVec3> validator    = delegate(IntVec3 c)
            {
                if ((float)(root - c).LengthHorizontalSquared > maxDist * maxDist)
                {
                    return(false);
                }
                if (pawn.HostFaction != null && c.GetRoom(pawn.Map, RegionType.Set_Passable) != rootRoom)
                {
                    return(false);
                }
                if (!desperate)
                {
                    if (!c.Standable(pawn.Map))
                    {
                        return(false);
                    }
                    if (GenPlace.HaulPlaceBlockerIn(null, c, pawn.Map, false) != null)
                    {
                        return(false);
                    }
                    if (c.GetRegion(pawn.Map, RegionType.Set_Passable).type == RegionType.Portal)
                    {
                        return(false);
                    }
                }
                IntVec3 intVec2;
                return((ignoreDanger || c.GetDangerFor(pawn, pawn.Map) == Danger.None) && !c.ContainsStaticFire(pawn.Map) && !c.ContainsTrap(pawn.Map) && pawn.Map.pawnDestinationReservationManager.CanReserve(c, pawn, false) && Toils_Ingest.TryFindAdjacentIngestionPlaceSpot(c, ingestible.def, pawn, out intVec2));
            };
            int    maxRegions = 1;
            Region region     = pawn.GetRegion(RegionType.Set_Passable);

            for (int i = 0; i < 30; i++)
            {
                if (i == 1)
                {
                    desperate = true;
                }
                else if (i == 2)
                {
                    desperate  = false;
                    maxRegions = 4;
                }
                else if (i == 6)
                {
                    desperate = true;
                }
                else if (i == 10)
                {
                    desperate  = false;
                    maxDist    = 8f;
                    maxRegions = 12;
                }
                else if (i == 15)
                {
                    desperate = true;
                }
                else if (i == 20)
                {
                    maxDist    = 15f;
                    maxRegions = 16;
                }
                else if (i == 26)
                {
                    maxDist      = 5f;
                    maxRegions   = 4;
                    ignoreDanger = true;
                }
                else if (i == 29)
                {
                    maxDist    = 15f;
                    maxRegions = 16;
                }
                Region  reg = CellFinder.RandomRegionNear(region, maxRegions, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), null, null, RegionType.Set_Passable);
                IntVec3 intVec;
                if (reg.TryFindRandomCellInRegionUnforbidden(pawn, validator, out intVec))
                {
                    if (DebugViewSettings.drawDestSearch)
                    {
                        pawn.Map.debugDrawer.FlashCell(intVec, 0.5f, "go!", 50);
                    }
                    return(intVec);
                }
                if (DebugViewSettings.drawDestSearch)
                {
                    pawn.Map.debugDrawer.FlashCell(intVec, 0f, i.ToString(), 50);
                }
            }
            return(region.RandomCell);
        }