fBaseXtensions.Game.Hero.Class.PlayerClass.DestructibleAbility C# (CSharp) Method

DestructibleAbility() private method

Returns Ability used for destructibles
private DestructibleAbility ( ) : Skill
return fBaseXtensions.Game.Hero.Skills.Skill
        internal virtual Skill DestructibleAbility()
        {
            Skill returnAbility = FunkyGame.Hero.Class.DefaultAttack;
            List<Skill> nonDestructibleAbilities = new List<Skill>();
            foreach (var item in Abilities.Values)
            {
                if (item.IsDestructiblePower)
                {

                    //Check LOS -- Projectiles
                    if (item.IsRanged && !FunkyGame.Targeting.Cache.CurrentTarget.IgnoresLOSCheck)
                    {
                        LOSInfo LOSINFO = FunkyGame.Targeting.Cache.CurrentTarget.LineOfSight;
                        if (LOSINFO.LastLOSCheckMS > 3000)
                        {
                            if (!LOSINFO.LOSTest(FunkyGame.Hero.Position, true, ServerObjectIntersection: false))
                            {
                                //Raycast failed.. reset LOS Check -- for valid checking.
                                if (!LOSINFO.RayCast.Value) FunkyGame.Targeting.Cache.CurrentTarget.RequiresLOSCheck = true;
                                continue;
                            }
                        }
                    }

                    if (item.CheckPreCastConditionMethod())
                    {
                        returnAbility = item;
                        Skill.SetupAbilityForUse(ref returnAbility, FunkyGame.Targeting.Cache.CurrentTarget, true);
                        return returnAbility;
                    }
                }

                else if (ObjectCache.CheckFlag(item.ExecutionType, SkillExecutionFlags.Target) || ObjectCache.CheckFlag(item.ExecutionType, SkillExecutionFlags.Location))
                {

                    //Check LOS -- Projectiles
                    if (item.IsRanged && !FunkyGame.Targeting.Cache.CurrentTarget.IgnoresLOSCheck)
                    {
                        LOSInfo LOSINFO = FunkyGame.Targeting.Cache.CurrentTarget.LineOfSight;
                        if (LOSINFO.LastLOSCheckMS > 3000 || (item.IsProjectile && !LOSINFO.ObjectIntersection.HasValue) || !LOSINFO.NavCellProjectile.HasValue)
                        {
                            if (!LOSINFO.LOSTest(FunkyGame.Hero.Position, NavRayCast: true, ServerObjectIntersection: item.IsProjectile, Flags: NavCellFlags.AllowProjectile))
                            {
                                //Raycast failed.. reset LOS Check -- for valid checking.
                                if (!LOSINFO.RayCast.Value) FunkyGame.Targeting.Cache.CurrentTarget.RequiresLOSCheck = true;
                                continue;
                            }
                        }
                        else if ((item.IsProjectile && LOSINFO.ObjectIntersection.Value) || !LOSINFO.NavCellProjectile.Value)
                        {
                            continue;
                        }
                    }

                    //Add this Ability to our list.. incase we cant find an offical Ability to use.
                    if (item.CheckPreCastConditionMethod())
                    {
                        nonDestructibleAbilities.Add(item);
                    }
                }
            }

            //Use non-destructible Ability..
            if (nonDestructibleAbilities.Count > 0)
                returnAbility = nonDestructibleAbilities[0];

            Skill.SetupAbilityForUse(ref returnAbility, FunkyGame.Targeting.Cache.CurrentTarget, true);
            return returnAbility;
        }