99final class PathFinder
1010{
1111 private Graph $ graph ;
12- /** @var array<string,bool > */
12+ /** @var array<string,null > */
1313 private array $ visited = [];
1414 private readonly int $ obstacleOvercomeHeight ;
1515 /** @var array<int,array{int,int,int}> */
@@ -105,8 +105,8 @@ public function findTile(Point $pointOnFloor, int $radius): ?Point
105105 return $ floorNavmeshPoint ;
106106 }
107107
108- $ maxDistance = $ this ->navigationMesh ->tileSize * 2 ;
109- $ maxY = $ this ->obstacleOvercomeHeight * 2 ;
108+ $ maxDistance = $ this ->navigationMesh ->tileSize + $ this -> navigationMesh -> tileSize ;
109+ $ maxY = $ this ->obstacleOvercomeHeight + $ this -> obstacleOvercomeHeight ;
110110 $ checkAbove = function (Point $ start , int $ maxY , int $ radius ): ?Point {
111111 $ yCandidate = $ start ->clone ();
112112 $ navMeshCenter = $ yCandidate ->clone ();
@@ -188,7 +188,7 @@ public function buildNavigationMesh(Point $start, int $objectHeight, int $maxNod
188188 continue ;
189189 }
190190
191- $ this ->visited [$ currentKey ] = true ;
191+ $ this ->visited [$ currentKey ] = null ;
192192 $ currentNode = $ this ->graph ->getNodeById ($ currentKey );
193193 if ($ currentNode === null ) {
194194 $ currentNode = new Node ($ currentKey , $ current );
@@ -210,7 +210,7 @@ public function buildNavigationMesh(Point $start, int $objectHeight, int $maxNod
210210 $ this ->graph ->addEdge (new DirectedEdge ($ currentNode , $ newNode , 1 ));
211211 $ queue ->enqueue ($ newNeighbour );
212212 }
213- if (++$ nodeCount === $ maxNodeCount ) {
213+ if (++$ nodeCount === $ maxNodeCount ) { // @codeCoverageIgnore
214214 GameException::notImplementedYet ('MaxNodeCount hit - new map, tileSize or bad test (no boundary box, bad starting point)? ' ); // @codeCoverageIgnore
215215 }
216216 }
0 commit comments