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:
@@ -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) {}
|
||||
|
||||
Reference in New Issue
Block a user