Skip to main content

SpatialQuery

Trait SpatialQuery 

Source
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§

Source

fn candidates_on_layer(&self, layer: SpatialLayerId) -> Vec<EnemyIdx>

Sorted, deduplicated broad-phase actor IDs on one spatial layer.

Source

fn candidates_in_envelope( &self, layer: SpatialLayerId, envelope: SpatialEnvelope, ) -> Vec<EnemyIdx>

Source

fn actors_in_radius( &self, query: RadiusQuery, allowed: Option<&[EnemyIdx]>, ) -> Vec<EnemyIdx>

Source

fn actors_in_cone( &self, query: ConeQuery, allowed: Option<&[EnemyIdx]>, ) -> Vec<EnemyIdx>

Source

fn actors_by_distance( &self, layer: SpatialLayerId, origin: Position2, allowed: Option<&[EnemyIdx]>, ) -> Vec<EnemyIdx>

Active actors ordered by increasing distance, then ascending actor ID.

Source

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).

Source

fn segment_visible( &self, layer: SpatialLayerId, start: Position2, end: Position2, ) -> bool

Whether a same-layer closed segment is unobstructed by static geometry.

Source

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.

Source

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.

Source

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.

Source

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.

Implementors§