Exemplo n.º 1
0
        public void FillEffectsCache(BaseStatsDictionary statsCache, byte level)
        {
            if (!this.HasStatEffects)
            {
                return;
            }

            // this temp cache will be taken only when necessarily
            TempStatsCache tempStatsCache = null;

            foreach (var statEffect in this.StatEffects)
            {
                if (level < statEffect.Level)
                {
                    // level is lower than required
                    continue;
                }

                tempStatsCache ??= TempStatsCache.GetFromPool();

                var statName = statEffect.StatName;
                tempStatsCache.AddValue(this, statName, statEffect.CalcTotalValueBonus(level));
                tempStatsCache.AddPercent(this, statName, statEffect.CalcTotalPercentBonus(level));
            }

            if (tempStatsCache is not null)
            {
                statsCache.Merge(tempStatsCache);
                tempStatsCache.Dispose();
            }
        }