This commit is contained in:
@@ -26,13 +26,17 @@ pub fn apply_directional_influence(
|
||||
let normal = FGVec2::new(-base_launch_direction.y, base_launch_direction.x);
|
||||
let di_amount = receiver_stick.dot(normal);
|
||||
let angle_change = di_amount * di_max_angle.to_fixed::<FGWide>();
|
||||
let angle_change = angle_change.clamp(
|
||||
-di_max_angle.to_fixed::<FGWide>(),
|
||||
di_max_angle.to_fixed::<FGWide>(),
|
||||
);
|
||||
let (sin, cos) = (attack_angle + angle_change.to_fixed::<FGi32>()).sin_cos();
|
||||
FGVec2::new(cos, sin).normalize_or_zero()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use crate::{
|
||||
use crate::{
|
||||
fighter::attack::directional_influence::apply_directional_influence,
|
||||
math::{int::FGi32, vec::FGVec2},
|
||||
};
|
||||
@@ -47,10 +51,18 @@ use crate::{
|
||||
|
||||
#[test]
|
||||
fn di_applies_on_the_correct_side() {
|
||||
let di = apply_directional_influence(FGVec2::lit("0.0", "1.0"), FGi32::lit("0.0"), FGi32::lit("18.0"));
|
||||
let di = apply_directional_influence(
|
||||
FGVec2::lit("0.0", "1.0"),
|
||||
FGi32::lit("0.0"),
|
||||
FGi32::lit("18.0"),
|
||||
);
|
||||
assert!(di.x > FGi32::ZERO);
|
||||
assert!(di.y > FGi32::ZERO);
|
||||
let di = apply_directional_influence(FGVec2::lit("0.0", "-1.0"), FGi32::lit("0.0"), FGi32::lit("18.0"));
|
||||
let di = apply_directional_influence(
|
||||
FGVec2::lit("0.0", "-1.0"),
|
||||
FGi32::lit("0.0"),
|
||||
FGi32::lit("18.0"),
|
||||
);
|
||||
assert!(di.x > FGi32::ZERO);
|
||||
assert!(di.y < FGi32::ZERO);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,16 @@ pub struct HitstunState {
|
||||
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 {
|
||||
const NAME: &'static str = "Hitstun";
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user