public static bool TryFindGatheringSpot(Pawn organizer, GatheringDef gatheringDef, out IntVec3 result) { bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer); Map map = organizer.Map; Predicate <IntVec3> baseValidator = (IntVec3 cell) => GatheringsUtility.ValidateGatheringSpot(cell, gatheringDef, organizer, enjoyableOutside); List <ThingDef> gatherSpotDefs = gatheringDef.gatherSpotDefs; try { foreach (ThingDef item in gatherSpotDefs) { foreach (Building item2 in map.listerBuildings.AllBuildingsColonistOfDef(item)) { tmpSpotThings.Add(item2); } } if ((from x in tmpSpotThings where baseValidator(x.Position) select x.Position).TryRandomElement(out result)) { return(true); } } finally { tmpSpotThings.Clear(); } Predicate <IntVec3> noPartySpotValidator = delegate(IntVec3 cell) { Room room = cell.GetRoom(map); return((room == null || room.IsHuge || room.PsychologicallyOutdoors || room.CellCount >= 10) ? true : false); }; foreach (CompGatherSpot item3 in map.gatherSpotLister.activeSpots.InRandomOrder()) { for (int i = 0; i < 10; i++) { IntVec3 intVec = CellFinder.RandomClosewalkCellNear(item3.parent.Position, item3.parent.Map, 4); if (baseValidator(intVec) && noPartySpotValidator(intVec)) { result = intVec; return(true); } } } if (CellFinder.TryFindRandomCellNear(organizer.Position, organizer.Map, 25, (IntVec3 cell) => baseValidator(cell) && noPartySpotValidator(cell), out result)) { return(true); } result = IntVec3.Invalid; return(false); }
protected override bool TryFindGatherSpot(Pawn organizer, out IntVec3 spot) { bool enjoyableOutside = JoyUtility.EnjoyableOutsideNow(organizer); _ = organizer.Map; IEnumerable <Building_MusicalInstrument> enumerable = organizer.Map.listerBuildings.AllBuildingsColonistOfClass <Building_MusicalInstrument>(); try { int num = -1; foreach (Building_MusicalInstrument item in enumerable) { if (GatheringsUtility.ValidateGatheringSpot(item.InteractionCell, def, organizer, enjoyableOutside) && InstrumentAccessible(item, organizer)) { float instrumentRange = item.def.building.instrumentRange; if ((float)num < instrumentRange) { tmpInstruments.Clear(); } else if ((float)num > instrumentRange) { continue; } tmpInstruments.Add(item); } } if (!tmpInstruments.TryRandomElement(out Building_MusicalInstrument result)) { spot = IntVec3.Invalid; return(false); } spot = result.InteractionCell; return(true); } finally { tmpInstruments.Clear(); } }