Rename "event" module to be plural "events.rs"
This commit is contained in:
@@ -8,7 +8,7 @@ use std::time::Duration;
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
GameAssets, Lifetime, WorldSize, config::ASTEROID_LIFETIME, event::AsteroidDestroy,
|
GameAssets, Lifetime, WorldSize, config::ASTEROID_LIFETIME, events::AsteroidDestroy,
|
||||||
physics::Velocity,
|
physics::Velocity,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
26
src/lib.rs
26
src/lib.rs
@@ -1,6 +1,6 @@
|
|||||||
mod asteroids;
|
mod asteroids;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
mod event;
|
mod events;
|
||||||
mod physics;
|
mod physics;
|
||||||
mod preparation_widget;
|
mod preparation_widget;
|
||||||
mod ship;
|
mod ship;
|
||||||
@@ -74,9 +74,9 @@ impl Plugin for AsteroidPlugin {
|
|||||||
.run_if(in_state(GameState::Playing)),
|
.run_if(in_state(GameState::Playing)),
|
||||||
)
|
)
|
||||||
.add_event::<asteroids::SpawnAsteroid>()
|
.add_event::<asteroids::SpawnAsteroid>()
|
||||||
.add_event::<event::AsteroidDestroy>()
|
.add_event::<events::AsteroidDestroy>()
|
||||||
.add_event::<event::ShipDestroy>()
|
.add_event::<events::ShipDestroy>()
|
||||||
.add_event::<event::BulletDestroy>();
|
.add_event::<events::BulletDestroy>();
|
||||||
app.insert_state(GameState::Playing);
|
app.insert_state(GameState::Playing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,9 +101,9 @@ fn debug_collision_event_printer(mut collision_events: EventReader<CollisionEven
|
|||||||
/// | 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) |
|
||||||
fn collision_listener(
|
fn collision_listener(
|
||||||
mut collisions: EventReader<CollisionEvent>,
|
mut collisions: EventReader<CollisionEvent>,
|
||||||
mut ship_writer: EventWriter<event::ShipDestroy>,
|
mut ship_writer: EventWriter<events::ShipDestroy>,
|
||||||
mut asteroid_writer: EventWriter<event::AsteroidDestroy>,
|
mut asteroid_writer: EventWriter<events::AsteroidDestroy>,
|
||||||
mut bullet_writer: EventWriter<event::BulletDestroy>,
|
mut bullet_writer: EventWriter<events::BulletDestroy>,
|
||||||
player: Single<Entity, With<Ship>>,
|
player: Single<Entity, With<Ship>>,
|
||||||
bullets: Query<&Bullet>,
|
bullets: Query<&Bullet>,
|
||||||
rocks: Query<&Asteroid>,
|
rocks: Query<&Asteroid>,
|
||||||
@@ -123,12 +123,12 @@ fn collision_listener(
|
|||||||
if rocks.contains(*two) {
|
if rocks.contains(*two) {
|
||||||
// player-asteroid collision
|
// player-asteroid collision
|
||||||
dbg!("Writing ShipDestroy event");
|
dbg!("Writing ShipDestroy event");
|
||||||
ship_writer.write(event::ShipDestroy);
|
ship_writer.write(events::ShipDestroy);
|
||||||
} // else, we don't care
|
} // else, we don't care
|
||||||
} else if *two == *player {
|
} else if *two == *player {
|
||||||
if rocks.contains(*one) {
|
if rocks.contains(*one) {
|
||||||
dbg!("Writing ShipDestroy event");
|
dbg!("Writing ShipDestroy event");
|
||||||
ship_writer.write(event::ShipDestroy);
|
ship_writer.write(events::ShipDestroy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,14 +136,14 @@ fn collision_listener(
|
|||||||
if bullets.contains(*one) {
|
if bullets.contains(*one) {
|
||||||
if rocks.contains(*two) {
|
if rocks.contains(*two) {
|
||||||
dbg!("Writing AsteroidDestroy & BulletDestroy events");
|
dbg!("Writing AsteroidDestroy & BulletDestroy events");
|
||||||
asteroid_writer.write(event::AsteroidDestroy(*two));
|
asteroid_writer.write(events::AsteroidDestroy(*two));
|
||||||
bullet_writer.write(event::BulletDestroy(*one));
|
bullet_writer.write(events::BulletDestroy(*one));
|
||||||
}
|
}
|
||||||
} else if rocks.contains(*one) {
|
} else if rocks.contains(*one) {
|
||||||
if bullets.contains(*two) {
|
if bullets.contains(*two) {
|
||||||
dbg!("Writing AsteroidDestroy & BulletDestroy events");
|
dbg!("Writing AsteroidDestroy & BulletDestroy events");
|
||||||
asteroid_writer.write(event::AsteroidDestroy(*one));
|
asteroid_writer.write(events::AsteroidDestroy(*one));
|
||||||
bullet_writer.write(event::BulletDestroy(*two));
|
bullet_writer.write(events::BulletDestroy(*two));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
AngularVelocity, GameAssets, GameState, Lives,
|
AngularVelocity, GameAssets, GameState, Lives,
|
||||||
asteroids::Asteroid,
|
asteroids::Asteroid,
|
||||||
event::{BulletDestroy, ShipDestroy},
|
events::{BulletDestroy, ShipDestroy},
|
||||||
physics::{Velocity, Wrapping},
|
physics::{Velocity, Wrapping},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user