public override bool HasJobOnCell(Pawn pawn, IntVec3 c, bool forced = false) { Plant plant = c.GetPlant(pawn.Map); if (plant == null) { return(false); } if (plant.IsForbidden(pawn)) { return(false); } if (!plant.HarvestableNow || plant.LifeStage != PlantLifeStage.Mature) { return(false); } if (!plant.CanYieldNow()) { return(false); } LocalTargetInfo target = plant; return(pawn.CanReserve(target, 1, -1, null, forced)); }
public static void AddObjectToActionableObjects(Map map, IntVec3 location, List <HashSet <IntVec3>[]> awaitingActionZoomLevels) { int jumboCellWidth; int mapSizeX = map.Size.x; int mapSizeZ = map.Size.z; int zoomLevel; //---START--- For plant Harvest //WorkGiver_GrowerHarvest.HasJobOnCell Plant plant = location.GetPlant(map); bool hasJobOnCell = plant != null && !plant.IsForbidden(Faction.OfPlayer) && (plant.HarvestableNow && plant.LifeStage == PlantLifeStage.Mature) && (plant.CanYieldNow() && !map.physicalInteractionReservationManager.IsReserved(location)); if (!hasJobOnCell) { return; } //---END-- zoomLevel = 0; do { jumboCellWidth = getJumboCellWidth(zoomLevel); HashSet <IntVec3>[] awaitingActionGrid = awaitingActionZoomLevels[zoomLevel]; int jumboCellIndex = CellToIndexCustom(location, mapSizeX, jumboCellWidth); HashSet <IntVec3> hashset = awaitingActionGrid[jumboCellIndex]; if (hashset == null) { hashset = new HashSet <IntVec3>(); lock (awaitingActionGrid) { awaitingActionGrid[jumboCellIndex] = hashset; } } lock (hashset) { hashset.Add(location); } zoomLevel++; } while (jumboCellWidth < mapSizeX || jumboCellWidth < mapSizeZ); }