pub trait SpatialQuery: Debug + Send {
// Required methods
fn candidates_on_layer(&self, layer: SpatialLayerId) -> Vec<EnemyIdx>;
fn candidates_in_envelope(
&self,
layer: SpatialLayerId,
envelope: SpatialEnvelope,
) -> Vec<EnemyIdx>;
fn actors_in_radius(
&self,
query: RadiusQuery,
allowed: Option<&[EnemyIdx]>,
) -> Vec<EnemyIdx>;
fn actors_in_cone(
&self,
query: ConeQuery,
allowed: Option<&[EnemyIdx]>,
) -> Vec<EnemyIdx>;
fn actors_by_distance(
&self,
layer: SpatialLayerId,
origin: Position2,
allowed: Option<&[EnemyIdx]>,
) -> Vec<EnemyIdx>;
fn nearest_actor_matching(
&self,
layer: SpatialLayerId,
origin: Position2,
is_eligible: &mut dyn FnMut(EnemyIdx) -> bool,
) -> Option<EnemyIdx>;
fn segment_visible(
&self,
layer: SpatialLayerId,
start: Position2,
end: Position2,
) -> bool;
fn validate_transform(
&self,
transform: SpatialTransform,
) -> Result<(), SpatialQueryError>;
fn insert_actor(
&mut self,
actor: SpatialActor,
) -> Result<(), SpatialQueryError>;
fn remove_actor(
&mut self,
actor: SpatialActor,
) -> Result<(), SpatialQueryError>;
fn relocate_actor(
&mut self,
actor: EnemyIdx,
from: SpatialTransform,
to: SpatialTransform,
) -> Result<(), SpatialQueryError>;
}Expand description
Deterministic spatial queries over active enemy points and immutable blockers; implementations return sorted, deduplicated IDs.
Required Methods§
Sourcefn candidates_on_layer(&self, layer: SpatialLayerId) -> Vec<EnemyIdx>
fn candidates_on_layer(&self, layer: SpatialLayerId) -> Vec<EnemyIdx>
Sorted, deduplicated broad-phase actor IDs on one spatial layer.
fn candidates_in_envelope( &self, layer: SpatialLayerId, envelope: SpatialEnvelope, ) -> Vec<EnemyIdx>
fn actors_in_radius( &self, query: RadiusQuery, allowed: Option<&[EnemyIdx]>, ) -> Vec<EnemyIdx>
fn actors_in_cone( &self, query: ConeQuery, allowed: Option<&[EnemyIdx]>, ) -> Vec<EnemyIdx>
Sourcefn actors_by_distance(
&self,
layer: SpatialLayerId,
origin: Position2,
allowed: Option<&[EnemyIdx]>,
) -> Vec<EnemyIdx>
fn actors_by_distance( &self, layer: SpatialLayerId, origin: Position2, allowed: Option<&[EnemyIdx]>, ) -> Vec<EnemyIdx>
Active actors ordered by increasing distance, then ascending actor ID.
Sourcefn nearest_actor_matching(
&self,
layer: SpatialLayerId,
origin: Position2,
is_eligible: &mut dyn FnMut(EnemyIdx) -> bool,
) -> Option<EnemyIdx>
fn nearest_actor_matching( &self, layer: SpatialLayerId, origin: Position2, is_eligible: &mut dyn FnMut(EnemyIdx) -> bool, ) -> Option<EnemyIdx>
Return the nearest actor accepted by is_eligible without materializing the layer (increasing-distance then ascending actor-ID order).
Sourcefn segment_visible(
&self,
layer: SpatialLayerId,
start: Position2,
end: Position2,
) -> bool
fn segment_visible( &self, layer: SpatialLayerId, start: Position2, end: Position2, ) -> bool
Whether a same-layer closed segment is unobstructed by static geometry.
Sourcefn validate_transform(
&self,
transform: SpatialTransform,
) -> Result<(), SpatialQueryError>
fn validate_transform( &self, transform: SpatialTransform, ) -> Result<(), SpatialQueryError>
Validates that a transform can be represented by this index.
§Errors
Returns an error for non-finite, blocked, or otherwise invalid transforms.
Sourcefn insert_actor(&mut self, actor: SpatialActor) -> Result<(), SpatialQueryError>
fn insert_actor(&mut self, actor: SpatialActor) -> Result<(), SpatialQueryError>
Adds an actor to the index.
§Errors
Returns an error when the actor already exists or its transform is invalid.
Sourcefn remove_actor(&mut self, actor: SpatialActor) -> Result<(), SpatialQueryError>
fn remove_actor(&mut self, actor: SpatialActor) -> Result<(), SpatialQueryError>
Removes an actor from the index.
§Errors
Returns an error when the actor is absent or its transform does not match.
Sourcefn relocate_actor(
&mut self,
actor: EnemyIdx,
from: SpatialTransform,
to: SpatialTransform,
) -> Result<(), SpatialQueryError>
fn relocate_actor( &mut self, actor: EnemyIdx, from: SpatialTransform, to: SpatialTransform, ) -> Result<(), SpatialQueryError>
Moves an indexed actor between validated transforms.
§Errors
Returns an error when the actor is absent, the source differs, or the destination is invalid.