Rework input buffer to match HDR closer (#79)
CI / build-and-test (push) Successful in 1m24s
CI / production-build (push) Successful in 11m47s

## Summary

- Preserve distinct same-action bindings in rollback input frames.
- Add independent command lifetimes with tap and state-scoped hold buffering.
- Detect second shield bindings and consume shield commands for air dodge.
- Fix duplicate keyboard mappings being overwritten.

Reviewed-on: #79
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #79.
This commit is contained in:
2026-10-03 09:20:56 +00:00
committed by EIREXE
parent 47f7ae1e69
commit aca3886113
11 changed files with 711 additions and 165 deletions
+3
View File
@@ -45,6 +45,9 @@ impl FighterStateImpl for AirAttackState {
}
fn on_enter(&mut self, state_context: &mut EnterContext) {
state_context
.input
.consume_command(crate::input::FighterCommands::Attack);
state_context.play_animation(self.attack_kind.get_animation(), false);
let script = state_context.attack_script_assets.scripts[&self.attack_kind].clone();
state_context.hitboxes.0 = Some(crate::fighter::FighterActiveAttack {
+30 -7
View File
@@ -1,13 +1,17 @@
use crate::{
fighter::{
FighterInvulnerabilityState, animation::AnimKind, state::{
FighterInvulnerabilityState,
animation::AnimKind,
state::{
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext,
UpdateContext,
air::{self, AirborneStateCommon},
fall::FallState,
land::LandingType,
},
}, input, math::vec::FGVec2,
},
input,
math::vec::FGVec2,
};
#[derive(Debug, Clone, Hash)]
@@ -29,8 +33,13 @@ impl FighterStateImpl for AirDodgeState {
}
fn update(&mut self, state_context: &mut UpdateContext) {
let airdodge_intangible_end = state_context.fighter_attributes.air_dodge_intangible_start + state_context.fighter_attributes.air_dodge_intangible_duration;
if state_context.animation_frame == state_context.fighter_attributes.air_dodge_intangible_start {
let airdodge_intangible_end = state_context.fighter_attributes.air_dodge_intangible_start
+ state_context
.fighter_attributes
.air_dodge_intangible_duration;
if state_context.animation_frame
== state_context.fighter_attributes.air_dodge_intangible_start
{
*state_context.vulnerability = FighterInvulnerabilityState::Intangible;
} else if state_context.animation_frame >= airdodge_intangible_end {
*state_context.vulnerability = FighterInvulnerabilityState::Vulnerable;
@@ -54,6 +63,13 @@ impl FighterStateImpl for AirDodgeState {
fn on_enter(&mut self, state_context: &mut EnterContext) {
state_context.play_animation(AnimKind::AirDodge, false);
state_context
.input
.clear_command(input::FighterCommands::Shield);
state_context
.input
.clear_command(input::FighterCommands::GuardHold);
state_context.velocity.0 =
self.direction * state_context.fighter_attributes.air_dodge_velocity;
}
@@ -65,11 +81,11 @@ impl FighterStateImpl for AirDodgeState {
fn surface_policy(&self) -> super::SurfacePolicy {
super::SurfacePolicy::Airborne(crate::fighter::surface::EcbLockPolicy::StartOnDetach)
}
fn on_exit(&mut self, state_context: &mut super::ExitContext) {
*state_context.vulnerability = FighterInvulnerabilityState::Vulnerable;
}
fn name(&self) -> String {
Self::NAME.to_owned()
}
@@ -79,7 +95,14 @@ pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
state_context
.input
.has_command(input::FighterCommands::Shield)
.then(|| {
.then_some(())
.or_else(|| {
state_context
.input
.has_command(input::FighterCommands::GuardHold)
.then_some(())
})
.map(|_| {
FighterState::AirDodge(AirDodgeState {
direction: state_context
.input
+3
View File
@@ -42,6 +42,9 @@ impl FighterStateImpl for GroundAttackState {
}
fn on_enter(&mut self, state_context: &mut EnterContext) {
state_context
.input
.consume_command(crate::input::FighterCommands::Attack);
state_context.play_animation(self.attack_kind.get_animation(), false);
let script = state_context.attack_script_assets.scripts[&self.attack_kind].clone();
state_context.hitboxes.0 = Some(crate::fighter::FighterActiveAttack {
+18 -3
View File
@@ -11,7 +11,7 @@ use crate::{
ground,
},
},
input::FighterCommands,
input::{DigitalAction, FighterCommands},
math::{int::FGi32, vec::FGVec2},
};
#[derive(Debug, Hash, Clone, Copy)]
@@ -68,8 +68,18 @@ impl FighterStateImpl for JumpSquatState {
direction: wavedash_dir.normalize_or_zero(),
}))
} else if self.duration_counter >= state_context.fighter_attributes.jumpsquat_duration {
info!("Jump {}", state_context.input.get_last_frame().jump);
let jump_type = if state_context.input.get_last_frame().jump {
info!(
"Jump {}",
state_context
.input
.get_last_frame()
.is_held(DigitalAction::Jump)
);
let jump_type = if state_context
.input
.get_last_frame()
.is_held(DigitalAction::Jump)
{
JumpType::LongJump
} else {
JumpType::ShortHop
@@ -97,9 +107,14 @@ impl FighterStateImpl for JumpSquatState {
fn on_enter(&mut self, state_context: &mut EnterContext) {
state_context.play_animation(AnimKind::JumpSquat, false);
state_context.input.enable_hold_all(10);
state_context.input.clear_command(FighterCommands::Jump);
}
fn on_exit(&mut self, state_context: &mut crate::fighter::state::ExitContext) {
state_context.input.disable_hold_all();
}
fn is_visually_grounded<'a>(&'a self) -> bool {
true
}
+9 -4
View File
@@ -18,7 +18,10 @@ use crate::fighter::state::hitstun::HitstunState;
use crate::fighter::surface::EcbLockPolicy;
use crate::fighter::visual::FighterAnimations;
use crate::fighter::{
Fighter, FighterDamage, FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop, FighterHitstopShake, FighterHitstopShakeKind, FighterHitstopShakeRole, FighterInvulnerabilityState, FighterPendingRespawn, FighterPresentationSnap, FighterPreviousTranslation, FighterSurfaceState, FighterTranslation, FighterVelocity,
Fighter, FighterDamage, FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop,
FighterHitstopShake, FighterHitstopShakeKind, FighterHitstopShakeRole,
FighterInvulnerabilityState, FighterPendingRespawn, FighterPresentationSnap,
FighterPreviousTranslation, FighterSurfaceState, FighterTranslation, FighterVelocity,
};
use crate::game_settings::GameSettings;
use crate::input::FighterInput;
@@ -32,6 +35,7 @@ use crate::stage::line::StageCollision;
use crate::stage::manifest::{StageManifest, StageManifestRegistry};
pub mod air;
pub mod air_attack;
pub mod air_dodge;
pub mod angel;
pub mod crouch;
@@ -47,7 +51,6 @@ pub mod run;
pub mod turn;
pub mod wait;
pub mod walk;
pub mod air_attack;
#[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)]
pub enum SurfacePolicy {
@@ -170,6 +173,7 @@ impl EnterContext<'_> {
}
pub struct ExitContext<'a> {
pub input: &'a mut FighterInput,
pub hitboxes: &'a mut FighterHitboxes,
pub surface: &'a mut FighterSurfaceState,
pub vulnerability: &'a mut FighterInvulnerabilityState,
@@ -306,7 +310,7 @@ impl<'w, 's> FighterFrameQueryItem<'w, 's> {
animation,
surface: &self.surface,
stage_collision,
attack_script_assets: attack_script_assets
attack_script_assets: attack_script_assets,
}
}
@@ -333,6 +337,7 @@ impl<'w, 's> FighterFrameQueryItem<'w, 's> {
fn exit_context(&mut self) -> ExitContext<'_> {
ExitContext {
input: &mut self.input,
hitboxes: &mut self.hitboxes,
surface: &mut self.surface,
vulnerability: &mut self.vulnerability,
@@ -540,7 +545,7 @@ pub fn state_interrupt_system(
&baked_animations,
&manifest.attributes,
&stage_collision,
attack_script_assets
attack_script_assets,
))
};