Ejemplo n.º 1
0
        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_NewTemp(item.InteractionCell, def, organizer, enjoyableOutside, ignoreRequiredColonistCount: false) && 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 var result))
                {
                    spot = IntVec3.Invalid;
                    return(false);
                }
                spot = result.InteractionCell;
                return(true);
            }
            finally
            {
                tmpInstruments.Clear();
            }
        }