Skip to content

Commit

Permalink
Make same frame collisions more logical
Browse files Browse the repository at this point in the history
  • Loading branch information
haihala committed Dec 29, 2023
1 parent 962cf50 commit 5afd957
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions client/lib/src/damage/hitreg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ pub(super) fn detect_hits(
}

pub(super) fn apply_connections(
In(hits): In<Vec<AttackConnection>>,
In(mut hits): In<Vec<AttackConnection>>,
mut commands: Commands,
mut notifications: ResMut<Notifications>,
combo: Option<Res<Combo>>,
Expand All @@ -253,10 +253,7 @@ pub(super) fn apply_connections(
mut sounds: ResMut<Sounds>,
mut particles: ResMut<Particles>,
) {
if hits.len() == 2 {
// TODO: Handle strike and throw clash
// Ideally, one should be strike invincible while throw animation is active
// In a throw vs strike situation, the winner ought to be consistent.
if hits.len() >= 2 {
if hits
.iter()
.all(|hit| hit.contact_type == ConnectionType::Throw)
Expand All @@ -271,7 +268,6 @@ pub(super) fn apply_connections(

particles.spawn(ParticleRequest {
effect: VisualEffect::Clash,
// TODO: This can be refined more
position: hits
.iter()
.map(|hit| hit.overlap.center())
Expand All @@ -282,8 +278,14 @@ pub(super) fn apply_connections(
});

sounds.play(SoundEffect::Whoosh); // TODO change sound effect
return;
} else if hits
.iter()
.any(|hit| hit.contact_type == ConnectionType::Throw)
{
// On a same frame connect, grab beats strike
hits.retain(|hit| hit.contact_type == ConnectionType::Throw);
}
return;
}

for hit in hits {
Expand Down

0 comments on commit 5afd957

Please sign in to comment.