/// <summary>
/// Try to spawn another plant in this cluster.
/// </summary>
public static ClusterPlant TryGrowCluster(Cluster cluster)
{
IntVec3 spawnCell = IntVec3.Invalid;
TryGetRandomSpawnCellNearCluster(cluster, out spawnCell);
if (spawnCell.IsValid)
{
ClusterPlant newPlant = ThingMaker.MakeThing(cluster.plantDef) as ClusterPlant;
GenSpawn.Spawn(newPlant, spawnCell, cluster.Map);
newPlant.cluster = cluster;
cluster.NotifyPlantAdded();
if (cluster.plantDef.isSymbiosisPlant)
{
// Destroy source symbiosis plant.
Thing sourceSymbiosisPlant = spawnCell.GetFirstThing(cluster.Map, cluster.plantDef.symbiosisPlantDefSource);
if (sourceSymbiosisPlant != null)
{
sourceSymbiosisPlant.Destroy();
}
}
return(newPlant);
}
else
{
return(null);
}
}