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

		/// <summary>
		/// Records a species that should be checked for resprouting during
		/// reproduction.
		/// </summary>
		/// <param name="cohort">
		/// The cohort whose death triggered the current call to this method.
		/// </param>
		/// <param name="site">
		/// The site where the cohort died.
		/// </param>
		/// <remarks>
		/// If the cohort's age is within the species' age range for
		/// resprouting, then the species will be have additional resprouting
		/// criteria (light, probability) checked during reproduction.
		/// </remarks>
		public static void CheckForResprouting(AgeCohort.ICohort cohort,
		                                       ActiveSite        site)
		{
			ISpecies species = cohort.Species;
			if (species.MinSproutAge <= cohort.Age && cohort.Age <= species.MaxSproutAge)
				resprout[site].Set(species.Index, true);
		}
        //---------------------------------------------------------------------
        /// <summary>
        /// Records a species that should be checked for post-fire regeneration
        /// during reproduction.
        /// </summary>
        /// <param name="cohort">
        /// The cohort whose death triggered the current call to this method.
        /// </param>
        /// <param name="site">
        /// The site where the cohort died.
        /// </param>
        /// <remarks>
        /// If the cohort's species has resprouting as its post-fire
        /// regeneration, then the CheckForResprouting method is called with
        /// the cohort.  If the species has serotiny as its post-fire
        /// regeneration, then the species will be checked for on-site seeding
        /// during reproduction.
        /// </remarks>
        public static void CheckForPostFireRegen(AgeCohort.ICohort cohort,
            ActiveSite        site)
        {
            ISpecies species = cohort.Species;
            switch (species.PostFireRegeneration) {
                case PostFireRegeneration.Resprout:
                    CheckForResprouting(cohort, site);
                    break;

                case PostFireRegeneration.Serotiny:
                    if (cohort.Age >= species.Maturity)
                        serotiny[site].Set(species.Index, true);
                    break;

                default:
                    //	Do nothing
                    break;
            }
        }
		//---------------------------------------------------------------------
		//DamageCohort is a filter to determine which cohorts are removed.

		private bool DamageCohort(AgeCohort.ICohort cohort)
		{
			//logger.Debug(string.Format("Damaging Cohorts. Severity = {0}", siteSeverity));
			//Fire Severity 5 kills all cohorts:
			if(siteSeverity == 5) 
			{
				this.cohortsKilled++;
				logger.Debug(string.Format("  cohort {0}:{1} killed, severity =5", cohort.Species.Name, cohort.Age));
				return true;
			}
			
			//Otherwise, use damage table to calculate damage.
			//Read table backwards; most severe first.
			float ageAsPercent = cohort.Age / (float) cohort.Species.Longevity;
			for (int i = damages.Length-1; i >= 0; --i) 
			{
				IDamageTable damage = damages[i];
				if (siteSeverity - cohort.Species.FireTolerance == damage.SeverTolerDifference) {
					if (damage.MaxAge >= ageAsPercent) {
						this.cohortsKilled++;
						logger.Debug(string.Format("  cohort {0}:{1} killed, damage class {2}", cohort.Species.Name, cohort.Age, damage.SeverTolerDifference));
						return true;  //Yes, kill me.
					}
					break;  // No need to search further in the table
				}
			}
			return false;
		}
            //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

            bool AgeCohort.IDisturbance.Damage(AgeCohort.ICohort cohort)
            {
                if (5 <= cohort.Age && cohort.Age <= 30)
                    return true;
                else
                    return false;
            }
        //---------------------------------------------------------------------

        public WrappedDisturbance(AgeCohort.IDisturbance ageCohortDisturbance)
        {
            this.ageCohortDisturbance = ageCohortDisturbance;
        }
		//---------------------------------------------------------------------
		//DamageCohort is a filter to determine which cohorts are removed.

		private bool DamageCohort(AgeCohort.ICohort cohort)
		{
			bool killCohort = false;

			//Fire Severity 5 kills all cohorts:
			if (siteSeverity == 5) 
			{
				logger.Debug(string.Format("  cohort {0}:{1} killed, severity =5", cohort.Species.Name, cohort.Age));
				killCohort = true;
			}
			
			//Otherwise, use damage table to calculate damage.
			//Read table backwards; most severe first.
			float ageAsPercent = cohort.Age / (float) cohort.Species.Longevity;
			for (int i = damages.Length-1; i >= 0; --i) 
			{
				IDamageTable damage = damages[i];
				if (siteSeverity - cohort.Species.FireTolerance == damage.SeverTolerDifference) {
					if (damage.MaxAge >= ageAsPercent) {
						logger.Debug(string.Format("  cohort {0}:{1} killed, damage class {2}", cohort.Species.Name, cohort.Age, damage.SeverTolerDifference));
						killCohort = true;
					}
					break;  // No need to search further in the table
				}
			}

			if (killCohort) {
				this.cohortsKilled++;
				successionPlugIn.CheckForPostFireRegen(cohort, currentSite);
			}
			return killCohort;
		}
 //---------------------------------------------------------------------
 /// <summary>
 /// Makes a list of age cohorts in an initial community sorted from
 /// oldest to youngest.
 /// </summary>
 public static List<AgeCohort.ICohort> SortCohorts(AgeCohort.ISiteCohorts siteCohorts)
 {
     List<AgeCohort.ICohort> cohorts = new List<AgeCohort.ICohort>();
     foreach (AgeCohort.ISpeciesCohorts speciesCohorts in siteCohorts) {
         foreach (AgeCohort.ICohort cohort in speciesCohorts)
             cohorts.Add(cohort);
     }
     cohorts.Sort(AgeCohort.Util.WhichIsOlderCohort);
     return cohorts;
 }
        //---------------------------------------------------------------------
        // DamageCohort is a filter to determine which cohorts are removed.
        // Each cohort is passed into the function and tested whether it should
        // be killed.
        bool AgeCohort.ICohortDisturbance.Damage(AgeCohort.ICohort cohort)
        {
            bool killCohort = false;

            ISppParameters sppParms = epidemicParms.SppParameters[cohort.Species.Index];

            if (sppParms == null)
                return killCohort;
            
            
            if(this.siteSeverity == 1)
                if(cohort.Age >= sppParms.VulnerableHostAge)
                    killCohort = true;
            if(this.siteSeverity == 2)
                if(cohort.Age >= sppParms.TolerantHostAge)
                    killCohort = true;
            if(this.siteSeverity == 3)
                if(cohort.Age >= sppParms.ResistantHostAge)
                    killCohort = true;
                    
            if (killCohort)
            {
                this.siteCohortsKilled++;
                if (sppParms.CFSConifer)
                    this.siteCFSconifersKilled++;
            }

            return killCohort;
        }
        } // public virtual double Harvest(Stand stand)

        //---------------------------------------------------------------------
        void AgeCohort.ISpeciesCohortsDisturbance.Damage(AgeCohort.ISpeciesCohorts         cohorts,
                                                         AgeCohort.ISpeciesCohortBoolArray isDamaged)
        {
            cohortSelector.Harvest(cohorts, isDamaged);

            int cohortsDamaged = 0;
            for (int i = 0; i < isDamaged.Count; i++) {
                if (isDamaged[i]) {
                    
                    //if this cohort is killed, update the damage table (for the stand of this site) with this species name
                    SiteVars.Stand[currentSite].UpdateDamageTable(cohorts.Species.Name);
                    
                    //and increment the cohortsDamaged
                    cohortsDamaged++;
                }
            }
            SiteVars.CohortsDamaged[currentSite] += cohortsDamaged;
        }
        //---------------------------------------------------------------------

        public Community(ushort                 mapCode,
                         AgeCohort.ISiteCohorts cohorts)
        {
            this.mapCode = mapCode;
            this.cohorts = cohorts;
        }
        //---------------------------------------------------------------------

        bool AgeCohort.ICohortDisturbance.Damage(AgeCohort.ICohort cohort)

//        private bool DamageCohort(AgeCohort.ICohort cohort)
        {
            float ageAsPercent = cohort.Age / (float) cohort.Species.Longevity;
            for (int i = 0; i < severities.Length; ++i) {
                ISeverity severity = severities[i];
                if (severity.AgeRange.Contains(ageAsPercent)) {
                    if (intensity < severity.MortalityProbability) {
                        cohortsKilled++;
                        if (severity.Number > siteSeverity)
                            siteSeverity = severity.Number;
                        //successionPlugIn.CheckForResprouting(cohort, currentSite);
                        //UI.WriteLine("  cohort {0}:{1} killed, severity {2}", cohort.Species.Name, cohort.Age, severity.Number);
                        return true;
                    }
                    break;  // No need to search further in the table
                }
            }
            return false;
        }
		//---------------------------------------------------------------------

		private bool DamageCohort(AgeCohort.ICohort cohort)
		{
			float ageAsPercent = cohort.Age / (float) cohort.Species.Longevity;
			for (int i = 0; i < severities.Length; ++i) {
				ISeverity severity = severities[i];
				if (severity.AgeRange.Contains(ageAsPercent)) {
					if (intensity < severity.MortalityProbability) {
						cohortsKilled++;
						if (severity.Number > siteSeverity)
							siteSeverity = severity.Number;
						logger.Debug(string.Format("  cohort {0}:{1} killed, severity {2}", cohort.Species.Name, cohort.Age, severity.Number));
						return true;
					}
					break;  // No need to search further in the table
				}
			}
			return false;
		}
        //---------------------------------------------------------------------

        //  A filter to determine which cohorts are removed.

        bool AgeCohort.ICohortDisturbance.Damage(AgeCohort.ICohort cohort)
        //bool BaseCohort.ICohortDisturbance.MarkCohortsForDeath(AgeCohort.ICohort cohort)
        {
            bool killCohort = false;

            //Fire Severity 5 kills all cohorts:
            if (siteSeverity == 5) 
            {
                //logger.Debug(string.Format("  cohort {0}:{1} killed, severity =5", cohort.Species.Name, cohort.Age));
                killCohort = true;
            }
            else {
                //Otherwise, use damage table to calculate damage.
                //Read table backwards; most severe first.
                float ageAsPercent = (float) cohort.Age / (float) cohort.Species.Longevity;
                //for (int i = damages.Length-1; i >= 0; --i) 
                foreach(IDamageTable damage in damages)
                {
                    //IDamageTable damage = damages[i];
                    if (siteSeverity - cohort.Species.FireTolerance >= damage.SeverTolerDifference) 
                    {
                        if (damage.MaxAge >= ageAsPercent) {
                            //logger.Debug(string.Format("  cohort {0}:{1} killed, damage class {2}", cohort.Species.Name, cohort.Age, damage.SeverTolerDifference));
                            killCohort = true;
                        }
                        break;  // No need to search further in the table
                    }
                }
            }

            if (killCohort) {
                this.cohortsKilled++;
            }
            return killCohort;
        }
        //---------------------------------------------------------------------

        //  A filter to determine which cohorts are removed.

        bool AgeCohort.ICohortDisturbance.Damage(AgeCohort.ICohort cohort)
        {
            bool killCohort = false;

            //Fire Severity 5 kills all cohorts:
            if (siteSeverity == 5) 
            {
                killCohort = true;
            }
            else {
                //Otherwise, use damage table to calculate damage.
                //Read table backwards; most severe first.
                float ageAsPercent = (float) cohort.Age / (float) cohort.Species.Longevity;
                for (int i = damages.Length-1; i >= 0; --i) 
                {
                    IDamageTable damage = damages[i];
                    if (siteSeverity - cohort.Species.FireTolerance >= damage.SeverTolerDifference) 
                    {
                        if (damage.MaxAge >= ageAsPercent) {
                            killCohort = true;
                        }
                        break;  // No need to search further in the table
                    }
                }
            }

            if (killCohort) {
                this.cohortsKilled++;
            }
            return killCohort;
        }
        //---------------------------------------------------------------------

        bool AgeCohort.ICohortDisturbance.Damage(AgeCohort.ICohort cohort)
        {
            float ageAsPercent = cohort.Age / (float) cohort.Species.Longevity;
            //for (int i = 0; i < severities.Length; ++i)
            foreach (ISeverity severity in severities)
            {
                //ISeverity severity = severities[i];
                //if (severity.AgeRange.Contains(ageAsPercent))
                if(ageAsPercent >= severity.MinAge && ageAsPercent <= severity.MaxAge)
                {
                    if (intensity < severity.MortalityProbability) {
                        cohortsKilled++;
                        if (severity.Number > siteSeverity)
                            siteSeverity = severity.Number;
                        //UI.WriteLine("  cohort {0}:{1} killed, severity {2}", cohort.Species.Name, cohort.Age, severity.Number);
                        return true;
                    }
                    break;  // No need to search further in the table
                }
            }
            return false;
        }