fix suit damage on collisions outside of vehicles

This commit is contained in:
yuni 2024-05-07 19:07:28 +02:00
parent 79673e5ec5
commit 0c1393290e

View file

@ -391,18 +391,15 @@ 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, Option<&Player>), With<PlayerCollider>>,
q_player: Query<Entity, With<PlayerCollider>>,
mut q_player_lifeform: Query<(&mut LifeForm, &mut Suit), With<Player>>,
) {
if let (Ok((player, player_maybe)), Ok((mut lifeform, mut suit))) = (q_player.get_single(), q_player_lifeform.get_single_mut()) {
if let (Ok(player), Ok((mut lifeform, mut suit))) = (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;
}
suit.integrity -= 0.03;
}
}
}