Implement land from below, fix attacks not lifting fighters off the ground (#96)
CI / build-and-test (push) Successful in 1m44s
CI / production-build (push) Successful in 12m17s

Reviewed-on: #96
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #96.
This commit is contained in:
2026-10-14 18:33:17 +00:00
committed by EIREXE
parent 4185bd90d5
commit 9dfae1de77
10 changed files with 274 additions and 53 deletions
+28 -30
View File
@@ -1,8 +1,6 @@
use crate::{
fighter::{
animation::AnimKind,
attack::{self, FighterHitReaction},
state::{
FighterVelocity, animation::AnimKind, attack::{self, FighterHitReaction}, state::{
CollisionContext, EnterContext, ExitContext, FighterState, FighterStateImpl,
InterruptContext, UpdateContext,
air::{self, AirborneStateCommon},
@@ -40,6 +38,30 @@ impl HitstunState {
impl FighterStateImpl for HitstunState {
const NAME: &'static str = "Hitstun";
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
if state_context.get_current_animation_frame() > self.hit_reaction.hitstun_frames {
match &self.hitstop_kind {
HitstopStateKind::Grounded => Some(FighterState::Wait(WaitState)),
HitstopStateKind::Airborne => Some(FighterState::Fall(FallState::new(
AirborneStateCommon::default(),
))),
}
} else {
None
}
}
fn on_enter(&mut self, state_context: &mut EnterContext) {
let animation = match self.hitstop_kind {
HitstopStateKind::Grounded => AnimKind::FlinchGround,
HitstopStateKind::Airborne => AnimKind::FlinchAir,
};
state_context.play_animation(animation, false);
state_context.velocity.0 = FGVec2::ZERO;
}
fn on_exit(&mut self, _state_context: &mut ExitContext) {}
fn name(&self) -> String {
let hitstop_kind = match self.hitstop_kind {
HitstopStateKind::Grounded => "Grounded",
@@ -54,19 +76,6 @@ impl FighterStateImpl for HitstunState {
format!("Hitstun ({hitstop_kind}, {hit_reaction_type})")
}
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
if state_context.get_current_animation_frame() > self.hit_reaction.hitstun_frames {
match &self.hitstop_kind {
HitstopStateKind::Grounded => Some(FighterState::Wait(WaitState)),
HitstopStateKind::Airborne => Some(FighterState::Fall(FallState::new(
AirborneStateCommon::default(),
))),
}
} else {
None
}
}
fn update(&mut self, ctx: &mut UpdateContext) {
if !self.knockback_applied {
let launch_direction = attack::directional_influence::apply_directional_influence(
@@ -83,6 +92,8 @@ impl FighterStateImpl for HitstunState {
HitstopStateKind::Grounded => {}
HitstopStateKind::Airborne => {
air::integrate_gravity(ctx.velocity, ctx.fighter_attributes, false);
let vel_with_kb = FighterVelocity(ctx.velocity.0 + ctx.knockback_velocity.0);
air::apply_air_motion(&vel_with_kb, ctx.translation, ctx.prev_translation);
}
}
@@ -92,21 +103,8 @@ impl FighterStateImpl for HitstunState {
.max(FGi32::ZERO);
ctx.knockback_velocity.0 = ctx.knockback_velocity.normalize_or_zero() * next_speed;
ctx.translation.0 += ctx.velocity.0 + ctx.knockback_velocity.0;
}
fn on_enter(&mut self, state_context: &mut EnterContext) {
let animation = match self.hitstop_kind {
HitstopStateKind::Grounded => AnimKind::FlinchGround,
HitstopStateKind::Airborne => AnimKind::FlinchAir,
};
state_context.play_animation(animation, false);
state_context.velocity.0 = FGVec2::ZERO;
}
fn on_exit(&mut self, _state_context: &mut ExitContext) {}
fn check_collision_interrupt(
&mut self,
state_context: &mut CollisionContext,
@@ -114,7 +112,7 @@ impl FighterStateImpl for HitstunState {
match &mut self.hitstop_kind {
HitstopStateKind::Grounded => collision_interrupt(state_context, true),
HitstopStateKind::Airborne => {
air::collision_interrupt(state_context, LandingType::Normal, false)
air::collision_interrupt(state_context, LandingType::Normal, Default::default())
}
}
}