diff --git a/assets/models/beaming.glb b/assets/models/beaming.glb new file mode 100644 index 0000000..3988702 Binary files /dev/null and b/assets/models/beaming.glb differ diff --git a/assets/textures/beaming.png b/assets/textures/beaming.png new file mode 100644 index 0000000..2b755f6 Binary files /dev/null and b/assets/textures/beaming.png differ diff --git a/src/abilities/arrow.rs b/src/abilities/arrow.rs index 2dfbf6a..17ec2dd 100644 --- a/src/abilities/arrow.rs +++ b/src/abilities/arrow.rs @@ -106,7 +106,7 @@ fn update( ), ) .insert(( - Billboard, + Billboard::All, Transform::from_translation(first_hit.point1), NotShadowCaster, AnimationTimer::new(Timer::from_seconds(0.005, TimerMode::Repeating)), diff --git a/src/abilities/curver.rs b/src/abilities/curver.rs index 8e6b8ca..2a20180 100644 --- a/src/abilities/curver.rs +++ b/src/abilities/curver.rs @@ -195,7 +195,7 @@ fn shot_collision( .bundle_with_atlas(&mut sprite_params, texture_atlas), ) .insert(( - Billboard, + Billboard::All, Transform::from_translation(shot_pos), NotShadowCaster, AnimationTimer::new(Timer::from_seconds(0.01, TimerMode::Repeating)), diff --git a/src/abilities/gun.rs b/src/abilities/gun.rs index 62866f1..6e0263b 100644 --- a/src/abilities/gun.rs +++ b/src/abilities/gun.rs @@ -191,7 +191,7 @@ fn shot_collision( .bundle_with_atlas(&mut sprite_params, texture_atlas), ) .insert(( - Billboard, + Billboard::All, Transform::from_translation(shot_pos), NotShadowCaster, AnimationTimer::new(Timer::from_seconds(0.01, TimerMode::Repeating)), diff --git a/src/abilities/missile.rs b/src/abilities/missile.rs index a831b5c..0ad761a 100644 --- a/src/abilities/missile.rs +++ b/src/abilities/missile.rs @@ -192,7 +192,7 @@ fn shot_collision( .bundle_with_atlas(&mut sprite_params, texture_atlas), ) .insert(( - Billboard, + Billboard::All, Transform::from_translation(shot_pos), NotShadowCaster, AnimationTimer::new(Timer::from_seconds(0.01, TimerMode::Repeating)), diff --git a/src/abilities/thrown.rs b/src/abilities/thrown.rs index fbd1035..d3a556d 100644 --- a/src/abilities/thrown.rs +++ b/src/abilities/thrown.rs @@ -174,7 +174,7 @@ fn shot_collision( ), ) .insert(( - Billboard, + Billboard::All, Transform::from_translation(shot_pos), NotShadowCaster, AnimationTimer::new(Timer::from_seconds(0.02, TimerMode::Repeating)), diff --git a/src/aim/marker.rs b/src/aim/marker.rs index 6366134..dda88c3 100644 --- a/src/aim/marker.rs +++ b/src/aim/marker.rs @@ -42,7 +42,7 @@ fn marker_event( let id = commands .spawn(( Name::new("aim-marker"), - Billboard, + Billboard::All, TargetMarker, Transform::default(), Sprite3dBuilder { diff --git a/src/head_drop.rs b/src/head_drop.rs index b1b750b..da5a453 100644 --- a/src/head_drop.rs +++ b/src/head_drop.rs @@ -134,7 +134,7 @@ fn on_head_drop( || drop.impulse, ) .with_child(( - Billboard, + Billboard::All, SquishAnimation(2.6), SceneRoot(mesh.scenes[0].clone()), )); diff --git a/src/heal_effect.rs b/src/heal_effect.rs index 0e585ba..196fbfc 100644 --- a/src/heal_effect.rs +++ b/src/heal_effect.rs @@ -62,7 +62,7 @@ fn update_effects( cmds.entity(e).with_child(( Name::new("heal-particle"), SceneRoot(assets.mesh_heal_particle.clone()), - Billboard, + Billboard::All, Transform::from_translation(start_pos), HealParticle { start_scale, diff --git a/src/keys.rs b/src/keys.rs index 1f7a45d..82fdabc 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -43,7 +43,7 @@ fn on_spawn_key(trigger: Trigger, mut commands: Commands, assets: Res< Restitution::new(0.6), Children::spawn(( Spawn(( - Billboard, + Billboard::All, SquishAnimation(2.6), SceneRoot(assets.mesh_key.clone()), )), diff --git a/src/loading_assets.rs b/src/loading_assets.rs index 46dbbc4..0b66904 100644 --- a/src/loading_assets.rs +++ b/src/loading_assets.rs @@ -110,6 +110,9 @@ pub struct GameAssets { #[asset(path = "models/medic_particle.glb#Scene0")] pub mesh_heal_particle: Handle, + #[asset(path = "models/beaming.glb#Scene0")] + pub beaming: Handle, + #[asset(path = "models/projectiles", collection(mapped, typed))] pub projectiles: HashMap>, diff --git a/src/npc.rs b/src/npc.rs index d2b2c3e..f63939d 100644 --- a/src/npc.rs +++ b/src/npc.rs @@ -9,10 +9,12 @@ use crate::{ heads_database::HeadsDatabase, hitpoints::{Hitpoints, Kill}, keys::KeySpawn, + loading_assets::GameAssets, sounds::PlaySound, tb_entities::EnemySpawn, + utils::billboards::Billboard, }; -use bevy::prelude::*; +use bevy::{pbr::NotShadowCaster, prelude::*}; use std::collections::HashMap; #[derive(Component, Reflect)] @@ -25,14 +27,23 @@ struct NpcSpawning { spawn_index: u32, } +#[derive(Component, Reflect)] +#[reflect(Component)] +pub struct SpawningBeam(pub f32); + #[derive(Event)] struct OnCheckSpawns; +#[derive(Event)] +pub struct SpawnCharacter(pub Vec3); + pub fn plugin(app: &mut App) { app.init_resource::(); app.add_systems(OnEnter(GameState::Playing), setup); + app.add_systems(Update, update_beams.run_if(in_state(GameState::Playing))); global_observer!(app, on_spawn_check); + global_observer!(app, on_spawn); } fn setup(mut commands: Commands) { @@ -43,7 +54,7 @@ fn setup(mut commands: Commands) { fn on_spawn_check( _trigger: Trigger, mut commands: Commands, - query: Query<(Entity, &EnemySpawn), Without>, + query: Query<(Entity, &EnemySpawn, &Transform), Without>, heads_db: Res, spawning: Res, ) { @@ -53,7 +64,7 @@ fn on_spawn_check( names.insert(heads_db.head_key(i).to_string(), i); } - for (e, spawn) in query.iter() { + for (e, spawn, transform) in query.iter() { if let Some(order) = spawn.spawn_order { if order > spawning.spawn_index { continue; @@ -79,6 +90,7 @@ fn on_spawn_check( .with_child((Name::from("body-rig"), AnimatedCharacter::new(id))) .observe(on_kill); + commands.trigger(SpawnCharacter(transform.translation)); commands.trigger(PlaySound::Beaming); } } @@ -107,3 +119,35 @@ fn on_kill( commands.trigger(KeySpawn(transform.translation, enemy.key.clone())); } } + +fn on_spawn( + trigger: Trigger, + mut commands: Commands, + assets: Res, + time: Res