Implement directional influence (#43)
CI / build-and-test (push) Successful in 1m9s

Reviewed-on: #43
Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #43.
This commit is contained in:
2026-09-18 20:43:41 +00:00
committed by EIREXE
parent 2b5af49e15
commit 9f51207f48
8 changed files with 116 additions and 20 deletions
+24 -6
View File
@@ -1,8 +1,6 @@
use crate::{
fighter::{
animation::AnimKind,
attack::FighterHitReaction,
state::{
animation::AnimKind, attack::{self, FighterHitReaction}, state::{
CollisionContext, EnterContext, ExitContext, FighterState, FighterStateImpl,
InterruptContext, UpdateContext, air,
fall::FallState,
@@ -10,8 +8,7 @@ use crate::{
land::LandingType,
wait::WaitState,
},
},
math::int::FGi32,
}, math::int::FGi32,
};
#[derive(Clone, Debug, Hash)]
@@ -24,6 +21,17 @@ pub enum HitstopStateKind {
pub struct HitstunState {
pub hit_reaction: FighterHitReaction,
pub hitstop_kind: HitstopStateKind,
knockback_applied: bool
}
impl HitstunState {
pub fn new(hit_reaction: FighterHitReaction, hitstop_kind: HitstopStateKind) -> Self {
Self {
hit_reaction,
hitstop_kind,
knockback_applied: false
}
}
}
impl FighterStateImpl for HitstunState {
@@ -59,6 +67,17 @@ 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,
self.hit_reaction.launch_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);
let speed = ctx.knockback_velocity.length();
@@ -77,7 +96,6 @@ impl FighterStateImpl for HitstunState {
HitstopStateKind::Airborne => AnimKind::FlinchAir,
};
state_context.play_animation(animation, false);
state_context.knockback_velocity.0 = self.hit_reaction.launch_velocity;
}
fn on_exit(&mut self, _state_context: &mut ExitContext) {}
+3 -3
View File
@@ -451,10 +451,10 @@ pub fn state_interrupt_system(
}
info!("Entering hitstop kind: {:?}", hitstop_kind);
Some(FighterState::Hitstun(HitstunState {
hit_reaction: reaction,
Some(FighterState::Hitstun(HitstunState::new(
reaction,
hitstop_kind,
}))
)))
} else if hitstop.remaining_frames > 0 {
None
} else {