UnitIndexer

Utilities View source
UnitIndexer

Returns the int index of this unit. A missing or stale association is a critical error. Can be configured by the user to supply a custom unit indexer which won’t break other stdlib components, as long as it keeps firing onUnitIndex and onUnitDeindex: UnitSpatialIndex, for one, registers units only through them.

Types

Functions and constants

public function shouldIndex(unit _u) returns boolean

Declaration shown above.

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

public function unit.peekIndex() returns int

Read-only lifecycle/diagnostic observation. Zero means no association exists. Never allocates or dispatches; normal consumers require getIndex instead.

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

public function unit.isIndexCurrent(int expectedIndex) returns boolean

Validates deferred work captured while indexed. Absence means the old lifetime ended, rather than requesting a replacement identity for the unit. Never allocates.

public function unit.getIndex() returns int

Declaration shown above.

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

public function unit.toUnitIndex() returns UnitIndex

Returns the existing UnitIndex. Lookup never creates an index or fires onUnitIndex.

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

public function getIndexingUnit() returns unit

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

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.

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.

public function unit.deindex() returns bool

Deindexes a unit. Returns false if the unit is unindexed or a deindex hook is already releasing it.