Spread state context architecture (Fixes #18) (#30)
CI / build-and-test (push) Canceled after 0s

Reviewed-on: #30
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #30.
This commit is contained in:
2026-09-15 17:59:03 +00:00
committed by EIREXE
parent 43a04e9491
commit b8b65e60e9
15 changed files with 384 additions and 302 deletions
+17 -17
View File
@@ -1,7 +1,8 @@
use crate::fighter::{
animation::AnimKind,
state::{
FighterState, FighterStateContext, FighterStateImpl, dash,
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext,
UpdateContext, dash,
fall::FallState,
ground::{
self, GroundedMotionResult, GroundedStateCommon,
@@ -35,11 +36,11 @@ impl LandingState {
impl FighterStateImpl for LandingState {
const NAME: &'static str = "Landing";
fn check_interrupt(&self, state_context: &mut FighterStateContext) -> Option<FighterState> {
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
if state_context.is_current_animation_finished() {
grounded_movement_standstill_common_interrupts(state_context, &self.grounded_common)
} else if state_context.get_current_animation_frame()
>= state_context.fighter_manifest.attributes.landing_iasa
>= state_context.fighter_attributes.landing_iasa
&& let LandingType::Normal = self.landing_type
{
dash::check_input(state_context, &self.grounded_common).or_else(|| {
@@ -51,18 +52,17 @@ impl FighterStateImpl for LandingState {
}
}
fn update(&mut self, state_context: &mut FighterStateContext) {
let friction = if state_context.velocity.x.abs()
> state_context.fighter_manifest.attributes.max_walk_vel
{
state_context.fighter_manifest.attributes.ground_friction
* state_context
.game_settings
.fighter_common
.ground_friction_over_walk_speed_multiplier
} else {
state_context.fighter_manifest.attributes.ground_friction
};
fn update(&mut self, state_context: &mut UpdateContext) {
let friction =
if state_context.velocity.x.abs() > state_context.fighter_attributes.max_walk_vel {
state_context.fighter_attributes.ground_friction
* state_context
.game_settings
.fighter_common
.ground_friction_over_walk_speed_multiplier
} else {
state_context.fighter_attributes.ground_friction
};
let ground_velocity = state_context.velocity.x;
@@ -77,7 +77,7 @@ impl FighterStateImpl for LandingState {
fn check_collision_interrupt(
&mut self,
state_context: &mut FighterStateContext,
state_context: &mut CollisionContext,
) -> Option<FighterState> {
if let GroundedMotionResult::InAir =
ground::collide_with_stage_grounded(state_context, &mut self.grounded_common, true)
@@ -88,7 +88,7 @@ impl FighterStateImpl for LandingState {
}
}
fn on_enter(&mut self, state_context: &mut FighterStateContext) {
fn on_enter(&mut self, state_context: &mut EnterContext) {
match self.landing_type {
LandingType::Normal => {
state_context.play_animation(AnimKind::Landing, false);