* move client/server/config into shared * move platforms into shared * move head drops into shared * move tb_entities to shared * reduce server to just a call into shared * get solo play working * fix server opening window * fix fmt * extracted a few more modules from client * near completely migrated client * fixed duplicate CharacterInputEnabled definition * simplify a few things related to builds * more simplifications * fix warnings/check * ci update * address comments * try fixing macos steam build * address comments * address comments * CI tweaks with default client feature --------- Co-authored-by: PROMETHIA-27 <electriccobras@gmail.com>
38 lines
1.0 KiB
Rust
38 lines
1.0 KiB
Rust
use crate::{global_observer, hitpoints::Hit, physics_layers::GameLayer};
|
|
use avian3d::prelude::*;
|
|
use bevy::prelude::*;
|
|
|
|
#[derive(Event, Debug)]
|
|
pub struct Explosion {
|
|
pub position: Vec3,
|
|
pub radius: f32,
|
|
pub damage: u32,
|
|
}
|
|
|
|
pub fn plugin(app: &mut App) {
|
|
global_observer!(app, on_explosion);
|
|
}
|
|
|
|
fn on_explosion(explosion: On<Explosion>, mut commands: Commands, spatial_query: SpatialQuery) {
|
|
let explosion = explosion.event();
|
|
let intersections = {
|
|
spatial_query.shape_intersections(
|
|
&Collider::sphere(explosion.radius),
|
|
explosion.position,
|
|
Quat::default(),
|
|
&SpatialQueryFilter::default().with_mask(LayerMask(
|
|
GameLayer::Npc.to_bits() | GameLayer::Player.to_bits(),
|
|
)),
|
|
)
|
|
};
|
|
|
|
for entity in intersections.iter() {
|
|
if let Ok(mut e) = commands.get_entity(*entity) {
|
|
e.trigger(|entity| Hit {
|
|
entity,
|
|
damage: explosion.damage,
|
|
});
|
|
}
|
|
}
|
|
}
|