From d1db57451ad504ddc018daffbcc6d5724348f31f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 2 Mar 2022 23:31:43 +0100 Subject: [PATCH] 5-10-5 support --- js/pathfinding.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/js/pathfinding.js b/js/pathfinding.js index f118bfb..1c36b79 100644 --- a/js/pathfinding.js +++ b/js/pathfinding.js @@ -107,10 +107,12 @@ function getNode(pos, token, initialize=true) { if (window.terrainRuler) { // TODO Additional cache for each token shape // TODO Use the correct token shape - // TODO 5-10-5 support let ray = new Ray(getCenterFromGridPositionObj(neighborPos), getCenterFromGridPositionObj(pos)); let measuredDistance = terrainRuler.measureDistances([{ray}], {costFunction: buildCostFunction(token, [{x: 0, y: 0}])})[0]; edgeCost = Math.round(measuredDistance / canvas.dimensions.distance); + if (ray.terrainRulerFinalState?.noDiagonals === 1) { + edgeCost = 1.5; + } // Charge 1.0001 instead of 1 for diagonals to discourage unnecessary diagonals if (isDiagonal && edgeCost == 1) { edgeCost = 1.0001;