context: using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using LeagueSharp;
  using LeagueSharp.Common;
  using SharpDX;
  using Color = System.Drawing.Color;
  using GamePath = System.Collections.Generic.List<SharpDX.Vector2>;
  
  using myWorld.Library.MenuWarpper;
  
  using EloBuddy; 
   using LeagueSharp.Common; 
   namespace myWorld.Library.SimpleEvade
  {
      public enum SkillShotType
      {
          SkillshotCircle,
          SkillshotLine,
          SkillshotMissileLine,
          SkillshotCone,
          SkillshotMissileCone,
          SkillshotRing,
          SkillshotArc,
      }
  
      public enum DetectionType
      {
          RecvPacket,
          ProcessSpell,
      }
  
      public struct SafePathResult
      {
          public FoundIntersection Intersection;
          public bool IsSafe;
  
          public SafePathResult(bool isSafe, FoundIntersection intersection)
          {
              IsSafe = isSafe;
              Intersection = intersection;
          }
      }
  
      public struct FoundIntersection
      {
          public Vector2 ComingFrom;
          public float Distance;
          public Vector2 Point;
          public int Time;
          public bool Valid;
  
          public FoundIntersection(float distance, int time, Vector2 point, Vector2 comingFrom)
          {
              Distance = distance;
              ComingFrom = comingFrom;
              Valid = (point.X != 0) && (point.Y != 0);
              Point = point + Config.GridSize * (ComingFrom - point).Normalized();
              Time = time;
          }
      }
  
  
      public class Skillshot
      {
          public Geometry.Circle Circle;
          public DetectionType DetectionType;
          public Vector2 Direction;
          public Geometry.Polygon DrawingPolygon;
  
          public Vector2 End;
  
          public bool ForceDisabled;
          public Vector2 MissilePosition;
          public Geometry.Polygon Polygon;
          public Geometry.Rectangle Rectangle;
          public Geometry.Ring Ring;
          public Geometry.Arc Arc;
          public Geometry.Sector Sector;
  
          public SpellData SpellData;
          public Vector2 Start;
          public int StartTick;
          private int _helperTick;
  
          private bool _cachedValue;
          private int _cachedValueTick;
          private Vector2 _collisionEnd;
          private int _lastCollisionCalc;
          private int RandomValue = 1;
  
          public Skillshot(DetectionType detectionType,
              SpellData spellData,
              int startT,
              Vector2 start,
              Vector2 end,
              Obj_AI_Base unit)
          {
              DetectionType = detectionType;
              SpellData = spellData;
              StartTick = startT;
              Start = start;
              End = end;
              MissilePosition = start;
              Direction = (end - start).Normalized();
  
              Unit = unit;
  
              SetRandomValue();
  
              //Create the spatial object for each type of skillshot.
              switch (spellData.Type)
              {
                  case SkillShotType.SkillshotCircle:
                      Circle = new Geometry.Circle(CollisionEnd, spellData.Radius);
                      break;
                  case SkillShotType.SkillshotLine:
                      Rectangle = new Geometry.Rectangle(Start, CollisionEnd, spellData.Radius);
                      break;
                  case SkillShotType.SkillshotMissileLine:
                      Rectangle = new Geometry.Rectangle(Start, CollisionEnd, spellData.Radius);
                      break;
                  case SkillShotType.SkillshotCone:
                      Sector = new Geometry.Sector(
                          start, CollisionEnd - start, spellData.Radius * (float)Math.PI / 180, spellData.Range);
                      break;
                  case SkillShotType.SkillshotRing:
                      Ring = new Geometry.Ring(CollisionEnd, spellData.Radius, spellData.RingRadius);
                      break;
                  case SkillShotType.SkillshotArc:
                      Arc = new Geometry.Arc(start, end, Config.SkillShotsExtraRadius + (int)ObjectManager.Player.BoundingRadius);
                      break;
              }
  
              UpdatePolygon(); //Create the polygon.
          }
  
          public Vector2 Perpendicular
          {
              get { return Direction.Perpendicular(); }
          }
  
          public Vector2 CollisionEnd
          {
              get
              {
                  if (_collisionEnd.IsValid())
                  {
                      return _collisionEnd;
                  }
  
                  if (IsGlobal)
                  {
                      return GlobalGetMissilePosition(0) +
                             Direction * SpellData.MissileSpeed *
                             (0.5f + SpellData.Radius * 2 / ObjectManager.Player.MoveSpeed);
                  }
  
                  return End;
              }
          }
  
          public bool IsGlobal
          {
              get { return SpellData.RawRange == 20000; }
          }
  
          public Geometry.Polygon EvadePolygon { get; set; }
          public Geometry.Polygon PathFindingPolygon { get; set; }
          public Geometry.Polygon PathFindingInnerPolygon { get; set; }
  
          public Obj_AI_Base Unit { get; set; }
  
          /// <summary>
          /// Returns the value from this skillshot menu.
          /// </summary>
          public T GetValue<T>(string name)
          {
              return Config.Menu.Item(name + SpellData.MenuItemName).GetValue<T>();
          }
  
          public int GetDangerPoint()
          {
              if (Config.Menu.Item("ChooseMode").GetValue<KeyBind>().Active)
              {
                  if (Config.Menu.Item("DangerLevel" + SpellData.MenuItemName).GetValue<Slider>().Value <= RandomValue && ObjectManager.Player.IsHPLow(Config.Menu.GetSlice("ChaseMode.MinHP")))
                  {
                      return 0;
  
                  }
                  else
                  {
                      return Config.Menu.Item("DangerLevel" + SpellData.MenuItemName).GetValue<Slider>().Value;
                  }
              }
              else
              {
                  return Config.Menu.Item("DangerLevel" + SpellData.MenuItemName).GetValue<Slider>().Value;
              }
          }
  
          /// <summary>
          /// Returns if the skillshot has expired.
          /// </summary>
          public bool IsActive()
          {
  
gt:             if (SpellData.MissileAccel != 0)