コード例 #1
0
ファイル: ProtoSkill.cs プロジェクト: jashking/CryoFall
        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();
            }
        }
コード例 #2
0
 public void SharedFillEffectsCache(BaseStatsDictionary statsCache)
 {
     foreach (var pair in this.Skills)
     {
         var skill      = pair.Key;
         var skillLevel = pair.Value.Level;
         if (skillLevel > 0)
         {
             skill.FillEffectsCache(statsCache, skillLevel);
         }
     }
 }
コード例 #3
0
        public void FillEffects(IProtoEntity prototype, BaseStatsDictionary effects, double maximumDefensePercent = 1)
        {
            Add(StatName.DefenseImpact, this.Impact);
            Add(StatName.DefenseKinetic, this.Kinetic);
            Add(StatName.DefenseExplosion, this.Explosion);
            Add(StatName.DefenseHeat, this.Heat);
            Add(StatName.DefenseCold, this.Cold);
            Add(StatName.DefenseChemical, this.Chemical);
            Add(StatName.DefenseRadiation, this.Radiation);
            Add(StatName.DefensePsi, this.Psi);

            void Add(StatName statName, double defensePercent)
            {
                if (defensePercent < 0 ||
                    defensePercent > maximumDefensePercent)
                {
                    throw new Exception(
                              $"Incorrect defense property value. It must be in range from 0 to {maximumDefensePercent} (inclusive). The defense {statName} for {prototype} is set to {defensePercent:F2}");
                }

                effects.AddValue(prototype, statName, defensePercent);
            }
        }