damage per head (#32)
This commit is contained in:
@@ -18,6 +18,7 @@ use std::f32::consts::PI;
|
||||
#[derive(Component)]
|
||||
struct ThrownProjectile {
|
||||
impact_animation: bool,
|
||||
damage: u32,
|
||||
}
|
||||
|
||||
#[derive(Component, Reflect)]
|
||||
@@ -126,6 +127,7 @@ fn on_trigger_thrown(
|
||||
Name::new("projectile-thrown"),
|
||||
ThrownProjectile {
|
||||
impact_animation: explosion_animation,
|
||||
damage: head.damage,
|
||||
},
|
||||
Collider::sphere(0.5),
|
||||
CollisionLayers::new(
|
||||
@@ -157,9 +159,14 @@ fn shot_collision(
|
||||
|
||||
let shot_entity = if query_shot.contains(*e1) { *e1 } else { *e2 };
|
||||
|
||||
let Ok((shot_pos, animation)) = query_shot
|
||||
.get(shot_entity)
|
||||
.map(|(projectile, t)| (t.translation, projectile.impact_animation))
|
||||
let Ok((shot_pos, animation, damage)) =
|
||||
query_shot.get(shot_entity).map(|(projectile, t)| {
|
||||
(
|
||||
t.translation,
|
||||
projectile.impact_animation,
|
||||
projectile.damage,
|
||||
)
|
||||
})
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
@@ -169,7 +176,7 @@ fn shot_collision(
|
||||
commands.trigger(PlaySound::ThrowHit);
|
||||
|
||||
commands.trigger(Explosion {
|
||||
damage: 20,
|
||||
damage,
|
||||
position: shot_pos,
|
||||
//TODO: should be around 1 grid in distance
|
||||
radius: 5.,
|
||||
|
||||
Reference in New Issue
Block a user