mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 03:59:43 +00:00
17 lines
386 B
PHP
17 lines
386 B
PHP
<?php
|
|
class DiagonalNeighborProvider implements INeighborProvider
|
|
{
|
|
private static $neighbors = array([ 0, -1 ], [ 1, 0 ], [ 0, 1 ], [ -1, 0 ], [ -1, -1 ], [ 1, -1 ], [ 1, 1 ], [ -1, 1 ]);
|
|
|
|
public function getNeighbors(PathTile $tile)
|
|
{
|
|
$result = [];
|
|
foreach(self::$neighbors as $offset){
|
|
$t = clone $tile;
|
|
$result[] = $t->addOffset($offset);
|
|
}
|
|
return $result;
|
|
}
|
|
|
|
}
|
|
|