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.
public constant USE_DESTRUCTABLE_SPATIAL_INDEX = trueDeclaration 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 intCollects indexed destructables whose cached position is inside the axis-aligned box.
public function destructableSpatialIndexBeginRangeQuery(vec2 center, real range) returns intCollects indexed destructables in the square used by forDestructablesInRange.
public function destructableSpatialIndexQuery(int i) returns destructablepublic function destructableSpatialIndexEndQuery()public function destructableSpatialIndexHealthy() returns booleanpublic function destructableSpatialIndexTracked() returns intpublic function destructableSpatialIndexCellOf(vec2 pos) returns intpublic function destructableSpatialIndexGridWidth() returns intpublic function destructableSpatialIndexGridHeight() returns int