getNeighbors

abstract fun getNeighbors(mode: CellAccessMode = CellAccessMode.ACCESSIBLE, includeDiagonals: Boolean = false, vararg excludeAxes: Axis): List<Cell>(source)

Computes all neighboring cells. That are cells for which only one dimension differs by exactly 1. Excluded are diagonal cells that will be included in the returned list if includeDiagonals is true. If this cell is located on the edge of the map, the returned list will not contain cells that are outside of the map (for example if this cell has the location 0, 0, 0, the returned list will not contain the cell at 0, 0, -1).

It is also possible to exclude certain axes from the search via excludeAxes. Possible values are x, y and z. If an axis is excluded, the returned list will not contain cells that differ in this axis from this cell. For example, if the x-axis is excluded and this cell has the location 0, 0, 0, the returned list will not contain the cell at 1, 0, 0. This applies further to diagonal cells, which will not be included in the returned list if they differ in an excluded axis. If all axes are excluded, an empty list is returned.

Depending on which accessibility mode was chosen, this method may return all cells that are adjacent to this or only those ones that are accessible from this cell, i.e. where no wall is between them two.

Return

a list of all neighboring cells

Parameters

mode

the accessibility mode to use

includeDiagonals

whether to include diagonal cells

excludeAxes

the axes to exclude from the search

Throws

if mode is CellAccessMode.ACCESSIBLE and this cell itself is not accessible