Deduplicate fighter state lifecycle policies (#36)
CI / build-and-test (push) Failing after 10m51s

Fixes #22

Extracts shared grounded collision/friction and airborne movement/landing policies while preserving state-specific behavior. Running fighters now pass `can_walk_off = true` so they can run off platform edges. Includes grounded and airborne hitstun call sites.

Reviewed-on: #36
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #36.
This commit is contained in:
2026-09-16 18:30:53 +00:00
committed by EIREXE
parent 43ee6d8153
commit ae8f7b5850
12 changed files with 86 additions and 240 deletions
+5 -26
View File
@@ -1,7 +1,5 @@
use super::{CollisionContext, EnterContext, FighterStateImpl, InterruptContext, UpdateContext};
use crate::fighter::animation::AnimKind;
use crate::fighter::state::ground::GroundedStateCommon;
use crate::fighter::state::land::{LandingState, LandingType};
use crate::fighter::state::{FighterState, air, jump};
#[derive(Debug, Clone, Copy, Hash)]
@@ -18,36 +16,17 @@ impl FighterStateImpl for FallState {
}
fn update(&mut self, state_context: &mut UpdateContext) {
air::integrate_gravity(state_context.velocity, state_context.fighter_attributes);
air::apply_air_drift(
state_context.velocity,
state_context.fighter_attributes,
state_context.input,
);
air::apply_air_motion(
state_context.velocity,
state_context.translation,
state_context.prev_translation,
);
air::update_standard_motion(state_context);
}
fn check_collision_interrupt(
&mut self,
state_context: &mut CollisionContext,
) -> Option<FighterState> {
if let Some(res) = state_context.air_collide_with_stage() {
// Adjust translation
state_context.translation.0 = res.hit_position - state_context.ecb.get_bottom_point();
let grounded_common = GroundedStateCommon {
current_line_id: res.line_id,
};
Some(FighterState::Land(LandingState::create(
grounded_common,
LandingType::Normal,
)))
} else {
None
}
air::collision_interrupt(
state_context,
crate::fighter::state::land::LandingType::Normal,
)
}
}