WIP on engine upgrade
This commit is contained in:
@@ -77,10 +77,10 @@ impl Plugin for AsteroidPlugin {
|
|||||||
)
|
)
|
||||||
.run_if(in_state(GameState::Playing)),
|
.run_if(in_state(GameState::Playing)),
|
||||||
)
|
)
|
||||||
.add_event::<messages::SpawnAsteroid>()
|
.add_message::<messages::SpawnAsteroid>()
|
||||||
.add_event::<messages::AsteroidDestroy>()
|
.add_message::<messages::AsteroidDestroy>()
|
||||||
.add_event::<messages::ShipDestroy>()
|
.add_message::<messages::ShipDestroy>()
|
||||||
.add_event::<messages::BulletDestroy>();
|
.add_message::<messages::BulletDestroy>();
|
||||||
app.insert_state(GameState::TitleScreen);
|
app.insert_state(GameState::TitleScreen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use bevy::{
|
|||||||
ecs::{
|
ecs::{
|
||||||
component::Component,
|
component::Component,
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
event::{EventReader, EventWriter},
|
message::{MessageReader, MessageWriter},
|
||||||
query::With,
|
query::With,
|
||||||
system::{Commands, Query, Res, ResMut, Single},
|
system::{Commands, Query, Res, ResMut, Single},
|
||||||
},
|
},
|
||||||
@@ -69,7 +69,7 @@ pub struct Debris;
|
|||||||
|
|
||||||
/// Responds to [`SpawnAsteroid`] events, spawning as specified
|
/// Responds to [`SpawnAsteroid`] events, spawning as specified
|
||||||
pub fn spawn_asteroid(
|
pub fn spawn_asteroid(
|
||||||
mut events: EventReader<SpawnAsteroid>,
|
mut events: MessageReader<SpawnAsteroid>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
game_assets: Res<GameAssets>,
|
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
|
/// The velocity of the child asteroids is scattered somewhat, as if they were
|
||||||
/// explosively pushed apart.
|
/// explosively pushed apart.
|
||||||
pub fn split_asteroids(
|
pub fn split_asteroids(
|
||||||
mut destroy_events: EventReader<AsteroidDestroy>,
|
mut destroy_events: MessageReader<AsteroidDestroy>,
|
||||||
mut respawn_events: EventWriter<SpawnAsteroid>,
|
mut respawn_events: MessageWriter<SpawnAsteroid>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
query: Query<(&Transform, &Asteroid, &Velocity)>,
|
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
|
/// Watch for [`BulletDestroy`] events and despawn
|
||||||
/// the associated bullet.
|
/// 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() {
|
for event in events.read() {
|
||||||
commands.entity(event.0).despawn();
|
commands.entity(event.0).despawn();
|
||||||
}
|
}
|
||||||
@@ -187,7 +187,7 @@ pub fn bullet_impact_listener(mut commands: Commands, mut events: EventReader<Bu
|
|||||||
/// - Clear all asteroids
|
/// - Clear all asteroids
|
||||||
/// - Respawn player
|
/// - Respawn player
|
||||||
pub fn ship_impact_listener(
|
pub fn ship_impact_listener(
|
||||||
mut events: EventReader<ShipDestroy>,
|
mut events: MessageReader<ShipDestroy>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
mut lives: ResMut<Lives>,
|
mut lives: ResMut<Lives>,
|
||||||
rocks: Query<Entity, With<Asteroid>>,
|
rocks: Query<Entity, With<Asteroid>>,
|
||||||
|
|||||||
@@ -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 & 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) |
|
/// | 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(
|
pub fn collision_listener(
|
||||||
mut collisions: EventReader<CollisionEvent>,
|
mut collisions: BufferedReader<CollisionEvent>,
|
||||||
mut ship_writer: EventWriter<messages::ShipDestroy>,
|
mut ship_writer: MessageWriter<messages::ShipDestroy>,
|
||||||
mut asteroid_writer: EventWriter<messages::AsteroidDestroy>,
|
mut asteroid_writer: MessageWriter<messages::AsteroidDestroy>,
|
||||||
mut bullet_writer: EventWriter<messages::BulletDestroy>,
|
mut bullet_writer: MessageWriter<messages::BulletDestroy>,
|
||||||
player: Single<Entity, With<Ship>>,
|
player: Single<Entity, With<Ship>>,
|
||||||
bullets: Query<&Bullet>,
|
bullets: Query<&Bullet>,
|
||||||
rocks: Query<&Asteroid>,
|
rocks: Query<&Asteroid>,
|
||||||
|
|||||||
Reference in New Issue
Block a user