AkaCore.Manager.EvadeManager.EvadeSkillshot.TryToEvade C# (CSharp) Method

TryToEvade() private static method

private static TryToEvade ( List hitBy, System.Vector2 to ) : void
hitBy List
to System.Vector2
return void
            private static void TryToEvade(List<Skillshot> hitBy, Vector2 to)
            {
                var dangerLevel =
                    hitBy.Select(i => Manager.MenuManager.EDLVL.Cast<Slider>().CurrentValue) //championmenu["DangerLevel"].Cast<Slider>().CurrentValue
                        .Concat(new[] { 0 })
                        .Max();
                foreach (var evadeSpell in
                    EvadeSpellDatabase.Spells.Where(i => i.Enabled && i.DangerLevel <= dangerLevel && i.IsReady)
                        .OrderBy(i => i.DangerLevel))
                {
                    if (evadeSpell.EvadeType == EvadeTypes.Dash && evadeSpell.CastType == CastTypes.Target)
                    {
                        var targets =
                            GetEvadeTargets(evadeSpell)
                                .Where(
                                    i =>
                                    IsSafePoint(Extensions.PosAfterE(i).To2D()).IsSafe
                                    && (!Extensions.PosAfterE(i).IsUnderTurret()) || Manager.MenuManager.EvadeMenu["ETower"].Cast<CheckBox>().CurrentValue)
                                .ToList();
                        if (targets.Count > 0)
                        {
                            var closestTarget = targets.MinOrDefault(i => Extensions.PosAfterE(i).To2D().Distance(to));
                            ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, closestTarget);
                            return;
                        }
                    }
                    if (evadeSpell.EvadeType == EvadeTypes.WindWall
                        && hitBy.Where(
                            i =>
                            i.SpellData.CollisionObjects.Contains(CollisionObjectTypes.YasuoWall)
                            && i.IsAboutToHit(
                                150 + evadeSpell.Delay - Manager.MenuManager.EvadeMenu["WDelay"].Cast<Slider>().CurrentValue,
                                ObjectManager.Player))
                               .OrderByDescending(
                                   i => Manager.MenuManager.EDLVL.Cast<Slider>().CurrentValue)
                               .Any(
                                   i =>
                                   ObjectManager.Player.Spellbook.CastSpell(
                                       evadeSpell.Slot,
                                       ObjectManager.Player.ServerPosition.Extend(i.Start.To3D(), 100).To3D(), true)))
                    {
                        return;
                    }
                    if (evadeSpell.EvadeType == EvadeTypes.Dash && evadeSpell.CastType == CastTypes.Position)
                    {
                        var points = GetEvadePoints(evadeSpell.Speed, evadeSpell.Delay, false);

                        points.RemoveAll(
                            item => item.Distance(ObjectManager.Player.ServerPosition) > evadeSpell.MaxRange);

                        if (evadeSpell.FixedRange)
                        {
                            for (var i = 0; i < points.Count; i++)
                            {
                                points[i] = ObjectManager.Player.Position
                                    .Extend(points[i], evadeSpell.MaxRange);
                            }

                            for (var i = points.Count - 1; i > 0; i--)
                            {
                                if (!IsSafePoint(points[i]).IsSafe)
                                {
                                    points.RemoveAt(i);
                                }
                            }
                        }

                        if (points.Count > 0)
                        {
                            var EvadePoint = to.Closest(points);

                            var castPoint = ObjectManager.Player.Position -
                                            (EvadePoint.To3D() - ObjectManager.Player.Position);
                            ObjectManager.Player.Spellbook.CastSpell(evadeSpell.Slot, castPoint);
                        }

                        return;
                    }
                }
            }