SimpleGridCell

open class SimpleGridCell(val location: Location, val map: VyrekaMap) : SimpleAttributeHolder, Cell(source)

A simple implementation of a Cell that is used in a grid-based map.

Parameters

location

the location of this cell

map

the map this cell is located on

Constructors

Link copied to clipboard
constructor(location: Location, map: VyrekaMap)

Properties

Link copied to clipboard
Link copied to clipboard
open override val location: Location
Link copied to clipboard
open override val map: VyrekaMap

Functions

Link copied to clipboard
open override 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
open override fun getNeighbors(mode: CellAccessMode, includeDiagonals: Boolean, 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.