Class CollisionMap
- java.lang.Object
-
- org.dreambot.api.wrappers.map.impl.CollisionMap
-
-
Constructor Summary
Constructors Constructor Description CollisionMap(java.lang.Object reference)
Note: This shouldn't be used by API users, it's an internal constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getBaseX()
Returns the base X coordinate for this collision map.int
getBaseY()
Returns the base Y coordinate for this collision map.float
getCost(int sx, int sy, int tx, int ty)
Get the cost of moving through the given tile.int
getDirection(int x, int y)
Retrieves the direction of the given x-y coordinates as a CollisionMap Flag.int
getFlag(int gridX, int gridY)
Gets collision flag for the given grid location.int[][]
getFlags()
Get the tile flags for this collision map.int
getHeight()
Gets height.Tile
getOffset()
Returns the collision map offset tile (UsesgetOffsetX()
andgetOffsetY()
)int
getOffsetX()
Gets offset x.int
getOffsetY()
Gets offset y.int
getWidth()
Gets width of the collision map.static boolean
isBlocked(int flag)
Determines if given tile flag represents a blocked/non-walkable tile.boolean
isBlocked(int x, int y, int direction)
Is blocked.static boolean
isCardinalDirectionBlocked(int cardinal, int flag, int neighbor)
Determines if the cardinal direction of your choice is blocked.static boolean
isOrdinalDirectionBlocked(int ordinal, int ne, int nw, int se, int sw)
Is ordinal direction blocked.boolean
isSolid(int x, int y)
Check if the given location is blocked, i.values.boolean
isSolid(int x, int y, int flag)
Check if the given location is blocked, i.values.boolean
isWalkable(int x1, int y1, int x2, int y2)
Check if the given location is walkable, i.values.boolean
isWalkable(int x1, int y1, int x2, int y2, int flag)
Check if the given location is walkable, i.values.void
visit(int x, int y)
Notification that the path finder visited a given tile.
-
-
-
Method Detail
-
isBlocked
public static boolean isBlocked(int flag)
Determines if given tile flag represents a blocked/non-walkable tile.- Parameters:
flag
- the flag of the given tile to check- Returns:
- true if the tile is blocked, and cannot be walked on; otherwise false.
-
isCardinalDirectionBlocked
public static boolean isCardinalDirectionBlocked(int cardinal, int flag, int neighbor)
Determines if the cardinal direction of your choice is blocked. The four Cardinal direction include: • North • East • South • West- Parameters:
cardinal
- the cardinal direction to check. (Use corresponding flag fromTileFlags
)flag
- the flagneighbor
- the neighbor- Returns:
- the boolean
-
isOrdinalDirectionBlocked
public static boolean isOrdinalDirectionBlocked(int ordinal, int ne, int nw, int se, int sw)
Is ordinal direction blocked.- Parameters:
ordinal
- the ordinalne
- the nenw
- the nwse
- the sesw
- the sw- Returns:
- the boolean
-
getBaseX
public int getBaseX()
Returns the base X coordinate for this collision map.
-
getBaseY
public int getBaseY()
Returns the base Y coordinate for this collision map.
-
getHeight
public int getHeight()
Gets height.
-
getOffsetX
public int getOffsetX()
Gets offset x.- Returns:
- the offset x
-
getOffsetY
public int getOffsetY()
Gets offset y.- Returns:
- the offset y
-
getOffset
public Tile getOffset()
Returns the collision map offset tile (UsesgetOffsetX()
andgetOffsetY()
)- Returns:
- the collision map offset tile.
-
getWidth
public int getWidth()
Gets width of the collision map.
-
getFlags
public int[][] getFlags()
Get the tile flags for this collision map.- Returns:
- the 2D array of tile flags.
-
getFlag
public int getFlag(int gridX, int gridY)
Gets collision flag for the given grid location.
-
isBlocked
public boolean isBlocked(int x, int y, int direction)
Is blocked.- Parameters:
x
- the xy
- the ydirection
- the direction- Returns:
- the boolean
-
isSolid
public boolean isSolid(int x, int y)
Check if the given location is blocked, i.values. blocks movement of the supplied mover.
-
isSolid
public boolean isSolid(int x, int y, int flag)
Check if the given location is blocked, i.values. blocks movement of the supplied mover.
-
getCost
public float getCost(int sx, int sy, int tx, int ty)
Get the cost of moving through the given tile. This can be used to make certain areas more desirable. A simple and valid implementation of this method would be to return 1 in all cases.- Specified by:
getCost
in interfaceTileMap
- Parameters:
sx
- The x coordinate of the tile we're moving fromsy
- The y coordinate of the tile we're moving fromtx
- The x coordinate of the tile we're moving toty
- The y coordinate of the tile we're moving to- Returns:
- The relative cost of moving across the given tile
-
visit
public void visit(int x, int y)
Notification that the path finder visited a given tile. This is used for debugging new heuristics.
-
isWalkable
public boolean isWalkable(int x1, int y1, int x2, int y2)
Check if the given location is walkable, i.values. no blocked movement.- Specified by:
isWalkable
in interfaceTileMap
- Parameters:
x1
- The x coordinate of the start tile to checky1
- The y coordinate of the start tile to checkx2
- The x coordinate of the destination tile to checky2
- The y coordinate of the destination tile to check- Returns:
- true, if the destination is walkable.
-
isWalkable
public boolean isWalkable(int x1, int y1, int x2, int y2, int flag)
Check if the given location is walkable, i.values. no blocked movement.- Specified by:
isWalkable
in interfaceTileMap
- Parameters:
x1
- The x coordinate of the start tile to checky1
- The y coordinate of the start tile to checkx2
- The x coordinate of the destination tile to checky2
- The y coordinate of the destination tile to checkflag
- The flag of the destination tile to check- Returns:
- true, if the destination is walkable.
-
getDirection
public int getDirection(int x, int y)
Retrieves the direction of the given x-y coordinates as a CollisionMap Flag.- Specified by:
getDirection
in interfaceTileMap
- Parameters:
x
- The x coordinatey
- The y coordinate
-
-