Add waveland snapping (#95)
Reviewed-on: #95 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #95.
This commit is contained in:
+11
-25
@@ -120,8 +120,9 @@ pub trait FighterStateImpl: Sized {
|
||||
|
||||
fn check_collision_interrupt(
|
||||
&mut self,
|
||||
_state_context: &mut CollisionContext,
|
||||
state_context: &mut CollisionContext,
|
||||
) -> Option<FighterState> {
|
||||
state_context.apply_desired_ecb();
|
||||
None
|
||||
}
|
||||
|
||||
@@ -260,7 +261,7 @@ pub struct CollisionContext<'a> {
|
||||
pub ledge_info: &'a mut FighterLedgeInformation,
|
||||
pub fighter_ledge_collision_box: FGRect,
|
||||
pub downward_stick_threshold: FGi32,
|
||||
pub(crate) ecb_advanced: bool,
|
||||
pub waveland_snap_distance: FGi32,
|
||||
}
|
||||
|
||||
impl CollisionContext<'_> {
|
||||
@@ -268,7 +269,6 @@ impl CollisionContext<'_> {
|
||||
/// substep resolver can later replace this with fractional steps.
|
||||
pub fn apply_desired_ecb(&mut self) {
|
||||
ecb::interpolate_ecb(self.ecb, *self.desired_ecb, FGi32::ONE);
|
||||
self.ecb_advanced = true;
|
||||
}
|
||||
|
||||
pub fn air_collide_with_stage(
|
||||
@@ -278,7 +278,7 @@ impl CollisionContext<'_> {
|
||||
let ignored_polys = self.surface.ignored_polygon_ids();
|
||||
let ignore_soft_platforms = can_ignore_soft_platforms
|
||||
&& self.input.get_last_frame().movement.y <= -self.downward_stick_threshold;
|
||||
let result = crate::fighter::collision::air_collide_with_stage_substepped(
|
||||
crate::fighter::collision::air_collide_with_stage_substepped(
|
||||
self.prev_translation,
|
||||
self.translation,
|
||||
self.velocity,
|
||||
@@ -287,15 +287,7 @@ impl CollisionContext<'_> {
|
||||
self.stage_collision,
|
||||
&ignored_polys,
|
||||
ignore_soft_platforms,
|
||||
);
|
||||
self.ecb_advanced = true;
|
||||
result
|
||||
}
|
||||
|
||||
fn finish_ecb_frame(&mut self) {
|
||||
if !self.ecb_advanced {
|
||||
self.apply_desired_ecb();
|
||||
}
|
||||
)
|
||||
}
|
||||
pub fn air_collide_with_ledges(
|
||||
&self,
|
||||
@@ -502,7 +494,7 @@ impl<'w, 's> FighterFrameQueryItem<'w, 's> {
|
||||
.leave_ground_ecb_frame_lock_duration,
|
||||
downward_stick_threshold: game_settings.input_common.run_stick_threshold,
|
||||
fighter_ledge_collision_box,
|
||||
ecb_advanced: false,
|
||||
waveland_snap_distance: game_settings.fighter_common.waveland_snap_distance,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -797,13 +789,9 @@ pub fn state_collision_interrupt_system(
|
||||
continue;
|
||||
}
|
||||
|
||||
let new_state = {
|
||||
let mut collision_context =
|
||||
frame.collision_context(&stage_collision, manifest, &game_settings);
|
||||
let new_state = state.check_collision_interrupt(&mut collision_context);
|
||||
collision_context.finish_ecb_frame();
|
||||
new_state
|
||||
};
|
||||
let new_state = state.check_collision_interrupt(
|
||||
&mut frame.collision_context(&stage_collision, manifest, &game_settings),
|
||||
);
|
||||
if let Some(new_state) = new_state {
|
||||
transition_state(
|
||||
&mut state,
|
||||
@@ -872,7 +860,7 @@ mod tests {
|
||||
};
|
||||
let previous_ecb = FighterPreviousECB::from(ecb);
|
||||
let mut presentation_snap = FighterPresentationSnap::default();
|
||||
let mut context = CollisionContext {
|
||||
let context = CollisionContext {
|
||||
translation: &mut translation,
|
||||
prev_translation: &previous_translation,
|
||||
input: &input,
|
||||
@@ -890,7 +878,7 @@ mod tests {
|
||||
end: FGVec2::lit("1", "-1"),
|
||||
},
|
||||
downward_stick_threshold: FGi32::ONE,
|
||||
ecb_advanced: false,
|
||||
waveland_snap_distance: FGi32::ZERO,
|
||||
};
|
||||
|
||||
assert!(context.air_collide_with_ledges().is_none());
|
||||
@@ -899,7 +887,5 @@ mod tests {
|
||||
context.air_collide_with_ledges().map(|result| result.ledge),
|
||||
Some(ledge_id)
|
||||
);
|
||||
context.finish_ecb_frame();
|
||||
assert_eq!(context.ecb.top, FGVec2::lit("0", "2"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user