public Path DoSearch(PathGraph.eSearchScoreSpot searchType) { //create a new path graph if required const int ResetAfterMinutes = 15; if (PathGraph == null || this.continent != locationFrom.Continent || (DateTime.Now - startTime).TotalMinutes >= ResetAfterMinutes) { CreatePathGraph(locationFrom.Continent); } PatherPath.Graph.PathGraph.SearchEnabled = true; // tell the pathgraph which type of search to do PathGraph.searchScoreSpot = searchType; //slow down the search if required. PathGraph.sleepMSBetweenSpots = 0; try { return(PathGraph.CreatePath(locationFrom, locationTo, 5, null)); } catch (Exception ex) { logger.WriteLine(ex.Message); return(null); } }
public MoveResult move() { if (GiveUpIfUnsafe) // fixme { //if (!pather.IsItSafeAt(Me.Target, Me.Location)) // return MoveResult.Unsafe; } if (PathTimeout.IsReady) { MoveAlong = null; } BoogieCore.Log(LogType.System, "[Mover] MoveAlong = {0}", MoveAlong); if (MoveAlong == null) { Location from = new Location(Me.Location); mover.Stop(); Path path = world.CreatePath(from, target, (float)4.5, PPather.radar); //fixme PathTimeout.Reset(); BoogieCore.Log(LogType.System, "[Mover (New)] PathCount = {0}", path.Count()); if (path == null || path.Count() == 0) { //Context.Log("EasyMover: Can not create path . giving up"); mover.MoveRandom(); Thread.Sleep(200); mover.Stop(); return(MoveResult.CantFindPath); } else { //Context.Log("Save path to " + pathfile); //path.Save(pathfile); MoveAlong = new MoveAlonger(pather, path); } } if (MoveAlong != null) { Location from = new Location(Me.Location); BoogieCore.Log(LogType.System, "[Mover ] PathCount = {0}", MoveAlong.path.Count()); if (MoveAlong.path.Count() == 0 || from.GetDistanceTo(target) < (float)5.0) { BoogieCore.Log(LogType.System, "[Mover] Count = 0 or Dist < 5.0"); MoveAlong = null; mover.Stop(); return(MoveResult.GotThere); } else if (!MoveAlong.MoveAlong()) { BoogieCore.Log(LogType.System, "[Mover] Stuck!!"); MoveAlong = null; // got stuck! if (GiveUpIfStuck) { return(MoveResult.Stuck); } } } return(MoveResult.Moving); }
public MoveResult move(double howClose) { if (GiveUpIfUnsafe) { if (!pather.IsItSafeAt(Me.Target, Me.Location)) { return(MoveResult.Unsafe); } } if (PathTimeout.IsReady) { MoveAlong = null; } if (MoveAlong == null) { Location from = new Location(Me.Location); mover.Stop(); Path path = world.CreatePath(from, target, (float)howClose, PPather.radar); PathTimeout.Reset(); if (path == null || path.Count() == 0) { PPather.WriteLine("EasyMover: Can not create path . giving up"); mover.MoveRandom(); Thread.Sleep(200); mover.Stop(); return(MoveResult.CantFindPath); } else { //PPather.WriteLine("Save path to " + pathfile); //path.Save(pathfile); MoveAlong = new MoveAlonger(pather, path); } } if (MoveAlong != null) { Location from = new Location(Me.Location); if (MoveAlong.path.Count() == 0 || from.GetDistanceTo(target) < howClose) { //PPather.WriteLine("Move along used up"); MoveAlong = null; mover.Stop(); return(MoveResult.GotThere); } else if (!MoveAlong.MoveAlong()) { MoveAlong = null; // got stuck! if (GiveUpIfStuck) { return(MoveResult.Stuck); } } } return(MoveResult.Moving); }
public List <Location> Search(Location start, Location end, double tolerance = 5.0) { //var SearchTask = Task.Factory.StartNew<List<PatherPath.Graph.Location>>(() => //{ // return PG.CreatePath(Convert(start), Convert(end), (float)tolerance); //}, TaskCreationOptions.LongRunning); //Task.WaitAll(SearchTask); //var path = SearchTask.Result; var path = PG.CreatePath(Convert(start), Convert(end), (float)tolerance); if (path != null && path.Locations != null) { return(path.Locations.ConvertAll <Location>(new Converter <PathLoc, Location>((loc) => { return Convert(loc); }))); } else { return(null); } }
public Path DoSearch(PathGraph.eSearchScoreSpot searchType) { //create a new path graph if required if (PathGraph == null || this.continent != locationFrom.Continent) { CreatePathGraph(locationFrom.Continent); } PatherPath.Graph.PathGraph.SearchEnabled = true; // tell the pathgraph which type of search to do PathGraph.searchScoreSpot = searchType; //slow down the search if required. PathGraph.sleepMSBetweenSpots = 0; var path = PathGraph.CreatePath(locationFrom, locationTo, 5, null); return(path); }