TryGetRandomClusterSpawnCell() public static method

Try to get a valid cell to spawn a new cluster anywhere on the map.
public static TryGetRandomClusterSpawnCell ( ThingDef_ClusterPlant plantDef, int newDesiredClusterSize, bool checkTemperature, IntVec3 &spawnCell ) : void
plantDef ThingDef_ClusterPlant
newDesiredClusterSize int
checkTemperature bool
spawnCell IntVec3
return void
コード例 #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);
            }
        }
コード例 #2
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);
            }
        }