DestructableSpatialIndex

Utilities View source
DestructableSpatialIndex

Static Lua spatial index for destructables.

Destructables do not have an observable movement event, so this index only needs registration and removal hooks. Preplaced destructables are discovered once during initialization. Runtime destructables created through CreateDestructable must call registerSpatialIndex() before they can be queried.

Functions and constants

public constant USE_DESTRUCTABLE_SPATIAL_INDEX = true

Declaration shown above.

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

public constant DESTRUCTABLE_SPATIAL_INDEX_CELL_SIZE = 256.

Declaration shown above.

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

public function destructable.registerSpatialIndex()

Registers one destructable in the index.

public function destructable.unregisterSpatialIndex()

Removes one destructable from the index before RemoveDestructable is called.

public function rebuildDestructableSpatialIndexGrid(vec2 worldMin, vec2 worldMax)

Rebuilds the grid around the current membership. Useful after changing the configured map bounds.

public function destructableSpatialIndexBeginBoxQuery(vec2 boxMin, vec2 boxMax) returns int

Collects indexed destructables whose cached position is inside the axis-aligned box.

public function destructableSpatialIndexBeginRangeQuery(vec2 center, real range) returns int

Collects indexed destructables in the square used by forDestructablesInRange.

public function destructableSpatialIndexQuery(int i) returns destructable
public function destructableSpatialIndexEndQuery()
public function destructableSpatialIndexHealthy() returns boolean
public function destructableSpatialIndexTracked() returns int
public function destructableSpatialIndexCellOf(vec2 pos) returns int
public function destructableSpatialIndexGridWidth() returns int
public function destructableSpatialIndexGridHeight() returns int