Add waveland snapping
This commit is contained in:
@@ -1,17 +1,9 @@
|
||||
use crate::{
|
||||
fighter::{
|
||||
FighterInvulnerabilityState,
|
||||
animation::AnimKind,
|
||||
state::{
|
||||
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext,
|
||||
UpdateContext,
|
||||
air::{self, AirborneStateCommon},
|
||||
fall::FallState,
|
||||
land::LandingType,
|
||||
FighterInvulnerabilityState, animation::AnimKind, state::{
|
||||
CollisionContext, EnterContext, FighterState, FighterStateImpl, InterruptContext, UpdateContext, air::{self, AirborneStateCommon}, fall::FallState, land::{LandingState, LandingType},
|
||||
},
|
||||
},
|
||||
input,
|
||||
math::vec::FGVec2,
|
||||
}, input, math::vec::FGVec2, stage::line::{StageLineID, StagePolyLineSegmentType},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Hash)]
|
||||
@@ -52,6 +44,27 @@ impl FighterStateImpl for AirDodgeState {
|
||||
&mut self,
|
||||
state_context: &mut CollisionContext,
|
||||
) -> Option<FighterState> {
|
||||
let can_wavesnap = self.direction.y.is_zero() || self.direction.y.is_negative();
|
||||
|
||||
if can_wavesnap {
|
||||
for (poly_idx, poly) in state_context.stage_collision.stage_polys.iter().enumerate() {
|
||||
for (segment_idx, segment) in poly.segments.iter().enumerate() {
|
||||
if !matches!(segment.segment_type, StagePolyLineSegmentType::Floor) {
|
||||
continue;
|
||||
}
|
||||
let bottom_point = state_context.translation.0 + state_context.ecb.get_bottom_point();
|
||||
let point_in_segment = segment.segment.closest_point(bottom_point);
|
||||
let dist_to_segment = point_in_segment.distance(bottom_point);
|
||||
if dist_to_segment <= state_context.waveland_snap_distance {
|
||||
state_context.ecb.bottom = point_in_segment;
|
||||
state_context.ecb.rebase_onto_bottom();
|
||||
state_context.surface.land(StageLineID { polygon: poly_idx, segment: segment_idx }, state_context.ledge_info);
|
||||
return Some(FighterState::Land(LandingState::create(LandingType::Special)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
air::collision_interrupt(state_context, LandingType::Special, false)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user