Implement fast falling (#44)
CI / build-and-test (push) Successful in 1m17s

Reviewed-on: #44
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #44.
This commit is contained in:
2026-09-18 22:23:03 +00:00
committed by EIREXE
parent 9f51207f48
commit 7269a1cb49
12 changed files with 123 additions and 55 deletions
+22 -13
View File
@@ -1,14 +1,18 @@
use crate::{
fighter::{
animation::AnimKind, attack::{self, FighterHitReaction}, state::{
animation::AnimKind,
attack::{self, FighterHitReaction},
state::{
CollisionContext, EnterContext, ExitContext, FighterState, FighterStateImpl,
InterruptContext, UpdateContext, air,
InterruptContext, UpdateContext,
air::{self, AirborneStateCommon},
fall::FallState,
ground::{GroundedStateCommon, collision_interrupt},
land::LandingType,
wait::WaitState,
},
}, math::int::FGi32,
},
math::int::FGi32,
};
#[derive(Clone, Debug, Hash)]
@@ -21,7 +25,7 @@ pub enum HitstopStateKind {
pub struct HitstunState {
pub hit_reaction: FighterHitReaction,
pub hitstop_kind: HitstopStateKind,
knockback_applied: bool
knockback_applied: bool,
}
impl HitstunState {
@@ -29,7 +33,7 @@ impl HitstunState {
Self {
hit_reaction,
hitstop_kind,
knockback_applied: false
knockback_applied: false,
}
}
}
@@ -59,7 +63,9 @@ impl FighterStateImpl for HitstunState {
grounded_common: grounded_state_common.clone(),
}))
}
HitstopStateKind::Airborne => Some(FighterState::Fall(FallState)),
HitstopStateKind::Airborne => {
Some(FighterState::Fall(FallState::new(AirborneStateCommon::default())))
}
}
} else {
None
@@ -69,16 +75,21 @@ impl FighterStateImpl for HitstunState {
fn update(&mut self, ctx: &mut UpdateContext) {
if !self.knockback_applied {
let launch_direction = attack::directional_influence::apply_directional_influence(
ctx.input.get_last_frame().movement,
ctx.input.get_last_frame().movement,
self.hit_reaction.launch_angle,
ctx.game_settings.fighter_common.di_max_angle
ctx.game_settings.fighter_common.di_max_angle,
);
ctx.knockback_velocity.0 = launch_direction * self.hit_reaction.launch_velocity;
self.knockback_applied = true;
}
air::integrate_gravity(ctx.velocity, ctx.fighter_attributes);
match self.hitstop_kind {
HitstopStateKind::Grounded(_) => {}
HitstopStateKind::Airborne => {
air::integrate_gravity(ctx.velocity, ctx.fighter_attributes, false);
}
}
let speed = ctx.knockback_velocity.length();
let next_speed = speed
@@ -113,10 +124,8 @@ impl FighterStateImpl for HitstunState {
}
}
}
fn is_visually_grounded<'a>(
&'a self,
) -> bool {
fn is_visually_grounded<'a>(&'a self) -> bool {
match self.hitstop_kind {
HitstopStateKind::Grounded(_) => true,
HitstopStateKind::Airborne => false,