vehicles protect from damage now, though not perfectly
This commit is contained in:
parent
df9f47c427
commit
e577a5084c
10
src/actor.rs
10
src/actor.rs
|
@ -310,17 +310,23 @@ pub fn handle_vehicle_enter_exit(
|
|||
fn handle_collisions(
|
||||
mut collision_event_reader: EventReader<CollisionStarted>,
|
||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
q_player: Query<Entity, With<PlayerCamera>>,
|
||||
q_player: Query<(Entity, Option<&Player>), With<PlayerCamera>>,
|
||||
mut q_player_lifeform: Query<(&mut LifeForm, &mut Suit, &mut HitPoints), With<Player>>,
|
||||
) {
|
||||
if let (Ok(player), Ok((mut lifeform, mut suit, mut hp))) = (q_player.get_single(), q_player_lifeform.get_single_mut()) {
|
||||
if let (Ok((player, player_maybe)), Ok((mut lifeform, mut suit, mut hp))) = (q_player.get_single(), q_player_lifeform.get_single_mut()) {
|
||||
for CollisionStarted(entity1, entity2) in collision_event_reader.read() {
|
||||
if *entity1 == player || *entity2 == player {
|
||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Crash));
|
||||
lifeform.adrenaline_jolt += 0.1;
|
||||
|
||||
if player_maybe.is_some() {
|
||||
suit.integrity -= 0.03;
|
||||
hp.damage += 10.0;
|
||||
}
|
||||
else {
|
||||
hp.damage += 3.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue