public static List <Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, int[] limits, int x1, int y1, int x2, int y2, bool flag) { heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic); lock (finderLazy) { if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10) { finderLazy.Clear(); } int key = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag); List <Vector2f> result = (List <Vector2f>)CollectionUtils.Get(finderLazy, key); if (result == null) { AStarFinder astar = new AStarFinder(heuristic); Field2D fieldMap = new Field2D(maps); if (limits != null) { fieldMap.SetLimit(limits); } Vector2f start = new Vector2f(x1, y1); Vector2f over = new Vector2f(x2, y2); result = astar.Calc(fieldMap, start, over, flag); CollectionUtils.Put(finderLazy, key, result); astar.Dispose(); } if (result != null) { List <Vector2f> newResult = new List <Vector2f>(); CollectionUtils.AddAll(newResult, result); result = newResult; } return(result); } }
public static List<Vector2f> Find(AStarFindHeuristic heuristic, int[][] maps, int[] limits, int x1, int y1, int x2, int y2, bool flag) { heuristic = ((heuristic == null) ? ASTAR_MANHATTAN : heuristic); lock (finderLazy) { if (finderLazy.Count >= LSystem.DEFAULT_MAX_CACHE_SIZE * 10) { finderLazy.Clear(); } int key = MakeLazyKey(heuristic, maps, limits, x1, y1, x2, y2, flag); List<Vector2f> result = (List<Vector2f>)CollectionUtils.Get(finderLazy, key); if (result == null) { AStarFinder astar = new AStarFinder(heuristic); Field2D fieldMap = new Field2D(maps); if (limits != null) { fieldMap.SetLimit(limits); } Vector2f start = new Vector2f(x1, y1); Vector2f over = new Vector2f(x2, y2); result = astar.Calc(fieldMap, start, over, flag); CollectionUtils.Put(finderLazy, key, result); astar.Dispose(); } if (result != null) { List<Vector2f> newResult = new List<Vector2f>(); CollectionUtils.AddAll(newResult, result); result = newResult; } return result; } }
public void SetLimit(int[] limit) { field.SetLimit(limit); }