CaveworldFlora.GenClusterPlantReproduction.TryToReproduce C# (CSharp) Method

TryToReproduce() public static method

Try to spawn another cave plant in the cluster or to spawn a new cluster.
public static TryToReproduce ( ClusterPlant plant ) : ClusterPlant
plant ClusterPlant
return ClusterPlant
        public static ClusterPlant TryToReproduce(ClusterPlant plant)
        {
            // Test if it is growing on a fungiponics basin.
            if (plant.isOnCavePlantGrower)
            {
                return null;
            }

            if (plant.cluster.actualSize < plant.cluster.desiredSize)
            {
                // Cluster is not mature, grow the cluster.
                return TryGrowCluster(plant.cluster);
            }
            else
            {
                // Cluster is mature: try to spawn a new cluster and/or a symbiosis cluster.
                if (plant.clusterPlantProps.isSymbiosisPlant == false)
                {
                    return TrySpawnNewClusterAwayFrom(plant.cluster);
                }
                if (plant.clusterPlantProps.symbiosisPlantDefEvolution != null)
                {
                    TryToSpawnNewSymbiosisCluster(plant.cluster);
                }
            }
            return null;
        }

Usage Example

Beispiel #1
0
        // ===================== Main Work Function =====================
        /// <summary>
        /// Main function:
        /// - update the glower if necessary.
        /// - verify the cave plant is in good conditions to growth.
        /// - when the cave plant is too old, damage it over time.
        /// - when the cave plant is mature, try to reproduce.
        /// </summary>
        public override void TickLong()
        {
            if (this.isGrowingNow)
            {
                bool plantWasAlreadyMature = (this.LifeStage == PlantLifeStage.Mature);
                this.growthInt += this.GrowthPerTick * GenTicks.TickLongInterval;
                if (!plantWasAlreadyMature &&
                    (this.LifeStage == PlantLifeStage.Mature))
                {
                    // Plant just became mature.
                    this.Map.mapDrawer.MapMeshDirty(this.Position, MapMeshFlag.Things);
                }
            }

            // Verify the plant is not in cryostasis.
            if (this.isInCryostasis == false)
            {
                if (this.LifeStage == PlantLifeStage.Mature)
                {
                    this.ageInt += GenTicks.TickLongInterval;
                }
                if (this.Dying)
                {
                    int amount = Mathf.CeilToInt(1.25f);
                    base.TakeDamage(new DamageInfo(DamageDefOf.Rotting, amount, -1, null, null, null));
                }
                if (!base.Destroyed &&
                    (this.growthInt > minGrowthToReproduce) &&
                    !this.Dying &&
                    Rand.MTBEventOccurs(this.def.plant.reproduceMtbDays, GenDate.TicksPerDay, GenTicks.TickLongInterval))
                {
                    GenClusterPlantReproduction.TryToReproduce(this);
                }
            }

            // Update glower.
            if (!base.Destroyed)
            {
                UpdateGlowerAccordingToGrowth();
            }

            this.cachedLabelMouseover = null;
        }
All Usage Examples Of CaveworldFlora.GenClusterPlantReproduction::TryToReproduce