// Token: 0x06000078 RID: 120 RVA: 0x00004C7C File Offset: 0x00002E7C
        private HashSet <Thing> FindNearbyNeeders(Pawn pawn, ThingDefCountClass need, IConstructible c, int resTotalAvailable, bool canRemoveExistingFloorUnderNearbyNeeders, out int neededTotal, out Job jobToMakeNeederAvailable)
        {
            neededTotal = need.count;
            HashSet <Thing> hashSet = new HashSet <Thing>();
            Thing           thing   = (Thing)c;

            foreach (Thing thing2 in GenRadial.RadialDistinctThingsAround(thing.Position, thing.Map, 8f, true))
            {
                bool flag = neededTotal >= resTotalAvailable;
                if (flag)
                {
                    break;
                }
                bool flag2 = this.IsNewValidNearbyNeeder(thing2, hashSet, c, pawn);
                if (flag2)
                {
                    Blueprint blueprint = thing2 as Blueprint;
                    bool      flag3     = blueprint == null || !WorkGiver_WPConstructDeliverResources.ShouldRemoveExistingFloorFirst(pawn, blueprint);
                    if (flag3)
                    {
                        int  num   = GenConstruct.AmountNeededByOf((IConstructible)thing2, need.thingDef);
                        bool flag4 = num > 0;
                        if (flag4)
                        {
                            hashSet.Add(thing2);
                            neededTotal += num;
                        }
                    }
                }
            }
            Blueprint blueprint2 = c as Blueprint;
            bool      flag5      = blueprint2 != null && blueprint2.def.entityDefToBuild is TerrainDef && canRemoveExistingFloorUnderNearbyNeeders && neededTotal < resTotalAvailable;

            if (flag5)
            {
                foreach (Thing thing3 in GenRadial.RadialDistinctThingsAround(thing.Position, thing.Map, 3f, false))
                {
                    bool flag6 = this.IsNewValidNearbyNeeder(thing3, hashSet, c, pawn);
                    if (flag6)
                    {
                        Blueprint blueprint3 = thing3 as Blueprint;
                        bool      flag7      = blueprint3 != null;
                        if (flag7)
                        {
                            Job  job   = this.RemoveExistingFloorJob(pawn, blueprint3);
                            bool flag8 = job != null;
                            if (flag8)
                            {
                                jobToMakeNeederAvailable = job;
                                return(hashSet);
                            }
                        }
                    }
                }
            }
            jobToMakeNeederAvailable = null;
            return(hashSet);
        }
示例#2
0
        private HashSet <Thing> FindNearbyNeeders(Pawn pawn, ThingDefCountClass need, IConstructible c, int resTotalAvailable, bool canRemoveExistingFloorUnderNearbyNeeders, out int neededTotal, out Job jobToMakeNeederAvailable)
        {
            neededTotal = need.count;
            HashSet <Thing> hashSet = new HashSet <Thing>();
            Thing           thing   = (Thing)c;

            foreach (Thing item in GenRadial.RadialDistinctThingsAround(thing.Position, thing.Map, 8f, useCenter: true))
            {
                if (neededTotal >= resTotalAvailable)
                {
                    break;
                }
                if (!IsNewValidNearbyNeeder(item, hashSet, c, pawn))
                {
                    continue;
                }
                Blueprint blueprint = item as Blueprint;
                if (blueprint == null || !ShouldRemoveExistingFloorFirst(pawn, blueprint))
                {
                    int num = GenConstruct.AmountNeededByOf((IConstructible)item, need.thingDef);
                    if (num > 0)
                    {
                        hashSet.Add(item);
                        neededTotal += num;
                    }
                }
            }
            Blueprint blueprint2 = c as Blueprint;

            if (blueprint2 != null && blueprint2.def.entityDefToBuild is TerrainDef && canRemoveExistingFloorUnderNearbyNeeders && neededTotal < resTotalAvailable)
            {
                foreach (Thing item2 in GenRadial.RadialDistinctThingsAround(thing.Position, thing.Map, 3f, useCenter: false))
                {
                    if (!IsNewValidNearbyNeeder(item2, hashSet, c, pawn))
                    {
                        continue;
                    }
                    Blueprint blueprint3 = item2 as Blueprint;
                    if (blueprint3 != null)
                    {
                        Job job = RemoveExistingFloorJob(pawn, blueprint3);
                        if (job != null)
                        {
                            jobToMakeNeederAvailable = job;
                            return(hashSet);
                        }
                    }
                }
            }
            jobToMakeNeederAvailable = null;
            return(hashSet);
        }