Skip to content

Commit 1c0e448

Browse files
committed
added cost property
1 parent 116db10 commit 1c0e448

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/core/Node.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
* @param {number} x - The x coordinate of the node on the grid.
77
* @param {number} y - The y coordinate of the node on the grid.
88
* @param {boolean} [walkable] - Whether this node is walkable.
9+
* @param {number} [cost] - node cost used by finders that allow non-uniform node costs
910
*/
10-
function Node(x, y, walkable) {
11+
function Node(x, y, walkable, cost) {
1112
/**
1213
* The x coordinate of the node on the grid.
1314
* @type number
@@ -23,6 +24,11 @@ function Node(x, y, walkable) {
2324
* @type boolean
2425
*/
2526
this.walkable = (walkable === undefined ? true : walkable);
27+
/**
28+
* Cost to walk this node if its walkable
29+
* @type number
30+
*/
31+
this.cost = (cost === undefined) ? 0 : cost;
2632
}
2733

2834
module.exports = Node;

0 commit comments

Comments
 (0)