mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
changed pathfinder(hopefully one last time)
This commit is contained in:
parent
8c12e0de26
commit
e11c40f645
28 changed files with 401 additions and 416 deletions
22
src/astarnavigator/providers/MCDiagonalProvider.php
Normal file
22
src/astarnavigator/providers/MCDiagonalProvider.php
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
|
||||
class MCDiagonalProvider implements INeighborProvider
|
||||
{
|
||||
private static $neighbors = array([ 0, 0, -1 ], [ 1, 0, 0 ], [ 0, 0, 1 ], [ -1, 0, 0 ], [ -1, 0, -1 ], [ 1, 0, -1 ], [ 1, 0, 1 ], [ -1, 0, 1 ]);
|
||||
public function getNeighbors(PathTile $tile)
|
||||
{
|
||||
|
||||
if($tile instanceof PathTileXYZ){
|
||||
$result = [];
|
||||
foreach(self::$neighbors as $offset){
|
||||
$t = clone $tile;
|
||||
$result[] = $t->addOffset($offset);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue