CaveworldFlora.GenClusterPlantReproduction.TryToSpawnNewSymbiosisCluster C# (CSharp) Method

TryToSpawnNewSymbiosisCluster() public static method

public static TryToSpawnNewSymbiosisCluster ( Cluster cluster ) : ClusterPlant
cluster Cluster
return ClusterPlant
        public static ClusterPlant TryToSpawnNewSymbiosisCluster(Cluster cluster)
        {
            // Check there is not already a symbiosis cluster.
            if (cluster.symbiosisCluster == null)
            {
                foreach (IntVec3 cell in GenRadial.RadialCellsAround(cluster.Position, cluster.plantDef.clusterSpawnRadius, false).InRandomOrder())
                {
                    if (cell.InBounds() == false)
                    {
                        continue;
                    }
                    ClusterPlant plant = cell.GetFirstThing(cluster.plantDef) as ClusterPlant;
                    if (plant != null)
                    {
                        plant.Destroy();
                        ClusterPlant symbiosisPlant = Cluster.SpawnNewClusterAt(cell, cluster.plantDef.symbiosisPlantDefEvolution, cluster.plantDef.symbiosisPlantDefEvolution.clusterSizeRange.RandomInRange);
                        cluster.NotifySymbiosisClusterAdded(symbiosisPlant.cluster);
                        return symbiosisPlant;
                    }
                }
            }
            return null;
        }
    }