UnitSpatialGroup

Utilities View source
UnitSpatialGroup
public class UnitSpatialGroup

A maintained subset of indexed units, with independent partition chains.

Membership is event-owned: call refreshMembership after registration and changes to predicate inputs. A query also rechecks the predicate, so a stale member can never be returned; newly eligible units require a membership notification to join. Position sweeps never evaluate caller predicates. All queries honor isSpatialQueryCandidate. Within that policy, explicit subsets use their predicate as visibility policy, including hidden/Locust units when allowed. Ordinary queries retain Warcraft enumeration semantics. The caller owns the predicate and must keep it alive until the subset is destroyed.

Constructors

construct(UnitSpatialPredicate predicate)

Methods

refreshMembership(unit u)

Re-evaluates membership without registering a unit; safe from a deindex listener.

beginQuery(vec2 center, real radius) returns int

Opens a snapshot; close with spatialIndexEndQuery(), including when it returns zero.

beginQuery(vec2 center, real radius, boolean collisionFiltering) returns int
anyInRange(vec2 center, real radius, UnitSpatialPredicate filter) returns boolean

Exact origin-radius existence query; stops traversal at the first accepted member. The filter must not yield, query, or mutate the index. It is borrowed for this call only. No snapshot is opened, so an existing snapshot remains intact. No per-call allocation.