public static void TryGetRandomClusterSpawnCell(ThingDef_ClusterPlant plantDef, int newDesiredClusterSize, bool checkTemperature, out IntVec3 spawnCell)
{
spawnCell = IntVec3.Invalid;
Predicate<IntVec3> validator = delegate(IntVec3 cell)
{
// Check a plant can be spawned here.
if (GenClusterPlantReproduction.IsValidPositionToGrowPlant(plantDef, cell) == false)
{
return false;
}
// Check there is no third cluster nearby.
if (GenClusterPlantReproduction.IsClusterAreaClear(plantDef, newDesiredClusterSize, cell) == false)
{
return false;
}
return true;
};
bool validCellIsFound = CellFinderLoose.TryGetRandomCellWith(validator, 1000, out spawnCell);
if (validCellIsFound == false)
{
// Just for robustness, TryGetRandomCellWith set result to IntVec3.Invalid if no valid cell is found.
spawnCell = IntVec3.Invalid;
}
}