new BaseFinder(allowDiagonal)
Base class for path-finders. This class SHOULD NOT be directly instantiated, as it does not provide any path-finding algorithms or methods and is intended to be extended by all the other path-finder classes.
- Source:
- ./src/core/BaseFinder.js, line 9
Parameters:
Name | Type | Description |
---|---|---|
allowDiagonal |
boolean | Whether diagonal movement is allowed |
Properties
-
constructor
-
Constructor of each BaseFinder instance.
- Source:
- ./src/core/BaseFinder.js, line 86
Methods
-
<protected> _constructPath() → {Array.<Array.<number>>}
-
Construct the path according to the nodes' parents.
- Source:
- ./src/core/BaseFinder.js, line 119
Returns:
The path, including both start and end positions.- Type
- Array.<Array.<number>>
-
<protected> _find() → {Array.<[number, number]>}
-
Path-finding procedure. Note: this method is intended to be overriden by sub-classes.
- Source:
- ./src/core/BaseFinder.js, line 146
Returns:
The path, including both start and end positions.- Type
- Array.<[number, number]>
-
findPath(startX, startY, endX, endY, grid) → {Array.<[number, number]>}
-
Find and return the the path.
- Source:
- ./src/core/BaseFinder.js, line 99
Parameters:
Name Type Description startX
number The x coordinate of the start position. startY
number The y coordinate of the start position. endX
number The x coordinate of the end position. endY
number The y coordinate of the end position. grid
PF.Grid The grid holding the nodes' status. Returns:
The path, including both start and end positions.- Type
- Array.<[number, number]>
-
getAttributeAt(x, y, attr) → {object}
-
Generic getter of the attribute at the given position.
- Source:
- ./src/core/BaseFinder.js, line 77
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. attr
string The name of attribute to get. Returns:
The value of the attribute.- Type
- object
-
isInsideGrid(x, y) → {boolean}
-
Determine whether the given postition is inside the grid.
- Source:
- ./src/core/BaseFinder.js, line 28
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. Returns:
Whether it is inside.- Type
- boolean
-
isWalkableAt(x, y) → {boolean}
-
Determine whether the given position on the grid is walkable.
- Source:
- ./src/core/BaseFinder.js, line 51
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. Returns:
Whether it is walkable.- Type
- boolean
-
setAttributeAt(x, y, attr, value)
-
Generic setter of the attribute at the given position.
- Source:
- ./src/core/BaseFinder.js, line 64
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position. attr
string The name of attribute to set. value
object The value of attribute. -
setWalkableAt(x, y)
-
Set the walkable attribute of the given position on the grid.
- Source:
- ./src/core/BaseFinder.js, line 39
Parameters:
Name Type Description x
number The x coordinate of the position. y
number The y coordinate of the position.