Landis.Extension.BaseFire.Event.ICohortDisturbance C# (CSharp) Méthode

ICohortDisturbance() private méthode

private ICohortDisturbance ( ICohort cohort ) : bool
cohort ICohort
Résultat bool
        bool ICohortDisturbance.Damage(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;
        }
    }