//RCellFinder
        public static void TryFindPartySpot_PostFix(Pawn organizer, ref IntVec3 result, ref bool __result)
        {
            bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer, null);
            Map  map = organizer.Map;

            if (map.listerThings.ThingsOfDef(ThingDef.Named("LotRH_PlantPartyTree")).Any(x => x is Plant y && y.HarvestableNow))
            {
                Predicate <IntVec3> baseValidator = delegate(IntVec3 cell)
                {
                    if (!cell.Standable(map))
                    {
                        return(false);
                    }
                    if (cell.GetDangerFor(organizer, map) != Danger.None)
                    {
                        return(false);
                    }
                    if (!enjoyableOutside && !cell.Roofed(map))
                    {
                        return(false);
                    }
                    if (cell.IsForbidden(organizer))
                    {
                        return(false);
                    }
                    if (!organizer.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.None, 1, -1, null, false))
                    {
                        return(false);
                    }
                    Room room = cell.GetRoom(map, RegionType.Set_Passable);
                    bool flag = room != null && room.isPrisonCell;
                    return(organizer.IsPrisoner == flag && PartyUtility.EnoughPotentialGuestsToStartParty(map, new IntVec3?(cell)));
                };
                if ((from x in map.listerThings.ThingsOfDef(ThingDef.Named("LotRH_PlantPartyTree")).Where(x => x is Plant y && y.HarvestableNow)
                     where baseValidator(x.InteractionCell)
                     select x.InteractionCell).TryRandomElement(out result))
                {
                    __result = true;
                }
            }
        }
        public static bool TryFindPartySpot(Pawn organizer, out IntVec3 result)
        {
            bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer, null);
            Map  map = organizer.Map;
            Predicate <IntVec3> baseValidator = delegate(IntVec3 cell)
            {
                if (!cell.Standable(map))
                {
                    return(false);
                }
                if (cell.GetDangerFor(organizer, map) != Danger.None)
                {
                    return(false);
                }
                if (!enjoyableOutside && !cell.Roofed(map))
                {
                    return(false);
                }
                if (cell.IsForbidden(organizer))
                {
                    return(false);
                }
                if (!organizer.CanReserveAndReach(cell, PathEndMode.OnCell, Danger.None, 1, -1, null, false))
                {
                    return(false);
                }
                Room room = cell.GetRoom(map, RegionType.Set_Passable);
                bool flag = room != null && room.isPrisonCell;
                return(organizer.IsPrisoner == flag && PartyUtility.EnoughPotentialGuestsToStartParty(map, new IntVec3?(cell)));
            };

            if ((from x in map.listerBuildings.AllBuildingsColonistOfDef(ThingDefOf.PartySpot)
                 where baseValidator(x.Position)
                 select x.Position).TryRandomElement(out result))
            {
                return(true);
            }
            Predicate <IntVec3> noPartySpotValidator = delegate(IntVec3 cell)
            {
                Room room = cell.GetRoom(map, RegionType.Set_Passable);
                return(room == null || room.IsHuge || room.PsychologicallyOutdoors || room.CellCount >= 10);
            };

            foreach (CompGatherSpot current in map.gatherSpotLister.activeSpots.InRandomOrder(null))
            {
                for (int i = 0; i < 10; i++)
                {
                    IntVec3 intVec = CellFinder.RandomClosewalkCellNear(current.parent.Position, current.parent.Map, 4, null);
                    if (baseValidator(intVec) && noPartySpotValidator(intVec))
                    {
                        result = intVec;
                        bool result2 = true;
                        return(result2);
                    }
                }
            }
            if (CellFinder.TryFindRandomCellNear(organizer.Position, organizer.Map, 25, (IntVec3 cell) => baseValidator(cell) && noPartySpotValidator(cell), out result, -1))
            {
                return(true);
            }
            result = IntVec3.Invalid;
            return(false);
        }