diff --git a/bin/easystar-0.4.4.js b/bin/easystar-0.4.4.js index ba4d9b5..df5ccc6 100644 --- a/bin/easystar-0.4.4.js +++ b/bin/easystar-0.4.4.js @@ -116,7 +116,7 @@ var EasyStar= * * Implementation By Bryce Neal (@prettymuchbryce) **/ -var EasyStar={},Instance=__webpack_require__(1),Node=__webpack_require__(2),Heap=__webpack_require__(3);module.exports=EasyStar;var nextInstanceId=1;EasyStar.js=function(){var collisionGrid,iterationsSoFar,acceptableTiles,syncEnabled=!1,pointsToAvoid={},costMap={},pointsToCost={},directionalConditions={},allowCornerCutting=!0,instances={},instanceQueue=[],iterationsPerCalculation=Number.MAX_VALUE,diagonalsEnabled=!1; +var EasyStar={},Instance=__webpack_require__(1),Node=__webpack_require__(2),Heap=__webpack_require__(3);module.exports=EasyStar;var nextInstanceId=1;EasyStar.js=function(){var collisionGrid,iterationsSoFar,acceptableTiles,syncEnabled=!1,pointsToAvoid={},costMap={},pointsToCost={},directionalConditions={},allowCornerCutting=!0,instances={},instanceQueue=[],iterationsPerCalculation=Number.MAX_VALUE,diagonalsEnabled=!1,findNearestEnabled=!1; /** * Sets the collision grid that EasyStar uses. * @@ -146,6 +146,14 @@ this.enableDiagonals=function(){diagonalsEnabled=!0}, * Disable diagonal pathfinding. */ this.disableDiagonals=function(){diagonalsEnabled=!1}, +/** + * Enable pathfinder to find 'nearest' tile when non acceptable tile is selected. + */ +this.enableFindNearest=function(){findNearestEnabled=!0}, +/** + * Enable find nearest. + */ +this.disableFindNearest=function(){findNearestEnabled=!1}, /** * Sets the collision grid that EasyStar uses. * @@ -249,7 +257,7 @@ if(void 0===acceptableTiles)throw new Error("You can't set a path without first if(void 0===collisionGrid)throw new Error("You can't set a path without first calling setGrid() on EasyStar.");// Start or endpoint outside of scope. if(startX<0||startY<0||endX<0||endY<0||startX>collisionGrid[0].length-1||startY>collisionGrid.length-1||endX>collisionGrid[0].length-1||endY>collisionGrid.length-1)throw new Error("Your start or end point is outside the scope of your grid.");// Start and end are the same tile. if(startX!==endX||startY!==endY){for(// End point is not an acceptable tile. -var endTile=collisionGrid[endY][endX],isAcceptable=!1,i=0;i0&&checkAdjacentNode(instance,searchNode,0,-1,1*getTileCost(searchNode.x,searchNode.y-1)),searchNode.x0&&checkAdjacentNode(instance,searchNode,-1,0,1*getTileCost(searchNode.x-1,searchNode.y)),diagonalsEnabled&&(searchNode.x>0&&searchNode.y>0&&(allowCornerCutting||isTileWalkable(collisionGrid,acceptableTiles,searchNode.x,searchNode.y-1,searchNode)&&isTileWalkable(collisionGrid,acceptableTiles,searchNode.x-1,searchNode.y,searchNode))&&checkAdjacentNode(instance,searchNode,-1,-1,1.4*getTileCost(searchNode.x-1,searchNode.y-1)),searchNode.x0&&(allowCornerCutting||isTileWalkable(collisionGrid,acceptableTiles,searchNode.x,searchNode.y-1,searchNode)&&isTileWalkable(collisionGrid,acceptableTiles,searchNode.x+1,searchNode.y,searchNode))&&checkAdjacentNode(instance,searchNode,1,-1,1.4*getTileCost(searchNode.x+1,searchNode.y-1)),searchNode.x>0&&searchNode.y0&&checkAdjacentNode(instance,searchNode,0,-1,1*getTileCost(searchNode.x,searchNode.y-1)),searchNode.x0&&checkAdjacentNode(instance,searchNode,-1,0,1*getTileCost(searchNode.x-1,searchNode.y)),diagonalsEnabled&&(searchNode.x>0&&searchNode.y>0&&(allowCornerCutting||isTileWalkable(collisionGrid,acceptableTiles,searchNode.x,searchNode.y-1,searchNode)&&isTileWalkable(collisionGrid,acceptableTiles,searchNode.x-1,searchNode.y,searchNode))&&checkAdjacentNode(instance,searchNode,-1,-1,1.4*getTileCost(searchNode.x-1,searchNode.y-1)),searchNode.x0&&(allowCornerCutting||isTileWalkable(collisionGrid,acceptableTiles,searchNode.x,searchNode.y-1,searchNode)&&isTileWalkable(collisionGrid,acceptableTiles,searchNode.x+1,searchNode.y,searchNode))&&checkAdjacentNode(instance,searchNode,1,-1,1.4*getTileCost(searchNode.x+1,searchNode.y-1)),searchNode.x>0&&searchNode.yc[0].length-1||n>c.length-1||e>c[0].length-1||o>c.length-1)throw new Error("Your start or end point is outside the scope of your grid.");if(t!==e||n!==o){for(var s=c[o][e],u=!1,l=0;l>1])<0;)t[e]=i,e=s;return t[e]=r},f=function(t,n,e){var o,r,i,s,u;for(null==e&&(e=p),r=t.length,i=t[u=n],o=2*n+1;oc[0].length-1||n>c.length-1||e>c[0].length-1||r>c.length-1)throw new Error("Your start or end point is outside the scope of your grid.");if(t!==e||n!==r){for(var s=c[r][e],u=!1,a=0;a>1])<0;)t[e]=i,e=s;return t[e]=o},f=function(t,n,e){var r,o,i,s,u;for(null==e&&(e=p),o=t.length,i=t[u=n],r=2*n+1;r