Package com.valhalla.sdk.api.pathing
Class CollisionMap
java.lang.Object
com.valhalla.sdk.api.pathing.CollisionMap
A normalized, immutable local collision grid independent of client-specific flag values.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intBlocks movement through the tile's east edge.static final intBlocks movement through the tile's north edge.static final intBlocks movement through the tile's south edge.static final intBlocks occupation of the entire tile.static final intBlocks movement through the tile's west edge. -
Constructor Summary
ConstructorsConstructorDescriptionCollisionMap(Tile base, int width, int height, int[] flags) Creates a defensive collision snapshot. -
Method Summary
Modifier and TypeMethodDescriptionbooleanTests one cardinal or diagonal transition, including reciprocal edge flags.booleanTests whether a tile belongs to this grid.int[]Returns a defensive copy of row-major normalized flags.getBase()Returns the southwest tile represented by this grid.intReads normalized flags for a represented tile.intReturns the grid height in tiles.intgetWidth()Returns the grid width in tiles.booleanTests whether a tile is absent or fully blocked.toString()
-
Field Details
-
BLOCK_NORTH
public static final int BLOCK_NORTHBlocks movement through the tile's north edge.- See Also:
-
BLOCK_EAST
public static final int BLOCK_EASTBlocks movement through the tile's east edge.- See Also:
-
BLOCK_SOUTH
public static final int BLOCK_SOUTHBlocks movement through the tile's south edge.- See Also:
-
BLOCK_WEST
public static final int BLOCK_WESTBlocks movement through the tile's west edge.- See Also:
-
BLOCK_TILE
public static final int BLOCK_TILEBlocks occupation of the entire tile.- See Also:
-
-
Constructor Details
-
CollisionMap
Creates a defensive collision snapshot.- Parameters:
base- southwest tile represented by index zerowidth- positive grid widthheight- positive grid heightflags- row-major normalized flags withwidth * heightentries
-
-
Method Details
-
getBase
Returns the southwest tile represented by this grid.- Returns:
- the southwest tile represented by this grid
-
getWidth
public int getWidth()Returns the grid width in tiles.- Returns:
- the grid width in tiles
-
getHeight
public int getHeight()Returns the grid height in tiles.- Returns:
- the grid height in tiles
-
copyFlags
public int[] copyFlags()Returns a defensive copy of row-major normalized flags.- Returns:
- a defensive copy of row-major normalized flags
-
contains
Tests whether a tile belongs to this grid.- Parameters:
tile- world tile to test- Returns:
truewhen the tile is represented
-
getFlags
Reads normalized flags for a represented tile.- Parameters:
tile- world tile to inspect- Returns:
- normalized collision bit mask
-
isBlocked
Tests whether a tile is absent or fully blocked.- Parameters:
tile- world tile to inspect- Returns:
truewhen the tile cannot be occupied
-
canMove
Tests one cardinal or diagonal transition, including reciprocal edge flags.- Parameters:
from- represented origin tileto- adjacent destination tile- Returns:
truewhen normalized collision permits the transition
-
toString
-