public JsonResult MapRoute(int map1, float x1, float y1, int map2, float x2, float y2) { isBusy = true; service.SetLocations(service.GetWorldLocation(map1, x1, y1), service.GetWorldLocation(map2, x2, y2)); var path = service.DoSearch(PatherPath.Graph.PathGraph.eSearchScoreSpot.A_Star_With_Model_Avoidance); var worldLocations = path == null ? new List <WorldMapAreaSpot>() : path.locations.Select(s => service.ToMapAreaSpot(s.X, s.Y, s.Z, map1)); isBusy = false; return(new JsonResult(worldLocations, new JsonSerializerOptions { WriteIndented = true })); }
public JsonResult MapRoute(int map1, float x1, float y1, int map2, float x2, float y2) { service.SetLocations(service.GetWorldLocation(map1, x1, y1), service.GetWorldLocation(map2, x2, y2)); var path = service.DoSearch(PatherPath.Graph.PathGraph.eSearchScoreSpot.A_Star_With_Model_Avoidance); //return new JsonResult(path.locations, new JsonSerializerOptions //{ // WriteIndented=true //}); var worldLocations = path == null ? new List <WorldMapAreaSpot>() : path.locations.Select(s => service.ToMapAreaSpot(s.X, s.Y, s.Z, map1)); return(new JsonResult(worldLocations)); //return Newtonsoft.Json.JsonConvert.SerializeObject(worldLocations); }
public async Task <List <WowPoint> > FindRoute(int map, WowPoint fromPoint, WowPoint toPoint) { if (!Enabled) { logger.LogWarning($"Pathing is disabled, please check the messages when the bot started."); return(new List <WowPoint>()); } await Task.Delay(0); var sw = new Stopwatch(); sw.Start(); service.SetLocations(service.GetWorldLocation(map, (float)fromPoint.X, (float)fromPoint.Y), service.GetWorldLocation(map, (float)toPoint.X, (float)toPoint.Y)); var path = service.DoSearch(PatherPath.Graph.PathGraph.eSearchScoreSpot.A_Star_With_Model_Avoidance); if (path == null) { logger.LogWarning($"LocalPathingApi: Failed to find a path from {fromPoint} to {toPoint}"); return(new List <WowPoint>()); } else { logger.LogInformation($"Finding route from {fromPoint} map {map} to {toPoint} took {sw.ElapsedMilliseconds} ms."); } var worldLocations = path.locations.Select(s => service.ToMapAreaSpot(s.X, s.Y, s.Z, map)); var result = worldLocations.Select(l => new WowPoint(l.X, l.Y)).ToList(); return(result); }