private void CacheSkillshots() { Skillshots = (DodgeDangerousOnly ? SkillshotDetector.ActiveSkillshots.Where(c => c.SpellData.IsDangerous) : SkillshotDetector.ActiveSkillshots).ToArray(); _skillshotPolygonCache.Clear(); Polygons = Skillshots.Select(c => { var pol = c.ToPolygon(); _skillshotPolygonCache.Add(c, pol); return(pol); }).ToArray(); ClippedPolygons = Geometry.ClipPolygons(Polygons).ToPolygons(); }
public List <Geometry.Polygon> CustomPoly() { Skillshots = (DodgeDangerousOnly ? SkillshotDetector.ActiveSkillshots.Where(c => c.SpellData.IsDangerous && EvadeMenu.IsSkillshotE(c) && Environment.TickCount - c.TimeDetected >= Yasuo.FleeMenu["Evade.WDelay"].Cast <Slider>().CurrentValue) : SkillshotDetector.ActiveSkillshots).ToArray(); _skillshotPolygonCache.Clear(); Polygons = Skillshots.Select(c => { var pol = c.ToPolygon(); _skillshotPolygonCache.Add(c, pol); return(pol); }).ToArray(); return(Geometry.ClipPolygons(Polygons).ToPolygons()); }
private void CacheSkillshots() { Skillshots = (DodgeDangerousOnly ? SkillshotDetector.ActiveSkillshots.Where(c => c.OwnSpellData.IsDangerous) : SkillshotDetector.ActiveSkillshots).ToArray(); _skillshotPolygonCache.Clear(); Polygons = Skillshots.Select(c => { Geometry.Polygon pol; if (c.OwnSpellData.IsVeigarE) { var skill = c as VeigarE; var inner = skill.ToInnerPolygon(); var outer = skill.ToOuterPolygon(); if (!skill.IsSafe()) { pol = outer; } else { pol = inner.IsInside(Player.Instance) ? inner : outer; } } else { pol = c.ToPolygon(); } _skillshotPolygonCache.Add(c, pol); return(pol); }).ToArray(); ClippedPolygons = Geometry.ClipPolygons(Polygons).ToPolygons(); }
public Vector2[] GetPath(Vector2 start, Vector2 end) { const int extraWidth = 50; var walkPolygons = Geometry.ClipPolygons(Skillshots.Select(c => c.ToPolygon(extraWidth))).ToPolygons(); //if (walkPolygons.Any(pol => pol.IsInside(start))) //{ // Chat.Print("start"); // var polPoints = // Geometry.ClipPolygons( // SkillshotDetector.DetectedSkillshots.Where(c => c.IsValid) // .Select(c => c.ToPolygon(extraWidth)) // .ToList()) // .ToPolygons() // .Where(pol => pol.IsInside(start)) // .SelectMany(pol => pol.Points) // .ToList(); // polPoints.Sort((p1, p2) => p1.Distance(start, true).CompareTo(p2.Distance(start, true))); // start = polPoints.First().Extend(start, -150); //} if (walkPolygons.Any(pol => pol.IsInside(end))) { var polPoints = Geometry.ClipPolygons( SkillshotDetector.DetectedSkillshots.Where(c => c.IsValid) .Select(c => c.ToPolygon(extraWidth)) .ToList()) .ToPolygons() .Where(pol => pol.IsInside(end)) .SelectMany(pol => pol.Points) .ToList(); polPoints.Sort((p1, p2) => p1.Distance(end, true).CompareTo(p2.Distance(end, true))); end = polPoints.First().Extend(end, -extraWidth); } var ritoPath = Player.Instance.GetPath(end.To3DWorld(), true).ToArray().ToVector2().ToList(); //Player.Instance.GetPath(start.To3DWorld(), end.To3DWorld()).ToArray().ToVector2().ToList(); var pathPoints = new List <Vector2>(); var polygonDictionary = new Dictionary <Vector2, Geometry.Polygon>(); for (var i = 0; i < ritoPath.Count - 1; i++) { var lineStart = ritoPath[i]; var lineEnd = ritoPath[i + 1]; foreach (var pol in walkPolygons) { var intersectionPoints = pol.GetIntersectionPointsWithLineSegment(lineStart, lineEnd); foreach (var p in intersectionPoints) { if (!polygonDictionary.ContainsKey(p)) { polygonDictionary.Add(p, pol); pathPoints.Add(p); } } } } ritoPath.RemoveAll(p => walkPolygons.Any(pol => pol.IsInside(p))); pathPoints.AddRange(ritoPath); pathPoints.SortPath(Player.Instance.ServerPosition.To2D()); //start var path = new List <Vector2>(); while (pathPoints.Count > 0) { if (pathPoints.Count == 1) { path.Add(pathPoints[0]); break; } var current = pathPoints[0]; var next = pathPoints[1]; Geometry.Polygon pol1; Geometry.Polygon pol2; if (polygonDictionary.TryGetValue(current, out pol1) && polygonDictionary.TryGetValue(next, out pol2) && pol1.Equals(pol2)) { var detailedPolygon = pol1.ToDetailedPolygon(); detailedPolygon.Points.Sort( (p1, p2) => p1.Distance(current, true).CompareTo(p2.Distance(current, true))); current = detailedPolygon.Points.First(); detailedPolygon.Points.Sort((p1, p2) => p1.Distance(next, true).CompareTo(p2.Distance(next, true))); next = detailedPolygon.Points.First(); detailedPolygon = pol1.ToDetailedPolygon(); var index = detailedPolygon.Points.FindIndex(p => p == current); var linkedList = new LinkedList <Vector2>(detailedPolygon.Points, index); var nextPath = new List <Vector2>(); var previousPath = new List <Vector2>(); var nextLength = 0F; var previousLength = 0F; var nextWall = false; var previousWall = false; while (true) { var c = linkedList.Next(); if (c.IsWall()) { nextWall = true; break; } nextPath.Add(c); if (nextPath.Count > 1) { nextLength += nextPath[nextPath.Count - 2].Distance(c, true); } if (c == next) { break; } } linkedList.Index = index; while (true) { var c = linkedList.Previous(); if (c.IsWall()) { previousWall = true; break; } previousPath.Add(c); if (previousPath.Count > 1) { previousLength += previousPath[previousPath.Count - 2].Distance(c, true); } if (c == next) { break; } } var shortest = nextWall && previousWall ? (nextLength > previousLength ? nextPath : previousPath) : (nextWall || previousWall ? (nextWall ? previousPath : nextPath) : nextLength < previousLength ? nextPath : previousPath); path.AddRange(shortest); if (previousWall && nextWall) { break; } } else { path.Add(current); path.Add(next); } pathPoints.RemoveRange(0, 2); } return(path.ToArray()); }