UnitIndexer

Utilities View source
UnitIndexer

Returns the int index of this unit. Can be configured by the user to supply a custom unit indexer which won’t break other stdlib components.

Source on GitHub

Classes

UnitIndex

public class UnitIndex

Members:

  • getUnit() returns unit
  • getIndex() returns int
  • construct(unit whichUnit)

Functions

shouldIndex

public function shouldIndex(unit _u) returns boolean

🔧 Configurable. Override it in your map’s config package.

getIndexingUnit

public function getIndexingUnit() returns unit

Returns the currently indexing unit. That’s the last indexed unit or the one about to be deindexed.

onUnitDeindex

public function onUnitDeindex(code func)

Adds a function to be called before a unit is deindexed. Use the getIndexingUnit() function to refer to the deindexing unit.

onUnitIndex

public function onUnitIndex(code func)

Adds a function to be called after a unit is indexed. Use the getIndexingUnit() function to refer to the indexed unit.

Extension Functions

unit.getIndex

public function unit.getIndex() returns int

🔧 Configurable. Override it in your map’s config package.

unit.toUnitIndex

public function unit.toUnitIndex() returns UnitIndex

🔧 Configurable. Override it in your map’s config package.

Returns the UnitIndex associated with this unit, creating a new one if necessary.

unit.deindex

public function unit.deindex() returns bool

Deindexes a unit. Returns whether the unit was originally indexed.