fix contact damage and test with impaler

This commit is contained in:
Jim 2025-08-26 08:26:59 -04:00
parent 9d397451c4
commit e9790f156d
Signed by: jim
GPG key ID: 3236D2F059A7C0AC
6 changed files with 16 additions and 13 deletions

View file

@ -10,9 +10,9 @@ use bevy::{
render::camera::Exposure,
};
use building_core::SpawnCore;
use building_impaler::SpawnImpaler;
use building_impaler::{Impaler, SpawnImpaler};
use camera::ControlledCamera;
use combat::{Attacked, Defense, Health};
use combat::{Defense, Health};
use state::AppState;
pub struct LevelPlugin;
@ -64,16 +64,13 @@ fn setup(
))
.observe(
|trigger: Trigger<Pointer<Click>>,
mut query: Query<&mut LinearVelocity>,
mut commands: Commands| {
if let Ok(mut v) = query.get_mut(trigger.target()) {
target: Single<&GlobalTransform, With<Impaler>>,
mut query: Query<(&GlobalTransform, &mut LinearVelocity)>| {
if let Ok((gtf, mut v)) = query.get_mut(trigger.target()) {
let delta = target.translation() - gtf.translation();
v.y += 5.0;
v.0 += delta;
}
commands.entity(trigger.target()).trigger(Attacked {
attacker: None,
amount: 8.,
..default()
});
},
);
}