CaveworldFlora.Cluster.SpawnNewClusterAt C# (CSharp) Method

SpawnNewClusterAt() public static method

public static SpawnNewClusterAt ( IntVec3 spawnCell, ThingDef_ClusterPlant plantDef, int desiredSize ) : ClusterPlant
spawnCell IntVec3
plantDef ThingDef_ClusterPlant
desiredSize int
return ClusterPlant
        public static ClusterPlant SpawnNewClusterAt(IntVec3 spawnCell, ThingDef_ClusterPlant plantDef, int desiredSize)
        {
            ClusterPlant newPlant = ThingMaker.MakeThing(plantDef) as ClusterPlant;
            GenSpawn.Spawn(newPlant, spawnCell);
            Cluster newCluster = ThingMaker.MakeThing(Util_CaveworldFlora.ClusterDef) as Cluster;
            newCluster.Initialize(plantDef, desiredSize);
            GenSpawn.Spawn(newCluster, spawnCell);
            newPlant.cluster = newCluster;
            return newPlant;
        }
        public void Initialize(ThingDef_ClusterPlant plantDef, int desiredSize)

Usage Example

示例#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);
            }
        }
All Usage Examples Of CaveworldFlora.Cluster::SpawnNewClusterAt