diff --git a/Cargo.toml b/Cargo.toml index 5363f0a..8bc6281 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -bevy = "0.15" +bevy = "0.16.1" fastrand = "2.1.1" # ref: https://github.com/bevyengine/bevy/pull/3992 [workspace] diff --git a/src/game/ai/autofire.rs b/src/game/ai/autofire.rs index 90db690..a4f064e 100644 --- a/src/game/ai/autofire.rs +++ b/src/game/ai/autofire.rs @@ -37,9 +37,9 @@ pub fn fire_controller( rotation: transform.rotation, hitmask: collider.hitmask, // Hurt player only }; - bullet_fired_event.send(event); + bullet_fired_event.write(event); - audio_event.send(AudioEvent { + audio_event.write(AudioEvent { clip: weapon.firing_audio_clip.clone(), }); } diff --git a/src/game/collisions.rs b/src/game/collisions.rs index f54e479..4e23f93 100644 --- a/src/game/collisions.rs +++ b/src/game/collisions.rs @@ -68,7 +68,7 @@ pub fn check_collisions( if collision.is_some() { if let Some(_) = a_bullet { // If a is a bullet, despawn it on impact - commands.entity(a_entity).despawn_recursive(); + commands.entity(a_entity).despawn(); } b_health.hp = max(b_health.hp - a_collider.damage, 0); @@ -81,34 +81,34 @@ pub fn check_collisions( if b_health.hp == 0 { if let Some(d) = b_death_points { - score_event.send(ScoreEvent { + score_event.write(ScoreEvent { increment: d.points, }); } if let Some(s) = b_camera_shake { - camera_shake_event.send(CameraShakeEvent { + camera_shake_event.write(CameraShakeEvent { magnitude: s.magnitude, duration_secs: s.duration_secs, }); - explosion_event.send(ExplosionEvent { + explosion_event.write(ExplosionEvent { position: b_transform.translation, lifetime: 0.25, }); } if let Some(_) = b_player { - player_death_event.send(PlayerDeathEvent::default()); + player_death_event.write(PlayerDeathEvent::default()); } // Play death sound - audio_event.send(AudioEvent { + audio_event.write(AudioEvent { clip: b_health.death_sound.clone(), }); - commands.entity(b_entity).despawn_recursive(); + commands.entity(b_entity).despawn(); } - collision_event.send_default(); + collision_event.write_default(); } } } diff --git a/src/game/despawner.rs b/src/game/despawner.rs index e1cfe83..e48bca5 100644 --- a/src/game/despawner.rs +++ b/src/game/despawner.rs @@ -25,7 +25,7 @@ fn timed_despawn( for (entity, mut despawner) in &mut query { despawner.timer.tick(time.delta()); if despawner.timer.finished() { - commands.entity(entity).despawn_recursive(); + commands.entity(entity).despawn(); } } } @@ -45,7 +45,7 @@ fn timed_oob_despawn( { despawner.timer.tick(time.delta()); if despawner.timer.finished() { - commands.entity(entity).despawn_recursive(); + commands.entity(entity).despawn(); } } else { despawner.timer.reset(); diff --git a/src/game/levels/mod.rs b/src/game/levels/mod.rs index cab5a89..7de1a12 100644 --- a/src/game/levels/mod.rs +++ b/src/game/levels/mod.rs @@ -1,4 +1,5 @@ -use bevy::{prelude::*, utils::Duration}; +use bevy::prelude::*; +use std::time::Duration; use crate::utils::despawn_all; @@ -84,7 +85,7 @@ fn level_periodic_spawn( spawner.ttl_timer.reset(); } else { spawner.index = 0; - level_end_event.send(LevelEndEvent {}); + level_end_event.write(LevelEndEvent {}); } } diff --git a/src/game/particles/mod.rs b/src/game/particles/mod.rs index a91e01d..90459cf 100644 --- a/src/game/particles/mod.rs +++ b/src/game/particles/mod.rs @@ -27,7 +27,7 @@ fn update_emitter( for (entity, emitter) in &mut query{ emitter.lifetime_timer.tick(time.delta()); if emitter.lifetime_timer.just_finished(){ - commands.entity(entity).despawn_recursive(); + commands.entity(entity).despawn(); } } } diff --git a/src/game/player.rs b/src/game/player.rs index 9e14a14..b5d8d21 100644 --- a/src/game/player.rs +++ b/src/game/player.rs @@ -170,8 +170,8 @@ fn send_projectile_spawn_event( rotation: transform.rotation, hitmask: collider.hitmask, // Bullets have the same hitmask as the collider attached to the firer }; - bullet_fired_event.send(event); - audio_event.send(AudioEvent { + bullet_fired_event.write(event); + audio_event.write(AudioEvent { clip: weapon.firing_audio_clip.clone(), }); // TODO: Perhaps tie this audio event to the bullet fired event rather than with the player controls! } diff --git a/src/game/ui/mod.rs b/src/game/ui/mod.rs index c58ec02..36d6376 100644 --- a/src/game/ui/mod.rs +++ b/src/game/ui/mod.rs @@ -53,8 +53,9 @@ fn on_score_event( ) { for score_event in score_events.read() { scoreboard.score += score_event.increment; - let mut player_score_text = text_query.single_mut(); - **player_score_text = format!("SCORE: {}", scoreboard.score); + if let Ok(mut player_score_text) = text_query.single_mut() { + **player_score_text = format!("SCORE: {}", scoreboard.score); + } } score_events.clear(); // Clear buffer to prevent double registration of scoring events (???) } diff --git a/src/game/vfx/mod.rs b/src/game/vfx/mod.rs index ab0a126..3b7bf09 100644 --- a/src/game/vfx/mod.rs +++ b/src/game/vfx/mod.rs @@ -1,7 +1,8 @@ use std::f32::consts::PI; use crate::constants::CAMERA_FAR; -use bevy::{prelude::*, utils::Duration}; +use bevy::prelude::*; +use std::time::Duration; use fastrand; diff --git a/src/menus/mod.rs b/src/menus/mod.rs index 22bfe69..8cce3ca 100644 --- a/src/menus/mod.rs +++ b/src/menus/mod.rs @@ -109,7 +109,7 @@ fn menu_action( if *interaction == Interaction::Pressed { match menu_button_action { MenuButtonAction::Quit => { - app_exit_events.send(AppExit::Success); + app_exit_events.write(AppExit::Success); } MenuButtonAction::MainMenu => { menu_state.set(MenuState::Main); diff --git a/src/utils.rs b/src/utils.rs index 85e228b..f1ad046 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -2,6 +2,6 @@ use bevy::prelude::*; // Utility function pub fn despawn_all(to_despawn: Query>, mut commands: Commands) { for entity in &to_despawn { - commands.entity(entity).despawn_recursive(); + commands.entity(entity).despawn(); } }