//! Movement phase plugin — position resolution and spatial indexing. //! //! All systems run in [`TickPhase::Movement`]. Intra-phase ordering: //! - pathfinding → follow_paths → validate_movement → cleanup_path_blocked //! - After validate_movement: spatial index, listening focus, zone crossings, tier systems use bevy_app::prelude::*; use bevy_ecs::schedule::IntoScheduleConfigs; use crate::tick_phases::TickPhase; pub struct MovementPlugin; impl Plugin for MovementPlugin { fn build(&self, app: &mut App) { app.init_resource::() .init_resource::() .init_resource::() .add_systems( Update, ( // Core movement chain (strict sequence) super::pathfinding::compute_paths, super::path_follow::follow_paths.after(super::pathfinding::compute_paths), super::movement::validate_movement.after(super::path_follow::follow_paths), super::path_follow::cleanup_path_blocked .after(super::movement::validate_movement), // Post-movement indexing (all after validate_movement, parallel with each other) super::spatial::sync_spatial_index.after(super::movement::validate_movement), super::listening::update_listening_focus .after(super::movement::validate_movement), super::zone::detect_zone_crossings.after(super::movement::validate_movement), ) .in_set(TickPhase::Movement), ); } }