LayeredMap

This class represents a map in a 3-dimensional grid that contains multiple layers. Each layer is a 2-dimensional grid in which each cell has the same y-coordinate. The layers are ordered by their y-coordinate, with the first layer having the lowest y-coordinate and the last layer having the highest y-coordinate.

Since

1.0.0

See also

Properties

Link copied to clipboard
abstract val depth: Int

The depth of the map, represented as the z-axis.

Link copied to clipboard
abstract val height: Int

The height of the map, represented as the y-axis.

Link copied to clipboard
abstract val width: Int

The width of the map, represented as the x-axis.

Functions

Link copied to clipboard
open fun getCellAt(location: Location): Cell

Tries to retrieve a cell at the given location. If there is no cell at the location, for example since the location is out of bounds, an exception is thrown. This method should only be used if it is guaranteed that there is a cell at the location.

Link copied to clipboard
abstract fun getCellAtOrNull(location: Location): Cell?

Tries to retrieve a cell at the given location. If there is no cell at the location, for example since the location is out of bounds, null is returned. However, as long as the location is within the bounds of the map, this method should never return null.

Link copied to clipboard
abstract fun getCellsFlattened(): List<Cell>

Creates a list of all cells in the map. The order of the cells is not specified and may vary between different implementations.

Link copied to clipboard
abstract fun getLayer(layer: Int): MapLayer

Returns the layer at the specified index. The layer is the y-coordinate of the layer that should be returned.

Link copied to clipboard
abstract fun getLayers(): List<MapLayer>

Returns a list of all layers in this map. The layers are ordered by their y-coordinate, with the first layer having the lowest y-coordinate and the last layer having the highest y-coordinate.

Link copied to clipboard
abstract fun removeCellAt(location: Location): Cell?

Removes the cell at the given location. If there is no cell at the location, null is returned. Otherwise, the removed cell is returned.

Link copied to clipboard
abstract fun setCell(cell: Cell)

Sets the cell at the given location to the given cell. If there is already a cell at the location, it will be overwritten by the new cell.

Link copied to clipboard
abstract fun setLayer(layer: MapLayer): Int

Sets the layer at the specified index to the given layer. If there is already a layer at the specified index, it is replaced by the new layer. If the specified index is out of bounds, an exception is thrown. This method will not modify the order of the layers and the height of the map.