single global observers root node (#25)

plus auto name observer macro `global_observer`
This commit is contained in:
extrawurst
2025-04-07 18:22:29 +02:00
committed by GitHub
parent 92da1587ba
commit ddc57ec1e8
17 changed files with 94 additions and 37 deletions

View File

@@ -1,7 +1,12 @@
use super::TriggerThrow;
use crate::{
GameState, billboards::Billboard, hitpoints::Hit, loading_assets::GameAssets,
physics_layers::GameLayer, sounds::PlaySound, utils::sprite_3d_animation::AnimationTimer,
GameState,
billboards::Billboard,
hitpoints::Hit,
loading_assets::GameAssets,
physics_layers::GameLayer,
sounds::PlaySound,
utils::{global_observer, sprite_3d_animation::AnimationTimer},
};
use avian3d::prelude::*;
use bevy::{pbr::NotShadowCaster, prelude::*};
@@ -35,8 +40,9 @@ pub fn plugin(app: &mut App) {
app.add_systems(OnEnter(GameState::Playing), setup);
app.add_systems(Update, shot_collision.run_if(in_state(GameState::Playing)));
app.add_systems(FixedUpdate, update_auto_rotation);
app.add_observer(on_trigger_state);
app.add_observer(on_explosion);
global_observer!(app, on_trigger_thrown);
global_observer!(app, on_explosion);
}
fn on_explosion(
@@ -75,7 +81,7 @@ fn setup(mut commands: Commands, assets: Res<GameAssets>, mut sprite_params: Spr
});
}
fn on_trigger_state(
fn on_trigger_thrown(
trigger: Trigger<TriggerThrow>,
mut commands: Commands,
query_transform: Query<&Transform>,