SpawnNewClusterAt() public static method

public static SpawnNewClusterAt ( IntVec3 spawnCell, ThingDef_ClusterPlant plantDef, int desiredSize ) : ClusterPlant
spawnCell IntVec3
plantDef ThingDef_ClusterPlant
desiredSize int
return ClusterPlant
Beispiel #1
0
        /// <summary>
        /// Tries to spawn a new cluster at a random position on the map. The exclusivity radius still applies.
        /// </summary>
        public void TrySpawnNewClusterAtRandomPosition()
        {
            ThingDef_ClusterPlant cavePlantDef = cavePlantDefs.RandomElementByWeight((ThingDef_ClusterPlant plantDef) => plantDef.plant.wildCommonalityMaxFraction / plantDef.clusterSizeRange.Average);

            int     newDesiredClusterSize = cavePlantDef.clusterSizeRange.RandomInRange;
            IntVec3 spawnCell             = IntVec3.Invalid;

            GenClusterPlantReproduction.TryGetRandomClusterSpawnCell(cavePlantDef, newDesiredClusterSize, true, this.map, out spawnCell);
            if (spawnCell.IsValid)
            {
                Cluster.SpawnNewClusterAt(this.map, spawnCell, cavePlantDef, newDesiredClusterSize);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Try to spawn a new cluster away from plant.
        /// </summary>
        public static ClusterPlant TrySpawnNewClusterAwayFrom(Cluster cluster)
        {
            IntVec3 spawnCell             = IntVec3.Invalid;
            int     newDesiredClusterSize = cluster.plantDef.clusterSizeRange.RandomInRange;

            TryGetRandomSpawnCellAwayFromCluster(cluster, newDesiredClusterSize, out spawnCell);
            if (spawnCell.IsValid)
            {
                return(Cluster.SpawnNewClusterAt(cluster.Map, spawnCell, cluster.plantDef, newDesiredClusterSize));
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Tries to spawn a new cluster at a random position on the map. The exclusivity radius still applies.
        /// </summary>
        public void TrySpawnNewClusterAtRandomPosition()
        {
            //Log.Message("TrySpawnNewClusterAtRandomPosition");
            for (int defindex = 0; defindex < cavePlantDefs.Count; defindex++)
            {
                //Log.Message("cavePlantDefs: " + cavePlantDefs[defindex].ToString());
            }
            ThingDef_ClusterPlant cavePlantDef = cavePlantDefs.RandomElementByWeight((ThingDef_ClusterPlant plantDef) => plantDef.plant.wildCommonalityMaxFraction / plantDef.clusterSizeRange.Average);
            //Log.Message("selected cavePlantDef = " + cavePlantDef.ToString());

            int     newDesiredClusterSize = cavePlantDef.clusterSizeRange.RandomInRange;
            IntVec3 spawnCell             = IntVec3.Invalid;

            GenClusterPlantReproduction.TryGetRandomClusterSpawnCell(cavePlantDef, newDesiredClusterSize, true, out spawnCell);
            if (spawnCell.IsValid)
            {
                Cluster.SpawnNewClusterAt(spawnCell, cavePlantDef, newDesiredClusterSize);
            }
        }
Beispiel #4
0
 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);
 }