single global observers root node (#25)
plus auto name observer macro `global_observer`
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
GameState, billboards::Billboard, loading_assets::GameAssets, player::Player,
|
||||
GameState, billboards::Billboard, global_observer, loading_assets::GameAssets, player::Player,
|
||||
sounds::PlaySound, squish_animation::SquishAnimation,
|
||||
};
|
||||
use avian3d::prelude::*;
|
||||
@@ -18,10 +18,11 @@ pub struct KeyCollected(pub String);
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(Update, collect_key.run_if(in_state(GameState::Playing)));
|
||||
app.add_observer(on_spawn);
|
||||
|
||||
global_observer!(app, on_spawn_key);
|
||||
}
|
||||
|
||||
fn on_spawn(trigger: Trigger<KeySpawn>, mut commands: Commands, assets: Res<GameAssets>) {
|
||||
fn on_spawn_key(trigger: Trigger<KeySpawn>, mut commands: Commands, assets: Res<GameAssets>) {
|
||||
let KeySpawn(position, id) = trigger.event();
|
||||
|
||||
let angle = rand::random::<f32>() * PI * 2.;
|
||||
|
||||
Reference in New Issue
Block a user