Add shifting ECB based on bone positions (melee-like)
CI / build-and-test (pull_request) Successful in 1m33s
CI / production-build (pull_request) Successful in 10m48s

This commit is contained in:
2026-09-25 15:45:55 +02:00
parent d521461625
commit 0cb81ec2e9
17 changed files with 317 additions and 115 deletions
+24 -12
View File
@@ -178,7 +178,7 @@ pub fn collide_with_stage_grounded(
can_walk_off: bool,
) -> GroundedMotionResult {
let translation = &mut state_context.translation;
let ecb = state_context.ecb;
let ecb = &state_context.ecb;
let stage_collision = state_context.stage_collision;
let Some(current_line_id) = state_context.surface.line_id() else {
@@ -218,12 +218,18 @@ pub fn collide_with_stage_grounded(
GroundedMotionResult::InGround
}
GroundedPositionResult::InAir => {
state_context.surface.leave_ground();
state_context.surface.apply_airborne_policy(
crate::fighter::surface::EcbLockPolicy::StartOnDetach,
state_context.leave_ground_ecb_lock_duration,
);
GroundedMotionResult::InAir
}
}
} else {
state_context.surface.leave_ground();
state_context.surface.apply_airborne_policy(
crate::fighter::surface::EcbLockPolicy::StartOnDetach,
state_context.leave_ground_ecb_lock_duration,
);
GroundedMotionResult::InAir
}
}
@@ -363,9 +369,11 @@ mod tests {
let mut translation = FighterTranslation(FGVec2::lit("11", "0"));
let previous_translation = FighterPreviousTranslation(translation.0);
let mut velocity = FighterVelocity::default();
let ecb = FighterECB {
vertical_half: FGi32::ONE,
horizontal_half: FGi32::ONE,
let mut ecb = FighterECB {
bottom: FGVec2::lit("0.0", "-0.5"),
top: FGVec2::lit("0.0", "0.5"),
left: FGVec2::lit("-0.5", "0.0"),
right: FGVec2::lit("0.5", "0.0"),
};
let previous_ecb = FighterPreviousECB::from(ecb);
let mut context = CollisionContext {
@@ -373,9 +381,10 @@ mod tests {
prev_translation: &previous_translation,
velocity: &mut velocity,
surface: &mut surface,
ecb: &ecb,
ecb: &mut ecb,
prev_ecb: &previous_ecb,
stage_collision: &stage_collision,
leave_ground_ecb_lock_duration: 10,
};
assert!(matches!(
@@ -411,9 +420,11 @@ mod tests {
let mut translation = FighterTranslation(FGVec2::lit("11", "0"));
let previous_translation = FighterPreviousTranslation(translation.0);
let mut velocity = FighterVelocity::default();
let ecb = FighterECB {
vertical_half: FGi32::ONE,
horizontal_half: FGi32::ONE,
let mut ecb = FighterECB {
bottom: FGVec2::lit("0.0", "-0.5"),
top: FGVec2::lit("0.0", "0.5"),
left: FGVec2::lit("-0.5", "0.0"),
right: FGVec2::lit("0.5", "0.0"),
};
let previous_ecb = FighterPreviousECB::from(ecb);
let mut context = CollisionContext {
@@ -421,16 +432,17 @@ mod tests {
prev_translation: &previous_translation,
velocity: &mut velocity,
surface: &mut surface,
ecb: &ecb,
ecb: &mut ecb,
prev_ecb: &previous_ecb,
stage_collision: &stage_collision,
leave_ground_ecb_lock_duration: 10,
};
assert!(matches!(
collide_with_stage_grounded(&mut context, true),
GroundedMotionResult::InAir
));
assert_eq!(surface, FighterSurfaceState::Airborne);
assert!(matches!(surface, FighterSurfaceState::Airborne { .. }));
}
}