Class CollisionMap

java.lang.Object
com.valhalla.sdk.api.pathing.CollisionMap

public final class CollisionMap extends Object
A normalized, immutable local collision grid independent of client-specific flag values.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Blocks movement through the tile's east edge.
    static final int
    Blocks movement through the tile's north edge.
    static final int
    Blocks movement through the tile's south edge.
    static final int
    Blocks occupation of the entire tile.
    static final int
    Blocks movement through the tile's west edge.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CollisionMap(Tile base, int width, int height, int[] flags)
    Creates a defensive collision snapshot.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    canMove(Tile from, Tile to)
    Tests one cardinal or diagonal transition, including reciprocal edge flags.
    boolean
    contains(Tile tile)
    Tests whether a tile belongs to this grid.
    int[]
    Returns a defensive copy of row-major normalized flags.
    Returns the southwest tile represented by this grid.
    int
    getFlags(Tile tile)
    Reads normalized flags for a represented tile.
    int
    Returns the grid height in tiles.
    int
    Returns the grid width in tiles.
    boolean
    Tests whether a tile is absent or fully blocked.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • BLOCK_NORTH

      public static final int BLOCK_NORTH
      Blocks movement through the tile's north edge.
      See Also:
    • BLOCK_EAST

      public static final int BLOCK_EAST
      Blocks movement through the tile's east edge.
      See Also:
    • BLOCK_SOUTH

      public static final int BLOCK_SOUTH
      Blocks movement through the tile's south edge.
      See Also:
    • BLOCK_WEST

      public static final int BLOCK_WEST
      Blocks movement through the tile's west edge.
      See Also:
    • BLOCK_TILE

      public static final int BLOCK_TILE
      Blocks occupation of the entire tile.
      See Also:
  • Constructor Details

    • CollisionMap

      public CollisionMap(Tile base, int width, int height, int[] flags)
      Creates a defensive collision snapshot.
      Parameters:
      base - southwest tile represented by index zero
      width - positive grid width
      height - positive grid height
      flags - row-major normalized flags with width * height entries
  • Method Details

    • getBase

      public Tile 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

      public boolean contains(Tile tile)
      Tests whether a tile belongs to this grid.
      Parameters:
      tile - world tile to test
      Returns:
      true when the tile is represented
    • getFlags

      public int getFlags(Tile tile)
      Reads normalized flags for a represented tile.
      Parameters:
      tile - world tile to inspect
      Returns:
      normalized collision bit mask
    • isBlocked

      public boolean isBlocked(Tile tile)
      Tests whether a tile is absent or fully blocked.
      Parameters:
      tile - world tile to inspect
      Returns:
      true when the tile cannot be occupied
    • canMove

      public boolean canMove(Tile from, Tile to)
      Tests one cardinal or diagonal transition, including reciprocal edge flags.
      Parameters:
      from - represented origin tile
      to - adjacent destination tile
      Returns:
      true when normalized collision permits the transition
    • toString

      public String toString()
      Overrides:
      toString in class Object