single global observers root node (#25)
plus auto name observer macro `global_observer`
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use super::{Projectile, TriggerGun};
|
||||
use crate::{
|
||||
GameState, billboards::Billboard, loading_assets::GameAssets, physics_layers::GameLayer,
|
||||
sounds::PlaySound, utils::sprite_3d_animation::AnimationTimer,
|
||||
GameState, billboards::Billboard, global_observer, loading_assets::GameAssets,
|
||||
physics_layers::GameLayer, sounds::PlaySound, utils::sprite_3d_animation::AnimationTimer,
|
||||
};
|
||||
use avian3d::prelude::{
|
||||
Collider, CollisionLayers, CollisionStarted, LayerMask, PhysicsLayer, Sensor,
|
||||
@@ -30,7 +30,8 @@ pub fn plugin(app: &mut App) {
|
||||
Update,
|
||||
(update, shot_collision, timeout).run_if(in_state(GameState::Playing)),
|
||||
);
|
||||
app.add_observer(on_trigger_state);
|
||||
|
||||
global_observer!(app, on_trigger_gun);
|
||||
}
|
||||
|
||||
fn setup(mut commands: Commands, assets: Res<GameAssets>, mut sprite_params: Sprite3dParams) {
|
||||
@@ -43,7 +44,7 @@ fn setup(mut commands: Commands, assets: Res<GameAssets>, mut sprite_params: Spr
|
||||
});
|
||||
}
|
||||
|
||||
fn on_trigger_state(
|
||||
fn on_trigger_gun(
|
||||
trigger: Trigger<TriggerGun>,
|
||||
mut commands: Commands,
|
||||
query_transform: Query<&Transform>,
|
||||
|
||||
Reference in New Issue
Block a user