T - only classes extending GridCell can be used within this graphpublic class NavigationGrid<T extends NavigationGridGraphNode> extends java.lang.Object implements NavigationGridGraph<T>
NavigationGraph which is represented as a grid or a table.
The nodes are accessible through (x, y) coordinates.| Modifier and Type | Field and Description |
|---|---|
protected int |
height |
protected T[][] |
nodes
The nodes contained in the grid.
|
protected int |
width |
| Constructor and Description |
|---|
NavigationGrid()
Creates an grid with no nodes.
|
NavigationGrid(T[][] nodes) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(int x,
int y)
Determine wether the given x,y pair is within the bounds of this grid
|
T |
getCell(int x,
int y) |
int |
getHeight() |
float |
getMovementCost(T node1,
T node2,
PathFinderOptions opt)
Determines the movement cost for moving from node1 to node2, with the given options
|
java.util.List<T> |
getNeighbors(T cell) |
java.util.List<T> |
getNeighbors(T node,
PathFinderOptions opt)
Get the neighbors of the given node.
|
T[][] |
getNodes() |
int |
getWidth() |
boolean |
isWalkable(int x,
int y)
Determine whether the node at the given position is walkable.
|
boolean |
isWalkable(T node) |
boolean |
lineOfSight(NavigationNode from,
NavigationNode to) |
void |
setCell(int x,
int y,
T cell) |
void |
setHeight(int height) |
void |
setNodes(T[][] nodes) |
void |
setWalkable(int x,
int y,
boolean walkable)
Set whether the node on the given position is walkable.
|
void |
setWidth(int width) |
protected int width
protected int height
protected T extends NavigationGridGraphNode[][] nodes
public NavigationGrid()
setNodes(NavigationGridGraphNode[][]) before trying to make
use of the grid cells.public NavigationGrid(T[][] nodes)
public T getCell(int x, int y)
getCell in interface NavigationGridGraph<T extends NavigationGridGraphNode>public void setCell(int x,
int y,
T cell)
setCell in interface NavigationGridGraph<T extends NavigationGridGraphNode>public boolean isWalkable(int x,
int y)
isWalkable in interface NavigationGridGraph<T extends NavigationGridGraphNode>x - - The x / column coordinate of the node.y - - The y / row coordinate of the node.public boolean contains(int x,
int y)
contains in interface NavigationGridGraph<T extends NavigationGridGraphNode>x - - The x / column coordinate of the node.y - - The y / row coordinate of the node.public void setWalkable(int x,
int y,
boolean walkable)
setWalkable in interface NavigationGridGraph<T extends NavigationGridGraphNode>x - - The x / column coordinate of the node.y - - The y / row coordinate of the node.walkable - - Whether the position is walkable.java.lang.IndexOutOfBoundsException - if the coordinate is not inside the grid.public java.util.List<T> getNeighbors(T cell)
getNeighbors in interface NavigationGraph<T extends NavigationGridGraphNode>cell - the node to find the neighbors forpublic java.util.List<T> getNeighbors(T node, PathFinderOptions opt)
offsets diagonalOffsets:
+---+---+---+ +---+---+---+
| | 0 | | | 4 | | 5 |
+---+---+---+ +---+---+---+
| 3 | | 1 | | | | |
+---+---+---+ +---+---+---+
| | 2 | | | 6 | | 7 |
+---+---+---+ +---+---+---+
getNeighbors in interface NavigationGraph<T extends NavigationGridGraphNode>node - opt - public float getMovementCost(T node1, T node2, PathFinderOptions opt)
NavigationGraphgetMovementCost in interface NavigationGraph<T extends NavigationGridGraphNode>public boolean isWalkable(T node)
isWalkable in interface NavigationGraph<T extends NavigationGridGraphNode>public T[][] getNodes()
getNodes in interface NavigationGridGraph<T extends NavigationGridGraphNode>public void setNodes(T[][] nodes)
setNodes in interface NavigationGridGraph<T extends NavigationGridGraphNode>public int getWidth()
getWidth in interface NavigationGridGraph<T extends NavigationGridGraphNode>public void setWidth(int width)
setWidth in interface NavigationGridGraph<T extends NavigationGridGraphNode>public int getHeight()
getHeight in interface NavigationGridGraph<T extends NavigationGridGraphNode>public void setHeight(int height)
setHeight in interface NavigationGridGraph<T extends NavigationGridGraphNode>public boolean lineOfSight(NavigationNode from, NavigationNode to)
lineOfSight in interface NavigationGraph<T extends NavigationGridGraphNode>