diff --git a/Cargo.toml b/Cargo.toml index 30529a4..f68baee 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ speech_dispatcher_0_10 = ["bevy_tts/speech_dispatcher_0_10"] speech_dispatcher_0_11 = ["bevy_tts/speech_dispatcher_0_11"] [dependencies.bevy] -version = "0.10" +version = "0.11" default-features = false features = [ "bevy_gilrs", @@ -24,14 +24,13 @@ features = [ ] [dependencies] -bevy_rapier2d = "0.21" -bevy_synthizer = "0.3" -bevy_tts = { version = "0.5", default-features = false, features = ["tolk"] } +bevy_rapier2d = "0.22" +bevy_synthizer = "0.4" +bevy_tts = { version = "0.6", default-features = false, features = ["tolk"] } coord_2d = "0.3" futures-lite = "1" -gilrs = "0.10" here_be_dragons = { version = "0.3", features = ["serde"] } -leafwing-input-manager = { git = "https://github.com/ndarilek/leafwing-input-manager", branch = "consume" } +leafwing-input-manager = "0.10" maze_generator = "2" once_cell = "1" pathfinding = "4" diff --git a/src/core.rs b/src/core.rs index d7e7dca..b09d6fb 100644 --- a/src/core.rs +++ b/src/core.rs @@ -678,11 +678,11 @@ impl Plugin for CorePlugin { }; app.insert_resource(config) .register_type::() - .add_plugin(RapierPhysicsPlugin::::pixels_per_meter( + .add_plugins(RapierPhysicsPlugin::::pixels_per_meter( config.pixels_per_unit as f32, )) - .add_startup_system(setup) - .add_system(sync_config); + .add_systems(Startup, setup) + .add_systems(Update, sync_config); } } diff --git a/src/exploration.rs b/src/exploration.rs index f30776f..9838c86 100644 --- a/src/exploration.rs +++ b/src/exploration.rs @@ -13,7 +13,7 @@ use crate::{ visibility::{RevealedTiles, Viewshed, Visible, VisibleEntities}, }; -#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)] pub enum ExplorationAction { Forward, Backward, @@ -49,7 +49,7 @@ where #[reflect(Component)] pub struct Mappable; -fn exploration_type_change( +fn exploration_type_change( mut tts: ResMut, mut explorers: Query<( &ActionState, @@ -60,7 +60,6 @@ fn exploration_type_change( ) -> Result<(), Box> where ExplorationType: Component + Default + Copy + Ord, - State: 'static + Clone + Debug + Eq + Hash + Send + Sync, { for (actions, visible, mut focused) in &mut explorers { let mut types: Vec = vec![]; @@ -112,7 +111,7 @@ where Ok(()) } -fn exploration_type_focus( +fn exploration_type_focus( mut commands: Commands, mut tts: ResMut, explorers: Query<( @@ -126,7 +125,6 @@ fn exploration_type_focus( ) -> Result<(), Box> where ExplorationType: Component + Default + PartialEq, - State: 'static + Clone + Debug + Eq + Hash + Send + Sync, { for (entity, actions, visible_entities, focused_type, exploring) in &explorers { let mut features = features @@ -202,7 +200,7 @@ where Ok(()) } -fn exploration_focus( +fn exploration_focus( mut commands: Commands, map: Query<&Map>, explorers: Query< @@ -215,7 +213,6 @@ fn exploration_focus( With, >, ) where - State: 'static + Clone + Debug + Eq + Hash + Send + Sync, MapData: 'static + Clone + Default + Send + Sync, { for (entity, actions, transform, exploring) in &explorers { @@ -252,12 +249,11 @@ fn exploration_focus( } } -fn navigate_to_explored( +fn navigate_to_explored( mut commands: Commands, map: Query<(&Map, &RevealedTiles)>, explorers: Query<(Entity, &ActionState, &Exploring)>, ) where - State: 'static + Clone + Debug + Eq + Hash + Send + Sync, MapData: 'static + Clone + Default + Send + Sync, { for (entity, actions, exploring) in &explorers { @@ -400,31 +396,32 @@ where .register_type::() .register_type::() .register_type::() - .add_plugin(InputManagerPlugin::::default()) + .add_plugins(InputManagerPlugin::::default()) .add_systems( + Update, ( - exploration_type_change::.pipe(error_handler), + exploration_type_change::.pipe(error_handler), exploration_type_changed_announcement::.pipe(error_handler), ) .chain() .in_set(Exploration), ) .add_systems( + Update, ( - exploration_focus::, - exploration_type_focus::.pipe(error_handler), + exploration_focus::, + exploration_type_focus::.pipe(error_handler), exploration_changed_announcement:: .pipe(error_handler), ) .chain() .in_set(Exploration), ) - .add_system(navigate_to_explored::.in_set(Exploration)); + .add_systems(Update, navigate_to_explored::.in_set(Exploration)); if !config.states.is_empty() { let states = config.states; for state in states { - app.configure_set(Exploration.in_set(OnUpdate(state.clone()))) - .add_system(cleanup.in_schedule(OnExit(state))); + app.add_systems(OnExit(state), cleanup); } } } diff --git a/src/lib.rs b/src/lib.rs index b84203a..6c88956 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,7 +12,6 @@ pub mod core; pub mod error; pub mod exploration; pub use futures_lite; -pub use gilrs; pub use here_be_dragons as mapgen; pub use leafwing_input_manager; pub mod log; diff --git a/src/log.rs b/src/log.rs index 8d9e47f..3bfab54 100644 --- a/src/log.rs +++ b/src/log.rs @@ -60,11 +60,7 @@ pub struct LogPlugin; impl Plugin for LogPlugin { fn build(&self, app: &mut App) { app.register_type::() - .add_startup_system(setup) - .add_system( - read_log - .pipe(error_handler) - .in_base_set(CoreSet::PostUpdate), - ); + .add_systems(Startup, setup) + .add_systems(PostUpdate, read_log.pipe(error_handler)); } } diff --git a/src/map.rs b/src/map.rs index 1b8148c..05e01d2 100644 --- a/src/map.rs +++ b/src/map.rs @@ -329,12 +329,12 @@ impl Plugin for MapPlugin() .add_systems( + PreUpdate, ( spawn_colliders::, spawn_portals::, spawn_portal_colliders::, - ) - .in_base_set(CoreSet::PreUpdate), + ), ); } } diff --git a/src/navigation.rs b/src/navigation.rs index 85de95e..adbac2d 100644 --- a/src/navigation.rs +++ b/src/navigation.rs @@ -13,7 +13,7 @@ use crate::{ utils::target_and_other, }; -#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(Actionlike, PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)] pub enum NavigationAction { Move, Translate, @@ -415,21 +415,21 @@ where .register_type::() .register_type::() .register_type::() - .add_plugin(InputManagerPlugin::::default()) - .add_systems((update_direction, add_speed).in_base_set(CoreSet::PreUpdate)) + .add_plugins(InputManagerPlugin::::default()) + .add_systems(PreUpdate, (update_direction, add_speed)) .add_systems( + Update, (snap.pipe(error_handler), controls) .chain() .in_set(Movement), ) - .add_systems((tick_snap_timers, speak_direction.pipe(error_handler))) .add_systems( - (remove_direction, log_area_descriptions::).in_base_set(CoreSet::PostUpdate), + Update, + (tick_snap_timers, speak_direction.pipe(error_handler)), + ) + .add_systems( + PostUpdate, + (remove_direction, log_area_descriptions::), ); - if !self.states.is_empty() { - for state in &self.states { - app.configure_set(Movement.in_set(OnUpdate(state.clone()))); - } - } } } diff --git a/src/pathfinding.rs b/src/pathfinding.rs index 3a69562..ec44a11 100644 --- a/src/pathfinding.rs +++ b/src/pathfinding.rs @@ -19,7 +19,7 @@ use crate::{ navigation::{NavigationAction, RotationSpeed}, }; -#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)] +#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug, Reflect)] pub struct NegotiatePathAction; impl Actionlike for NegotiatePathAction { @@ -404,18 +404,18 @@ pub struct PathfindingPlugin; impl Plugin for PathfindingPlugin { fn build(&self, app: &mut App) { - app.add_plugin(InputManagerPlugin::::default()) + app.add_plugins(InputManagerPlugin::::default()) .register_type::() .register_type::() .register_type::() .register_type::() - .add_systems((negotiate_path, poll_tasks).in_base_set(CoreSet::PreUpdate)) + .add_systems(PreUpdate, (negotiate_path, poll_tasks)) .add_systems( + PreUpdate, (actions, calculate_path) .chain() - .in_base_set(CoreSet::PreUpdate) .after(InputManagerSystem::Tick), ) - .add_system(remove_destination.in_base_set(CoreSet::PostUpdate)); + .add_systems(PostUpdate, remove_destination); } } diff --git a/src/sound/footstep.rs b/src/sound/footstep.rs index 1301b07..d00f235 100644 --- a/src/sound/footstep.rs +++ b/src/sound/footstep.rs @@ -127,11 +127,9 @@ pub struct FootstepPlugin; impl Plugin for FootstepPlugin { fn build(&self, app: &mut App) { - app.add_system(added.in_base_set(CoreSet::PreUpdate)) - .add_system( - update - .after(TransformSystem::TransformPropagate) - .in_base_set(CoreSet::PostUpdate), - ); + app.add_systems(PreUpdate, added).add_systems( + PostUpdate, + update.after(TransformSystem::TransformPropagate), + ); } } diff --git a/src/sound/icon.rs b/src/sound/icon.rs index f47c499..685655b 100644 --- a/src/sound/icon.rs +++ b/src/sound/icon.rs @@ -43,7 +43,7 @@ fn added(mut commands: Commands, icons: Query<(Entity, &SoundIcon), Added( ) where S: States, { - if !config.states.is_empty() && !config.states.contains(&state.0) { + if !config.states.is_empty() && !config.states.contains(state.get()) { return; } for visible in &viewers { @@ -93,9 +93,8 @@ fn update( } } let buffer = icon.audio.clone(); - let audio: Audio = buffer.into(); - if sound.audio != audio { - sound.audio = audio; + if sound.audio != buffer { + sound.audio = buffer; } sound.gain = icon.gain; sound.pitch = icon.pitch; @@ -197,16 +196,11 @@ where { fn build(&self, app: &mut App) { app.insert_resource(self.clone()) - .add_systems((added, reset_timer_on_visibility_gain).in_base_set(CoreSet::PreUpdate)) + .add_systems(PreUpdate, (added, reset_timer_on_visibility_gain)) + .add_systems(PreUpdate, (exploration_focus_changed, update::).chain()) .add_systems( - (exploration_focus_changed, update::) - .chain() - .in_base_set(CoreSet::PreUpdate), - ) - .add_system( - exploration_focus_removed - .in_base_set(CoreSet::PostUpdate) - .after(exploration_focus_changed), + PostUpdate, + exploration_focus_removed.after(exploration_focus_changed), ); } } diff --git a/src/sound/pitch_shift.rs b/src/sound/pitch_shift.rs index 04ca115..f012532 100644 --- a/src/sound/pitch_shift.rs +++ b/src/sound/pitch_shift.rs @@ -154,8 +154,11 @@ impl Plugin for PitchShiftPlugin { .register_type::() .init_resource::() .init_resource::() - .add_system(tag_behind.in_base_set(CoreSet::PreUpdate)) - .add_systems((behind_added, sound_icon_changed, sound_changed, sync_config)) - .add_system(behind_removed.in_base_set(CoreSet::PostUpdate)); + .add_systems(PreUpdate, tag_behind) + .add_systems( + Update, + (behind_added, sound_icon_changed, sound_changed, sync_config), + ) + .add_systems(PostUpdate, behind_removed); } } diff --git a/src/sound/volumetric.rs b/src/sound/volumetric.rs index 3e1714f..9bb3b52 100644 --- a/src/sound/volumetric.rs +++ b/src/sound/volumetric.rs @@ -56,11 +56,10 @@ pub struct VolumetricPlugin; impl Plugin for VolumetricPlugin { fn build(&self, app: &mut App) { app.register_type::() - .add_system( - update - .in_base_set(CoreSet::PostUpdate) - .before(TransformSystem::TransformPropagate), + .add_systems( + PostUpdate, + update.before(TransformSystem::TransformPropagate), ) - .add_system(removed.in_base_set(CoreSet::PostUpdate)); + .add_systems(PostUpdate, removed); } } diff --git a/src/visibility.rs b/src/visibility.rs index a367cca..7393748 100644 --- a/src/visibility.rs +++ b/src/visibility.rs @@ -233,6 +233,7 @@ impl ViewshedBundle { } } +#[derive(Event)] pub enum VisibilityChanged { Gained { viewer: Entity, viewed: Entity }, Lost { viewer: Entity, viewed: Entity }, @@ -441,15 +442,13 @@ impl Plugin for VisibilityPlug fn build(&self, app: &mut App) { app.add_event::() .add_systems( + PreUpdate, ( add_visibility_indices::, update_viewshed, update_revealed_tiles::, - ) - .in_base_set(CoreSet::PreUpdate), + ), ) - .add_systems( - (log_visible, viewshed_removed, remove_visible).in_base_set(CoreSet::PostUpdate), - ); + .add_systems(PostUpdate, (log_visible, viewshed_removed, remove_visible)); } }