AStarCollisionMap.Collision.CollisionMap.GetNodeLocationsAroundEdges C# (CSharp) Метод

GetNodeLocationsAroundEdges() публичный Метод

Places nodes around all the edges
public GetNodeLocationsAroundEdges ( ) : CustomArrayList
Результат CustomArrayList
        public CustomArrayList<Point> GetNodeLocationsAroundEdges()
        {
            Boolean previous = CollisionAt(0);
            CustomArrayList<Point> pointList = new CustomArrayList<Point>();
            for (int i = 0; i < dataLength - 1; i++)
            {
                Boolean current = CollisionAt(i);
                if ((int)(i / mapWidth) % VERTICAL_COLLISION_CHECK_SPACING != 0) { continue; }
                // if (i % mapWidth > mapWidth - 15 || i % mapWidth < 15) { continue; }
                if (i % mapWidth == 0) { previous = current; }
                if (current != previous)
                {
                    if (!current && (i + 10 < dataLength) && !CollisionAt(i + 10)) pointList.AddLast(IndexToPoint(i + 10));
                    else if ((i - 10 > -1) && !CollisionAt(i - 10)) pointList.AddLast(IndexToPoint(i - 10));
                }
                previous = current;
            }

            for (int i = 0; i < mapWidth; i += HORIZONTAL_COLLISION_CHECK_SPACING)
            {
                for (int j = 0; j < mapHeight; j++)
                {
                    int index = i + j * mapWidth;
                    Boolean current = CollisionAt(index);
                    // if (index % mapWidth % HORIZONTAL_COLLISION_CHECK_SPACING != 0) { continue; }
                    if (j == 0) previous = current;
                    // if (index % screenWidth > screenWidth - 15 || index % screenWidth < 15) continue;
                    if (current != previous)
                    {
                        if (!current && (index + (10 * mapWidth) < dataLength)
                            && !CollisionAt(index + (10 * mapWidth)))
                            pointList.AddLast(IndexToPoint(index + (10 * mapWidth)));
                        else if ((index - (10 * mapWidth) > -1) && !CollisionAt(index - (10 * mapWidth)))
                            pointList.AddLast(IndexToPoint(index - (10 * mapWidth)));
                    }
                    previous = current;
                }
            }

            // Remove nodes that are closer than NODE_REMOVE_DISTANCE of each other
            for (int i = 0; i < pointList.Count(); i++)
            {
                Point p1 = pointList.ElementAt(i);
                for (int j = 0; j < pointList.Count(); j++)
                {
                    Point p2 = pointList.ElementAt(j);
                    if (p1 != p2 && PathfindingUtil.GetHypoteneuseLength(p1, p2) < NODE_REMOVE_DISTANCE)
                    {
                        pointList.Remove(p1);
                        i--;
                        j--;
                        break;
                    }
                }
            }
            return pointList;
        }