@@ -88,7 +88,11 @@ var astar = {
88
88
currentNode . closed = true ;
89
89
90
90
// Find all neighbors for the current node. Optionally find diagonal neighbors as well (false by default).
91
- var neighbors = astar . neighbors ( grid , currentNode , diagonal ) ;
91
+ var diagonalThisNode = false ;
92
+ if ( diagonal == true ) {
93
+ diagonalThisNode = ( currentNode . options . diagonal != null ) ? currentNode . options . diagonal : true ;
94
+ }
95
+ var neighbors = astar . neighbors ( grid , currentNode , diagonalThisNode ) ;
92
96
93
97
for ( var i = 0 , il = neighbors . length ; i < il ; i ++ ) {
94
98
var neighbor = neighbors [ i ] ;
@@ -215,7 +219,7 @@ function Graph(grid) {
215
219
nodes [ x ] = [ ] ;
216
220
217
221
for ( var y = 0 , row = grid [ x ] ; y < row . length ; y ++ ) {
218
- nodes [ x ] [ y ] = new GraphNode ( x , y , row [ y ] ) ;
222
+ nodes [ x ] [ y ] = new GraphNode ( x , y , row [ y ] . cost , row [ y ] . options ) ;
219
223
}
220
224
}
221
225
@@ -238,7 +242,7 @@ Graph.prototype.toString = function() {
238
242
return graphString ;
239
243
} ;
240
244
241
- function GraphNode ( x , y , type ) {
245
+ function GraphNode ( x , y , type , options ) {
242
246
this . data = { } ;
243
247
this . x = x ;
244
248
this . y = y ;
@@ -247,6 +251,7 @@ function GraphNode(x, y, type) {
247
251
y : y
248
252
} ;
249
253
this . type = type ;
254
+ this . options = options || { } ;
250
255
}
251
256
252
257
GraphNode . prototype . toString = function ( ) {
0 commit comments