protected override IntVec3 GetWanderRoot(Pawn pawn)
 {
     return(WanderUtility.GetColonyWanderRoot(pawn));
 }
        public static IEnumerable <LocalTargetInfo> AllMeditationSpotCandidates(Pawn pawn, bool allowFallbackSpots = true)
        {
            bool flag = false;

            if (pawn.royalty != null && pawn.royalty.AllTitlesInEffectForReading.Count > 0 && !pawn.IsPrisonerOfColony)
            {
                Building_Throne building_Throne = RoyalTitleUtility.FindBestUsableThrone(pawn);
                if (building_Throne != null)
                {
                    yield return(building_Throne);

                    flag = true;
                }
            }
            if (!pawn.IsPrisonerOfColony)
            {
                foreach (Building item in pawn.Map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.MeditationSpot).Where(delegate(Building s)
                {
                    if (s.IsForbidden(pawn) || !s.Position.Standable(s.Map))
                    {
                        return(false);
                    }
                    if (s.GetAssignedPawn() != null && s.GetAssignedPawn() != pawn)
                    {
                        return(false);
                    }
                    Room room4 = s.GetRoom();
                    return((room4 == null || CanUseRoomToMeditate(room4, pawn)) && pawn.CanReserveAndReach(s, PathEndMode.OnCell, pawn.NormalMaxDanger()));
                }))
                {
                    yield return(item);

                    flag = true;
                }
            }
            if (flag || !allowFallbackSpots)
            {
                yield break;
            }
            List <Thing> list = pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.MeditationFocus);

            foreach (Thing item2 in list)
            {
                if (item2.def == ThingDefOf.Wall)
                {
                    continue;
                }
                Room room = item2.GetRoom();
                if ((room == null || CanUseRoomToMeditate(room, pawn)) && item2.GetStatValueForPawn(StatDefOf.MeditationFocusStrength, pawn) > 0f)
                {
                    LocalTargetInfo localTargetInfo = MeditationSpotForFocus(item2, pawn);
                    if (localTargetInfo.IsValid)
                    {
                        yield return(localTargetInfo);
                    }
                }
            }
            Building_Bed bed   = pawn.ownership.OwnedBed;
            Room         room2 = bed?.GetRoom();
            IntVec3      c2;

            if (room2 != null && !room2.PsychologicallyOutdoors && pawn.CanReserveAndReach(bed, PathEndMode.OnCell, pawn.NormalMaxDanger()))
            {
                foreach (LocalTargetInfo item3 in FocusSpotsInTheRoom(pawn, room2))
                {
                    yield return(item3);
                }
                c2 = RCellFinder.RandomWanderDestFor(pawn, bed.Position, WanderRadius, (Pawn p, IntVec3 c, IntVec3 r) => c.Standable(p.Map) && c.GetDoor(p.Map) == null && WanderRoomUtility.IsValidWanderDest(p, c, r), pawn.NormalMaxDanger());
                if (c2.IsValid)
                {
                    yield return(c2);
                }
            }
            if (pawn.IsPrisonerOfColony)
            {
                yield break;
            }
            IntVec3 colonyWanderRoot = WanderUtility.GetColonyWanderRoot(pawn);

            c2 = RCellFinder.RandomWanderDestFor(pawn, colonyWanderRoot, WanderRadius, delegate(Pawn p, IntVec3 c, IntVec3 r)
            {
                if (!c.Standable(p.Map) || c.GetDoor(p.Map) != null || !p.CanReserveAndReach(c, PathEndMode.OnCell, p.NormalMaxDanger()))
                {
                    return(false);
                }
                Room room3 = c.GetRoom(p.Map);
                return((room3 == null || CanUseRoomToMeditate(room3, pawn)) ? true : false);
            }, pawn.NormalMaxDanger());
            if (c2.IsValid)
            {
                yield return(c2);
            }
        }