Class ClusterSpatialQueryExtensions
Construction helpers for ClusterSpatialQuery<TArch>. Exposed on DatabaseEngine —
dbe.ClusterSpatialQuery{TArch}().AABB(...) — and on Transaction — tx.ClusterSpatialQuery{TArch}().AABB(...).
public static class ClusterSpatialQueryExtensions
- Inheritance
-
ClusterSpatialQueryExtensions
- Inherited Members
Remarks
Engine or transaction. Both run the same zero-allocation query over the committed spatial state. The transaction form also drops every entity
that transaction destroyed and has not committed (CLUSTERWALK-04), as its point access (IsAlive, Open, OpenMut) already treats
it. With no pending destroy in the transaction it costs one null test and one count compare per cluster opened.
The engine form sees no transaction's pending work. Called from a system that destroys entities, it hands back those entities until the
destroy commits; an OpenMut on such a hit throws ("not found or not visible") and aborts the tick, a TryOpen silently skips it, and an
in-place write acts on an entity about to be released. Use the transaction form in any body that destroys, or validate each hit with
tx.IsAlive. Neither form shows the transaction's own pending spawns: they hold no spatial slot until the commit publishes them. Both can
still return an entity another transaction destroyed and committed earlier in the tick while the spatial index lags until the fence — validate before
acting on a hit you did not just read.
Methods
ClusterSpatialQuery<TArch>(DatabaseEngine)
Create a per-cell cluster AABB query for the given archetype. Sees no transaction's pending work: from a body that destroys entities, prefer ClusterSpatialQuery<TArch>(Transaction) (see the class remarks for the risk).
public static ClusterSpatialQuery<TArch> ClusterSpatialQuery<TArch>(this DatabaseEngine engine) where TArch : Archetype<TArch>, new()
Parameters
engineDatabaseEngineThe database engine.
Returns
- ClusterSpatialQuery<TArch>
A zero-allocation query handle.
Type Parameters
TArchThe archetype type.
Exceptions
- InvalidOperationException
Thrown when the archetype is not cluster-eligible or has no spatial component.
ClusterSpatialQuery<TArch>(DatabaseEngine, RealmId)
Create a per-cell cluster query for the given archetype in realm realm: it sees only that realm's entities, however their
coordinates compare with another realm's. Sees no transaction's pending work: from a body that destroys entities, prefer
ClusterSpatialQuery<TArch>(Transaction, RealmId) (see the class remarks for the risk).
public static ClusterSpatialQuery<TArch> ClusterSpatialQuery<TArch>(this DatabaseEngine engine, RealmId realm) where TArch : Archetype<TArch>, new()
Parameters
engineDatabaseEngineThe database engine.
realmRealmIdThe realm to query. Must be registered.
Returns
- ClusterSpatialQuery<TArch>
A zero-allocation query handle.
Type Parameters
TArchThe archetype type.
Exceptions
- InvalidOperationException
Thrown when the archetype is not cluster-eligible, has no spatial component, or the realm is not registered.
ClusterSpatialQuery<TArch>(Transaction)
ClusterSpatialQuery<TArch>(DatabaseEngine) through transaction: never returns an entity that transaction destroyed
and has not committed (CLUSTERWALK-04). A destroy made while the query runs — from a radius batch's sink, say — applies from the next cluster opened.
public static TransactionClusterSpatialQuery<TArch> ClusterSpatialQuery<TArch>(this Transaction transaction) where TArch : Archetype<TArch>, new()
Parameters
transactionTransactionThe transaction whose own pending destroys the query drops. Used on its own thread only, like the transaction.
Returns
- TransactionClusterSpatialQuery<TArch>
A zero-allocation query handle, valid while the transaction is.
Type Parameters
TArchThe archetype type.
Exceptions
ClusterSpatialQuery<TArch>(Transaction, RealmId)
ClusterSpatialQuery<TArch>(DatabaseEngine, RealmId) through transaction: never returns an entity that transaction
destroyed and has not committed (CLUSTERWALK-04).
public static TransactionClusterSpatialQuery<TArch> ClusterSpatialQuery<TArch>(this Transaction transaction, RealmId realm) where TArch : Archetype<TArch>, new()
Parameters
transactionTransactionThe transaction whose own pending destroys the query drops.
realmRealmIdThe realm to query. Must be registered.
Returns
- TransactionClusterSpatialQuery<TArch>
A zero-allocation query handle, valid while the transaction is.
Type Parameters
TArchThe archetype type.