Class CollisionMap

    • Constructor Detail

      • CollisionMap

        public CollisionMap​(java.lang.Object reference)
        Note: This shouldn't be used by API users, it's an internal constructor.
    • 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 from TileFlags)
        flag - the flag
        neighbor - 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 ordinal
        ne - the ne
        nw - the nw
        se - the se
        sw - the sw
        Returns:
        the boolean
      • getBaseX

        public int getBaseX()
        Returns the base X coordinate for this collision map.
        Specified by:
        getBaseX in interface TileMap
        Returns:
        the base X coordinate for this collision map if valid, otherwise -1;
      • getBaseY

        public int getBaseY()
        Returns the base Y coordinate for this collision map.
        Specified by:
        getBaseY in interface TileMap
        Returns:
        the base Y coordinate for this collision map if valid, otherwise -1;
      • getHeight

        public int getHeight()
        Gets height.
        Specified by:
        getHeight in interface TileMap
        Returns:
        the 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 (Uses getOffsetX() and getOffsetY())
        Returns:
        the collision map offset tile.
      • getWidth

        public int getWidth()
        Gets width of the collision map.
        Specified by:
        getWidth in interface TileMap
        Returns:
        the 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.
        Specified by:
        getFlag in interface TileMap
        Parameters:
        gridX - the x coordinate on the grid.
        gridY - the y coordinate on the grid.
        Returns:
        the collision flag for the given tile.
      • isBlocked

        public boolean isBlocked​(int x,
                                 int y,
                                 int direction)
        Is blocked.
        Parameters:
        x - the x
        y - the y
        direction - 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.
        Specified by:
        isSolid in interface TileMap
        Parameters:
        x - The x coordinate of the tile to check
        y - The y coordinate of the tile to check
        Returns:
        True if the location is blocked
      • 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.
        Specified by:
        isSolid in interface TileMap
        Parameters:
        x - The x coordinate of the tile to check
        y - The y coordinate of the tile to check
        flag - The flag of the tile to check
        Returns:
        True if the location is blocked
      • 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 interface TileMap
        Parameters:
        sx - The x coordinate of the tile we're moving from
        sy - The y coordinate of the tile we're moving from
        tx - The x coordinate of the tile we're moving to
        ty - 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.
        Specified by:
        visit in interface TileMap
        Parameters:
        x - The x coordinate of the tile that was visited
        y - The y coordinate of the tile that was visited
      • 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 interface TileMap
        Parameters:
        x1 - The x coordinate of the start tile to check
        y1 - The y coordinate of the start tile to check
        x2 - The x coordinate of the destination tile to check
        y2 - 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 interface TileMap
        Parameters:
        x1 - The x coordinate of the start tile to check
        y1 - The y coordinate of the start tile to check
        x2 - The x coordinate of the destination tile to check
        y2 - The y coordinate of the destination tile to check
        flag - 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 interface TileMap
        Parameters:
        x - The x coordinate
        y - The y coordinate