Implement directional influence #43

Merged
EIREXE merged 3 commits from di into master 2026-09-18 20:43:42 +00:00
3 changed files with 28 additions and 6 deletions
Showing only changes of commit 540b0cda8d - Show all commits
+14 -2
View File
@@ -26,6 +26,10 @@ 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()
}
@@ -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);
}
+10
View File
@@ -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";
+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 {