WIP on engine upgrade

This commit is contained in:
2025-10-04 11:58:45 -05:00
parent 7bd88c702f
commit 6e425e8eb9
3 changed files with 14 additions and 14 deletions

View File

@@ -77,10 +77,10 @@ impl Plugin for AsteroidPlugin {
)
.run_if(in_state(GameState::Playing)),
)
.add_event::<messages::SpawnAsteroid>()
.add_event::<messages::AsteroidDestroy>()
.add_event::<messages::ShipDestroy>()
.add_event::<messages::BulletDestroy>();
.add_message::<messages::SpawnAsteroid>()
.add_message::<messages::AsteroidDestroy>()
.add_message::<messages::ShipDestroy>()
.add_message::<messages::BulletDestroy>();
app.insert_state(GameState::TitleScreen);
}
}

View File

@@ -6,7 +6,7 @@ use bevy::{
ecs::{
component::Component,
entity::Entity,
event::{EventReader, EventWriter},
message::{MessageReader, MessageWriter},
query::With,
system::{Commands, Query, Res, ResMut, Single},
},
@@ -69,7 +69,7 @@ pub struct Debris;
/// Responds to [`SpawnAsteroid`] events, spawning as specified
pub fn spawn_asteroid(
mut events: EventReader<SpawnAsteroid>,
mut events: MessageReader<SpawnAsteroid>,
mut commands: Commands,
game_assets: Res<GameAssets>,
) {
@@ -109,8 +109,8 @@ pub fn spawn_asteroid(
/// The velocity of the child asteroids is scattered somewhat, as if they were
/// explosively pushed apart.
pub fn split_asteroids(
mut destroy_events: EventReader<AsteroidDestroy>,
mut respawn_events: EventWriter<SpawnAsteroid>,
mut destroy_events: MessageReader<AsteroidDestroy>,
mut respawn_events: MessageWriter<SpawnAsteroid>,
mut commands: Commands,
query: Query<(&Transform, &Asteroid, &Velocity)>,
) {
@@ -171,7 +171,7 @@ pub fn spawn_player(mut commands: Commands, game_assets: Res<GameAssets>) {
/// Watch for [`BulletDestroy`] events and despawn
/// the associated bullet.
pub fn bullet_impact_listener(mut commands: Commands, mut events: EventReader<BulletDestroy>) {
pub fn bullet_impact_listener(mut commands: Commands, mut events: MessageReader<BulletDestroy>) {
for event in events.read() {
commands.entity(event.0).despawn();
}
@@ -187,7 +187,7 @@ pub fn bullet_impact_listener(mut commands: Commands, mut events: EventReader<Bu
/// - Clear all asteroids
/// - Respawn player
pub fn ship_impact_listener(
mut events: EventReader<ShipDestroy>,
mut events: MessageReader<ShipDestroy>,
mut commands: Commands,
mut lives: ResMut<Lives>,
rocks: Query<Entity, With<Asteroid>>,

View File

@@ -89,10 +89,10 @@ pub(crate) fn wrap_entities(
/// | Bullet & Bullet | Nothing. Bullets won't collide with each other (and probably can't under normal gameplay conditions) |
/// | Bullet & Ship | Nothing. The player shouldn't be able to shoot themselves (and the Flying Saucer hasn't been impl.'d, so it's bullets don't count) |
pub fn collision_listener(
mut collisions: EventReader<CollisionEvent>,
mut ship_writer: EventWriter<messages::ShipDestroy>,
mut asteroid_writer: EventWriter<messages::AsteroidDestroy>,
mut bullet_writer: EventWriter<messages::BulletDestroy>,
mut collisions: BufferedReader<CollisionEvent>,
mut ship_writer: MessageWriter<messages::ShipDestroy>,
mut asteroid_writer: MessageWriter<messages::AsteroidDestroy>,
mut bullet_writer: MessageWriter<messages::BulletDestroy>,
player: Single<Entity, With<Ship>>,
bullets: Query<&Bullet>,
rocks: Query<&Asteroid>,