Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/game/ai/autofire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}
Expand Down
16 changes: 8 additions & 8 deletions src/game/collisions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/game/despawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
Expand All @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions src/game/levels/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use bevy::{prelude::*, utils::Duration};
use bevy::prelude::*;
use std::time::Duration;

use crate::utils::despawn_all;

Expand Down Expand Up @@ -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 {});
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/game/particles/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
4 changes: 2 additions & 2 deletions src/game/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}
Expand Down
5 changes: 3 additions & 2 deletions src/game/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 (???)
}
3 changes: 2 additions & 1 deletion src/game/vfx/mod.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/menus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ use bevy::prelude::*;
// Utility function
pub fn despawn_all<T: Component>(to_despawn: Query<Entity, With<T>>, mut commands: Commands) {
for entity in &to_despawn {
commands.entity(entity).despawn_recursive();
commands.entity(entity).despawn();
}
}
Loading