// Token: 0x0600042A RID: 1066 RVA: 0x0001E110 File Offset: 0x0001C310
 public SpecialData(Ability ability, string name)
 {
     try
     {
         AbilitySpecialData abilitySpecialData = ability.AbilitySpecialData.First((AbilitySpecialData x) => x.Name == name);
         AbilityId          talentId           = abilitySpecialData.SpecialBonusAbility;
         if (talentId != AbilityId.ability_base)
         {
             Unit unit = ability.Owner as Unit;
             if (unit != null)
             {
                 this.talent = unit.Spellbook.Spells.FirstOrDefault((Ability x) => x.Id == talentId);
             }
         }
         if (this.talent != null)
         {
             this.talentValue = this.talent.AbilitySpecialData.First((AbilitySpecialData x) => x.Name == "value").Value;
             this.getDataFunc = new Func <uint, float>(this.GetValueWithTalent);
         }
         else
         {
             this.getDataFunc = new Func <uint, float>(this.GetValueDefault);
         }
         this.value = new float[abilitySpecialData.Count];
         uint num = 0u;
         Func <AbilitySpecialData, bool> < > 9__3;
         while ((ulong)num < (ulong)((long)this.value.Length))
         {
             float[] array = this.value;
             int     num2  = (int)num;
             IEnumerable <AbilitySpecialData> abilitySpecialData2 = ability.AbilitySpecialData;
             Func <AbilitySpecialData, bool>  predicate;
             if ((predicate = < > 9__3) == null)
             {
                 predicate = (< > 9__3 = ((AbilitySpecialData x) => x.Name == name));
             }
             array[num2] = abilitySpecialData2.First(predicate).GetValue(num);
             num        += 1u;
         }
     }
     catch
     {
         this.getDataFunc = ((uint _) => 1f);
         BrokenAbilityException ex = new BrokenAbilityException(ability.Name);
         if (ability.IsValid)
         {
             ex.Data["Ability"] = new
             {
                 Ability     = ability.Name,
                 SpecialData = name
             };
         }
         Logger.Error(ex, null);
     }
 }
Exemple #2
0
        private void UpdateRange()
        {
            if (isRangeOnly)
            {
                return;
            }

            if (isAttackRange && Unit != null)
            {
                Range = 0;
                IEnumerable <Ability> spells = null;
                try
                {
                    spells = Unit.Spellbook.Spells.Where(x => x.Name.Contains("take_aim") || x.Name.Contains("psi_blades"));
                }
                catch (Ensage.EntityNotFoundException)
                {
                }

                if (spells != null)
                {
                    foreach (var spell in spells)
                    {
                        var data = spell.AbilitySpecialData.FirstOrDefault(x => x.Name.Contains("radius") || (x.Name.Contains("range") && !x.Name.Contains("ranged")));
                        if (data != null)
                        {
                            float value = 0;
                            if (spell.Level > 0)
                            {
                                value = data.Count > 1 ? data.GetValue(spell.Level - 1) : data.Value;
                            }
                            if (value > 0)
                            {
                                Range += value;
                            }
                        }
                    }
                }
                if (Unit.HasModifier("modifier_dragon_knight_dragon_form"))
                {
                    Range += 350;
                }
                else if (Unit.HasModifier("modifier_terrorblade_metamorphosis"))
                {
                    Range += 400;
                }
                Range += Unit.AttackRange + Unit.HullRadius;
                if (Unit.IsRanged && Unit.HasInventory)
                {
                    Item item = Unit.Inventory.Items.FirstOrDefault(x => x != null && x.IsValid && (x.Name.Contains("item_dragon_lance") || x.Name.Contains("item_hurricane_pike")));
                    if (item != null)
                    {
                        var spellData = item.AbilitySpecialData.FirstOrDefault(x => x.Name == "base_attack_range");
                        if (spellData != null)
                        {
                            Range += spellData.Value;
                        }
                    }
                }
                return;
            }

            if (Ability == null || Unit == null)
            {
                LastUsedRange = Range = 0;
                IsDisplayable = false;
                IsDisplayed   = false;
                return;
            }

            float bonusRange = 0f;

            if (((Ability.AbilityBehavior & AbilityBehavior.NoTarget) == 0) && Unit.HasInventory)
            {
                Item item = Unit.Inventory.Items.FirstOrDefault(x => x != null && x.IsValid && x.Name.Contains("item_aether_lens"));
                if (item != null)
                {
                    var spellData = item.AbilitySpecialData.FirstOrDefault(x => x.Name == "cast_range_bonus");
                    if (spellData != null)
                    {
                        bonusRange += spellData.Value;
                    }
                }
            }
            Range = Ability.CastRange;
            if (Range < 1)  //known as Range == 0
            {
                AbilitySpecialData data = null;
                if (Unit.AghanimState())
                {
                    data = Ability.AbilitySpecialData.FirstOrDefault(x => x.Name.Contains("scepter") && (x.Name.Contains("radius") || (x.Name.Contains("range") && !x.Name.Contains("ranged"))));
                }
                if (data == null)
                {
                    data = Ability.AbilitySpecialData.FirstOrDefault(x => x.Name.Contains("radius") || (x.Name.Contains("range") && !x.Name.Contains("ranged")));
                }
                if (data != null)
                {
                    uint level = Ability.Level == 0 ? 0 : Ability.Level - 1;
                    Range = data.Count > 1 ? data.GetValue(level) : data.Value;
                }
            }
            Range        += bonusRange;
            IsDisplayable = Range > 0;
        }