Cell

A cell is a single unit in a map. It is located at a specific location in 3-dimensional space and can possibly be accessed from other cells. A cell can have different properties, for example it could be a wall cell, which is not accessible from other cells. A cell can be uniquely identified by its location and the map it is located on.

A cell can also inherit attributes from an AttributeHolder. This can be used to store additional information about the cell, for example its permeability or its color. The permeability of a cell can be used to determine whether a

Since

1.0.0

See also

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val location: Location

The location of the entity it is located at. This value is static and cannot be changed.

Link copied to clipboard
abstract val map: VyrekaMap

The map this cell is located on.

Functions

Link copied to clipboard
abstract fun canBeAccessedFrom(other: Cell): Boolean

Whether this cell can be accessed from the given location. This is used to determine whether a path can be constructed from the given location to this cell. If this cell or the other cell is not accessible, this method returns false. Depending on the underlying implementation, if the other cell is more than one cell away from this cell, this method should return false as it only checks for direct accessibility.

Link copied to clipboard
open fun getAttribute(key: Key): Any

Retrieves an attribute with the given key. If no attribute with the given key exists, an exception is thrown.

Link copied to clipboard
open fun getAttributeOrDefault(key: Key, default: Any): Any

Retrieves an attribute with the given key. If no attribute with the given key exists, the default value is returned.

Link copied to clipboard
abstract fun getAttributeOrNull(key: Key): Any?

Retrieves an attribute with the given key. If no attribute with the given key exists, null is returned.

Link copied to clipboard
abstract fun getAttributes(): Map<Key, Any>

Returns a map of all attributes that are associated with a key which can be modified.

Link copied to clipboard
inline fun <T> AttributeHolder.getAttributeType(key: Key): T

Retrieves an attribute with the given key and casts it to the given type. If the attribute is not of the given type, a ClassCastException is thrown. If no attribute with the given key exists, an exception is thrown.

Link copied to clipboard
inline fun <T> AttributeHolder.getAttributeTypeOrDefault(key: Key, default: T): T

Retrieves an attribute with the given key and casts it to the given type. If the attribute is not of the given type, a ClassCastException is thrown. If no attribute with the given key exists, the default value is returned.

Link copied to clipboard

Retrieves an attribute with the given key and casts it to the given type. If the attribute is not of the given type, a ClassCastException is thrown. If no attribute with the given key exists, null is returned.

Link copied to clipboard
abstract fun getKeys(): Set<Key>

Returns a set of all keys that are associated with an attribute.

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

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).

Link copied to clipboard
open fun hasAttribute(key: Key): Boolean

Whether this cell has an attribute with the given key.

Link copied to clipboard
abstract fun removeAttribute(key: Key): Any?

Removes an attribute with the given key. If no attribute with the given key exists, null is returned; otherwise the previous value that was associated with the key is returned.

Link copied to clipboard
abstract fun setAttribute(key: Key, value: Any)

Sets an attribute with the given key to the given value. If an attribute with the same key already exists, it will be overwritten.