Class PathFinder<T extends Locatable>
- java.lang.Object
-
- org.dreambot.api.methods.walking.pathfinding.impl.PathFinder<T>
-
- Direct Known Subclasses:
LocalPathFinder
public abstract class PathFinder<T extends Locatable> extends java.lang.Object
A base PathFinder class for local pathfinders like ourLocalPathFinder
This class generally doesn't need to be used if you're just trying to walk, see
Walking.walk(Tile)
insteadFor global pathfinding across regions, see
WebFinder
instead
-
-
Constructor Summary
Constructors Constructor Description PathFinder(int maxDepth)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addBlacklistedTile(Tile tile)
This will add a tile to not be allowed in the final LocalPath calculated.void
addObstacle(PathObstacle obstacle)
Adds an obstacle to the available obstacle choices listvoid
addTileCondition(Tile tile, Condition c)
void
addWebOnlyObstacleTile(Tile tile)
Adds a tile for the local walker to ignore obstaclesAbstractPath<T>
calculate(int x1, int y1, int x2, int y2)
Calculate a walkable abstract path from the start tile location (sx, sy) to the destination tile location (dx, dy), using data provided by the tile map.AbstractPath<T>
calculate(int x1, int y1, int x2, int y2, int z)
Calculate a walkable abstract path from the start tile location (x1, y1,z) to the destination tile location (x2, y2,z), using data provided by the tile map.abstract AbstractPath<T>
calculate(int x1, int y1, int z1, int x2, int y2, int z2)
Calculates an AbstractPath from the start location (x1,y1,z1) to the destination tile location (x2,y2,z2)AbstractPath<T>
calculate(Tile start, Tile end)
Calculates a path from the start tile to the end tileboolean
checkTileCondition(Tile tile)
void
clearBlacklist()
void
clearTileConditions()
java.util.Set<Tile>
getBlacklistedTiles()
java.lang.String
getDirection(int sx, int sy, int ex, int ey)
float
getMovementCost(int sx, int sy, int ex, int ey, int z)
PathNode
getNode(int x, int y, int z)
PathObstacle
getObstacle(int x, int y, int z, int dir)
boolean
hasObstacle(int x, int y, int z, int dir)
boolean
isBlacklisted(Tile t)
boolean
isDirWall(java.lang.String dir, int flag)
boolean
isInPossibleObstacles(GameObject object)
boolean
isTileWebOnly(Tile tile)
void
onWebNodeVersionUpdate()
void
removeBlacklistedTile(Tile t)
void
removeObstacle(PathObstacle obstacle)
Removes the obstacle from the available obstaclesvoid
removeTileCondition(Tile tile)
void
removeWebOnlyObstacleTile(Tile tile)
Removes a tile from the web only obstacle tile listvoid
reset()
-
-
-
Method Detail
-
addBlacklistedTile
public void addBlacklistedTile(Tile tile)
This will add a tile to not be allowed in the final LocalPath calculated.Note: This method does not stop the walker from walking through it, only the paths we calculate.
- Parameters:
tile
- the tile to blacklist
-
removeBlacklistedTile
public void removeBlacklistedTile(Tile t)
-
isBlacklisted
public boolean isBlacklisted(Tile t)
-
clearBlacklist
public void clearBlacklist()
-
calculate
public AbstractPath<T> calculate(Tile start, Tile end)
Calculates a path from the start tile to the end tile- Parameters:
start
- start Tileend
- end Tile- Returns:
- a valid path with at least one tile, or an empty path if we were unable to find a valid path
-
calculate
public AbstractPath<T> calculate(int x1, int y1, int x2, int y2)
Calculate a walkable abstract path from the start tile location (sx, sy) to the destination tile location (dx, dy), using data provided by the tile map. Assumes z coordinate is 0- Parameters:
x1
- the starting grid X coordinate.y1
- the starting grid Y coordinate.x2
- the destination grid X coordinate.y2
- the destination grid Y coordinate.- Returns:
- the abstract path from the start to destination if a path is found, if unable to find path it will return null.
-
calculate
public AbstractPath<T> calculate(int x1, int y1, int x2, int y2, int z)
Calculate a walkable abstract path from the start tile location (x1, y1,z) to the destination tile location (x2, y2,z), using data provided by the tile map.- Parameters:
x1
- the starting grid X coordinate.y1
- the starting grid Y coordinate.x2
- the destination grid X coordinate.y2
- the destination grid Y coordinate.z
- the z coordinate- Returns:
- the abstract path from the start to destination if a path is found, if unable to find path it will return null.
-
addObstacle
public void addObstacle(PathObstacle obstacle)
Adds an obstacle to the available obstacle choices listExample usage:
PathObstacle doorObstacle = new PassableObstacle("Big door", "Open"); PathObstacle rockfallObstacle = new DestructableObstacle("Rockfall", "Mine"); LocalPathFinder.getLocalPathFinder().addObstacle(doorObstacle); LocalPathFinder.getLocalPathFinder().addObstacle(rockfallObstacle);
- Parameters:
obstacle
- the obstacle to add
-
removeObstacle
public void removeObstacle(PathObstacle obstacle)
Removes the obstacle from the available obstacles- Parameters:
obstacle
- the obstacle to remove from the pathfinder
-
getMovementCost
public float getMovementCost(int sx, int sy, int ex, int ey, int z)
-
getNode
public PathNode getNode(int x, int y, int z)
-
calculate
public abstract AbstractPath<T> calculate(int x1, int y1, int z1, int x2, int y2, int z2)
Calculates an AbstractPath from the start location (x1,y1,z1) to the destination tile location (x2,y2,z2)- Parameters:
x1
- the starting grid X coordinate.y1
- the starting grid Y coordinate.z1
- the starting grid Z coordinate.x2
- the destination grid X coordinate.y2
- the destination grid Y coordinate.z2
- the destination grid Z coordinate- Returns:
- AbstractPath
-
hasObstacle
public boolean hasObstacle(int x, int y, int z, int dir)
-
getObstacle
public PathObstacle getObstacle(int x, int y, int z, int dir)
-
isInPossibleObstacles
public boolean isInPossibleObstacles(GameObject object)
-
isDirWall
public boolean isDirWall(java.lang.String dir, int flag)
-
getDirection
public java.lang.String getDirection(int sx, int sy, int ex, int ey)
-
addWebOnlyObstacleTile
public void addWebOnlyObstacleTile(Tile tile)
Adds a tile for the local walker to ignore obstacles- Parameters:
tile
- The tile of the obstacle
-
removeWebOnlyObstacleTile
public void removeWebOnlyObstacleTile(Tile tile)
Removes a tile from the web only obstacle tile list- Parameters:
tile
- The tile of the obstacle to be removed
-
isTileWebOnly
public boolean isTileWebOnly(Tile tile)
-
checkTileCondition
public boolean checkTileCondition(Tile tile)
-
clearTileConditions
public void clearTileConditions()
-
removeTileCondition
public void removeTileCondition(Tile tile)
-
onWebNodeVersionUpdate
public void onWebNodeVersionUpdate()
-
reset
public void reset()
-
getBlacklistedTiles
public java.util.Set<Tile> getBlacklistedTiles()
-
-