//---------------------------------------------------------------------

        /// <summary>
        /// Removes the cohorts that are damaged by an age-only disturbance.
        /// </summary>
        /// <returns>
        /// The total biomass of all the cohorts damaged by the disturbance.
        /// </returns>
        public int DamageBySpecies(AgeCohort.ISpeciesCohortsDisturbance disturbance)
        {
            isSpeciesCohortDamaged.SetAllFalse(Count);
            disturbance.Damage(this, isSpeciesCohortDamaged);

            //  Go backwards through list of cohort data, so the removal of an
            //  item doesn't mess up the loop.
            isMaturePresent = false;
            int totalReduction = 0;

            for (int i = cohortData.Count - 1; i >= 0; i--)
            {
                if (isSpeciesCohortDamaged[i])
                {
                    Cohort cohort = new Cohort(species, cohortData[i]);
                    totalReduction += cohort.Biomass;
                    RemoveCohort(i, cohort, disturbance.CurrentSite,
                                 disturbance.Type);
                    // testing RMS
                    Cohort.KilledByAgeOnlyDisturbance(this, cohort, disturbance.CurrentSite, disturbance.Type);

                    cohort = null;
                }
                else if (cohortData[i].Age >= species.Maturity)
                {
                    isMaturePresent = true;
                }
            }
            return(totalReduction);
        }
Exemplo n.º 2
0
        //---------------------------------------------------------------------

        public int Damage(ICohort cohort)
        {
            if (ageCohortDisturbance.Damage(cohort))
            {
                Cohort.KilledByAgeOnlyDisturbance(this, cohort,
                                                  ageCohortDisturbance.CurrentSite,
                                                  ageCohortDisturbance.Type);
                return(cohort.Biomass);
            }
            else
            {
                return(0);
            }
        }