public override IEnumerable <IntVec3> PotentialWorkCellsGlobal(Pawn pawn)
        {
            Danger          maxDanger = pawn.NormalMaxDanger();
            List <Building> bList     = pawn.Map.listerBuildings.allBuildingsColonist;

            for (int i = 0; i < bList.Count; i++)
            {
                Building_PlantGrower b = bList[i] as Building_PlantGrower;
                if ((b != null) && b.TryGetComp <CompBotanyPlanter>().GetIsBotanyPlanter)
                {
                    if (this.ExtraRequirements(b, pawn))
                    {
                        if (!b.IsForbidden(pawn))
                        {
                            if (pawn.CanReach(b, PathEndMode.OnCell, maxDanger, false, TraverseMode.ByPawn))
                            {
                                if (!b.IsBurning())
                                {
                                    foreach (IntVec3 intVec in b.OccupiedRect())
                                    {
                                        yield return(intVec);
                                    }
                                    WorkGiver_GrowerBotany.wantedPlantDef = null;
                                }
                            }
                        }
                    }
                }
            }
            WorkGiver_GrowerBotany.wantedPlantDef = null;
            List <Zone> zonesList = pawn.Map.zoneManager.AllZones;

            for (int j = 0; j < zonesList.Count; j++)
            {
                Zone_GrowingBotanics growZone = zonesList[j] as Zone_GrowingBotanics;
                if (growZone != null)
                {
                    if (growZone.cells.Count == 0)
                    {
                        Log.ErrorOnce("Grow zone has 0 cells: " + growZone, -563487, false);
                    }
                    else if (this.ExtraRequirements(growZone, pawn))
                    {
                        if (!growZone.ContainsStaticFire)
                        {
                            if (pawn.CanReach(growZone.Cells[0], PathEndMode.OnCell, maxDanger, false, TraverseMode.ByPawn))
                            {
                                for (int k = 0; k < growZone.cells.Count; k++)
                                {
                                    yield return(growZone.cells[k]);
                                }
                                WorkGiver_GrowerBotany.wantedPlantDef = null;
                            }
                        }
                    }
                }
            }
            WorkGiver_GrowerBotany.wantedPlantDef = null;
        }
Beispiel #2
0
        protected override bool ExtraRequirements(IPlantToGrowSettable settable, Pawn pawn)
        {
            if (!settable.CanAcceptSowNow())
            {
                return(false);
            }
            Zone_GrowingBotanics zone_Growing = settable as Zone_GrowingBotanics;
            IntVec3 c;

            if (zone_Growing != null)
            {
                if (!zone_Growing.allowSow)
                {
                    return(false);
                }
                c = zone_Growing.Cells[0];
            }
            else
            {
                c = ((Thing)settable).Position;
            }
            WorkGiver_GrowerBotany.wantedPlantDef = WorkGiver_GrowerBotany.CalculateWantedPlantDef(c, pawn.Map);
            return(WorkGiver_GrowerBotany.wantedPlantDef != null);
        }