Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04f6f2386f | ||
|
|
84e07a80aa |
@@ -4,7 +4,7 @@ use crate::fighter::ecb::FighterPreviousECB;
|
|||||||
use crate::fighter::{FighterECB, FighterPreviousTranslation, FighterTranslation};
|
use crate::fighter::{FighterECB, FighterPreviousTranslation, FighterTranslation};
|
||||||
use crate::math::segment::FGSegment2d;
|
use crate::math::segment::FGSegment2d;
|
||||||
use crate::math::vec::FGVec2;
|
use crate::math::vec::FGVec2;
|
||||||
use crate::stage::line::{StageCollision, StageLineID, StagePolyType};
|
use crate::stage::line::{StageCollision, StageLineID};
|
||||||
/*
|
/*
|
||||||
pub fn collide_fighter_with_scene(
|
pub fn collide_fighter_with_scene(
|
||||||
fighters: Query<(&FighterECB, &mut FighterVelocity, &mut FighterTranslation)>,
|
fighters: Query<(&FighterECB, &mut FighterVelocity, &mut FighterTranslation)>,
|
||||||
@@ -45,7 +45,6 @@ pub fn air_collide_with_stage(
|
|||||||
ecb: &FighterECB,
|
ecb: &FighterECB,
|
||||||
stage_collision: &StageCollision,
|
stage_collision: &StageCollision,
|
||||||
ignored_polys: &[usize],
|
ignored_polys: &[usize],
|
||||||
ignore_soft_platforms: bool,
|
|
||||||
) -> Option<AirCollisionWithStageResult> {
|
) -> Option<AirCollisionWithStageResult> {
|
||||||
let ray_segment = FGSegment2d::new(
|
let ray_segment = FGSegment2d::new(
|
||||||
prev_translation.0 + prev_ecb.get_bottom_point(),
|
prev_translation.0 + prev_ecb.get_bottom_point(),
|
||||||
@@ -56,10 +55,7 @@ pub fn air_collide_with_stage(
|
|||||||
.stage_polys
|
.stage_polys
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter(|(poly_idx, poly)| {
|
.filter(|(poly_idx, _)| !ignored_polys.contains(poly_idx))
|
||||||
!ignored_polys.contains(poly_idx)
|
|
||||||
&& !(ignore_soft_platforms && matches!(poly.poly_type, StagePolyType::Platform))
|
|
||||||
})
|
|
||||||
.filter_map(|(poly_idx, poly)| {
|
.filter_map(|(poly_idx, poly)| {
|
||||||
poly.intersect_ray(ray_segment).map(|intersect_result| {
|
poly.intersect_ray(ray_segment).map(|intersect_result| {
|
||||||
(
|
(
|
||||||
@@ -99,18 +95,6 @@ mod tests {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn solid_floor() -> StagePoly {
|
|
||||||
StagePoly::build(
|
|
||||||
StagePolyType::Closed,
|
|
||||||
&[
|
|
||||||
(FGVec2::lit("-2", "0"), StagePolyLineSegmentType::Floor),
|
|
||||||
(FGVec2::lit("2", "0"), StagePolyLineSegmentType::Floor),
|
|
||||||
(FGVec2::lit("2", "-2"), StagePolyLineSegmentType::Wall),
|
|
||||||
(FGVec2::lit("-2", "-2"), StagePolyLineSegmentType::Wall),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn airborne_collision_skips_ignored_polygons() {
|
fn airborne_collision_skips_ignored_polygons() {
|
||||||
let stage_collision = StageCollision {
|
let stage_collision = StageCollision {
|
||||||
@@ -138,78 +122,10 @@ mod tests {
|
|||||||
&ecb,
|
&ecb,
|
||||||
&stage_collision,
|
&stage_collision,
|
||||||
&[1],
|
&[1],
|
||||||
false,
|
|
||||||
)
|
)
|
||||||
.expect("the non-ignored platform should still be collidable");
|
.expect("the non-ignored platform should still be collidable");
|
||||||
|
|
||||||
assert_eq!(collision.line_id.polygon, 0);
|
assert_eq!(collision.line_id.polygon, 0);
|
||||||
assert_eq!(collision.hit_position, FGVec2::lit("0", "0"));
|
assert_eq!(collision.hit_position, FGVec2::lit("0", "0"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn airborne_collision_skips_soft_platforms_while_passing_down() {
|
|
||||||
let stage_collision = StageCollision {
|
|
||||||
stage_polys: vec![horizontal_platform("0")],
|
|
||||||
};
|
|
||||||
let previous_translation = FighterPreviousTranslation(FGVec2::lit("0", "2"));
|
|
||||||
let translation = FighterTranslation(FGVec2::lit("0", "-1"));
|
|
||||||
let previous_ecb = FighterPreviousECB {
|
|
||||||
bottom: FGVec2::ZERO,
|
|
||||||
top: FGVec2::ZERO,
|
|
||||||
left: FGVec2::ZERO,
|
|
||||||
right: FGVec2::ZERO,
|
|
||||||
};
|
|
||||||
let ecb = FighterECB {
|
|
||||||
bottom: FGVec2::ZERO,
|
|
||||||
top: FGVec2::ZERO,
|
|
||||||
left: FGVec2::ZERO,
|
|
||||||
right: FGVec2::ZERO,
|
|
||||||
};
|
|
||||||
|
|
||||||
assert!(air_collide_with_stage(
|
|
||||||
&previous_translation,
|
|
||||||
&translation,
|
|
||||||
&previous_ecb,
|
|
||||||
&ecb,
|
|
||||||
&stage_collision,
|
|
||||||
&[],
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
.is_none());
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn airborne_collision_still_hits_solid_floors_while_passing_down() {
|
|
||||||
let stage_collision = StageCollision {
|
|
||||||
stage_polys: vec![solid_floor()],
|
|
||||||
};
|
|
||||||
let previous_translation = FighterPreviousTranslation(FGVec2::lit("0", "2"));
|
|
||||||
let translation = FighterTranslation(FGVec2::lit("0", "-1"));
|
|
||||||
let previous_ecb = FighterPreviousECB {
|
|
||||||
bottom: FGVec2::ZERO,
|
|
||||||
top: FGVec2::ZERO,
|
|
||||||
left: FGVec2::ZERO,
|
|
||||||
right: FGVec2::ZERO,
|
|
||||||
};
|
|
||||||
let ecb = FighterECB {
|
|
||||||
bottom: FGVec2::ZERO,
|
|
||||||
top: FGVec2::ZERO,
|
|
||||||
left: FGVec2::ZERO,
|
|
||||||
right: FGVec2::ZERO,
|
|
||||||
};
|
|
||||||
|
|
||||||
let collision = air_collide_with_stage(
|
|
||||||
&previous_translation,
|
|
||||||
&translation,
|
|
||||||
&previous_ecb,
|
|
||||||
&ecb,
|
|
||||||
&stage_collision,
|
|
||||||
&[],
|
|
||||||
true,
|
|
||||||
)
|
|
||||||
.expect("solid floors remain collidable while passing down");
|
|
||||||
|
|
||||||
assert_eq!(collision.line_id.polygon, 0);
|
|
||||||
assert_eq!(collision.hit_position, FGVec2::lit("0", "0"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -248,7 +248,6 @@ mod tests {
|
|||||||
use crate::fighter::ecb::FighterPreviousECB;
|
use crate::fighter::ecb::FighterPreviousECB;
|
||||||
use crate::fighter::{FighterECB, FighterSurfaceState};
|
use crate::fighter::{FighterECB, FighterSurfaceState};
|
||||||
use crate::stage::line::StagePolyType;
|
use crate::stage::line::StagePolyType;
|
||||||
use crate::input::FighterInput;
|
|
||||||
|
|
||||||
fn two_segment_floor() -> StagePoly {
|
fn two_segment_floor() -> StagePoly {
|
||||||
StagePoly::build(
|
StagePoly::build(
|
||||||
@@ -379,14 +378,12 @@ mod tests {
|
|||||||
let mut context = CollisionContext {
|
let mut context = CollisionContext {
|
||||||
translation: &mut translation,
|
translation: &mut translation,
|
||||||
prev_translation: &previous_translation,
|
prev_translation: &previous_translation,
|
||||||
input: &FighterInput::default(),
|
|
||||||
velocity: &mut velocity,
|
velocity: &mut velocity,
|
||||||
surface: &mut surface,
|
surface: &mut surface,
|
||||||
ecb: &mut ecb,
|
ecb: &mut ecb,
|
||||||
prev_ecb: &previous_ecb,
|
prev_ecb: &previous_ecb,
|
||||||
stage_collision: &stage_collision,
|
stage_collision: &stage_collision,
|
||||||
leave_ground_ecb_lock_duration: 10,
|
leave_ground_ecb_lock_duration: 10,
|
||||||
downward_stick_threshold: FGi32::ONE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
@@ -432,14 +429,12 @@ mod tests {
|
|||||||
let mut context = CollisionContext {
|
let mut context = CollisionContext {
|
||||||
translation: &mut translation,
|
translation: &mut translation,
|
||||||
prev_translation: &previous_translation,
|
prev_translation: &previous_translation,
|
||||||
input: &FighterInput::default(),
|
|
||||||
velocity: &mut velocity,
|
velocity: &mut velocity,
|
||||||
surface: &mut surface,
|
surface: &mut surface,
|
||||||
ecb: &mut ecb,
|
ecb: &mut ecb,
|
||||||
prev_ecb: &previous_ecb,
|
prev_ecb: &previous_ecb,
|
||||||
stage_collision: &stage_collision,
|
stage_collision: &stage_collision,
|
||||||
leave_ground_ecb_lock_duration: 10,
|
leave_ground_ecb_lock_duration: 10,
|
||||||
downward_stick_threshold: FGi32::ONE,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
assert!(matches!(
|
assert!(matches!(
|
||||||
|
|||||||
@@ -193,14 +193,12 @@ impl UpdateContext<'_> {
|
|||||||
pub struct CollisionContext<'a> {
|
pub struct CollisionContext<'a> {
|
||||||
pub translation: &'a mut FighterTranslation,
|
pub translation: &'a mut FighterTranslation,
|
||||||
pub prev_translation: &'a FighterPreviousTranslation,
|
pub prev_translation: &'a FighterPreviousTranslation,
|
||||||
pub input: &'a FighterInput,
|
|
||||||
pub velocity: &'a mut FighterVelocity,
|
pub velocity: &'a mut FighterVelocity,
|
||||||
pub surface: &'a mut FighterSurfaceState,
|
pub surface: &'a mut FighterSurfaceState,
|
||||||
pub ecb: &'a mut FighterECB,
|
pub ecb: &'a mut FighterECB,
|
||||||
pub prev_ecb: &'a FighterPreviousECB,
|
pub prev_ecb: &'a FighterPreviousECB,
|
||||||
pub stage_collision: &'a StageCollision,
|
pub stage_collision: &'a StageCollision,
|
||||||
pub leave_ground_ecb_lock_duration: u32,
|
pub leave_ground_ecb_lock_duration: u32,
|
||||||
pub downward_stick_threshold: FGi32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CollisionContext<'_> {
|
impl CollisionContext<'_> {
|
||||||
@@ -208,8 +206,6 @@ impl CollisionContext<'_> {
|
|||||||
&self,
|
&self,
|
||||||
) -> Option<crate::fighter::collision::AirCollisionWithStageResult> {
|
) -> Option<crate::fighter::collision::AirCollisionWithStageResult> {
|
||||||
let ignored_polys = self.surface.ignored_polygon_ids();
|
let ignored_polys = self.surface.ignored_polygon_ids();
|
||||||
let ignore_soft_platforms = self.input.get_last_frame().movement.y
|
|
||||||
<= -self.downward_stick_threshold;
|
|
||||||
crate::fighter::collision::air_collide_with_stage(
|
crate::fighter::collision::air_collide_with_stage(
|
||||||
self.prev_translation,
|
self.prev_translation,
|
||||||
self.translation,
|
self.translation,
|
||||||
@@ -217,7 +213,6 @@ impl CollisionContext<'_> {
|
|||||||
self.ecb,
|
self.ecb,
|
||||||
self.stage_collision,
|
self.stage_collision,
|
||||||
&ignored_polys,
|
&ignored_polys,
|
||||||
ignore_soft_platforms,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,14 +349,12 @@ impl<'w, 's> FighterFrameQueryItem<'w, 's> {
|
|||||||
CollisionContext {
|
CollisionContext {
|
||||||
translation: &mut self.translation,
|
translation: &mut self.translation,
|
||||||
prev_translation: &self.prev_translation,
|
prev_translation: &self.prev_translation,
|
||||||
input: &self.input,
|
|
||||||
velocity: &mut self.velocity,
|
velocity: &mut self.velocity,
|
||||||
surface: &mut self.surface,
|
surface: &mut self.surface,
|
||||||
ecb: &mut self.ecb,
|
ecb: &mut self.ecb,
|
||||||
prev_ecb: &self.prev_ecb,
|
prev_ecb: &self.prev_ecb,
|
||||||
stage_collision,
|
stage_collision,
|
||||||
leave_ground_ecb_lock_duration: game_settings.fighter_common.leave_ground_ecb_frame_lock_duration,
|
leave_ground_ecb_lock_duration: game_settings.fighter_common.leave_ground_ecb_frame_lock_duration
|
||||||
downward_stick_threshold: game_settings.input_common.run_stick_threshold,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-2
@@ -116,12 +116,13 @@ impl Plugin for FighterInputPlugin {
|
|||||||
binding: GamepadBinding::Button(GamepadButton::North),
|
binding: GamepadBinding::Button(GamepadButton::North),
|
||||||
action: InputMapAction::Jump,
|
action: InputMapAction::Jump,
|
||||||
},
|
},
|
||||||
|
// shield/airdodge -- both shoulder buttons, Melee-style
|
||||||
GamepadInputMapElement {
|
GamepadInputMapElement {
|
||||||
binding: GamepadBinding::Button(GamepadButton::LeftTrigger2),
|
binding: GamepadBinding::Button(GamepadButton::LeftTrigger),
|
||||||
action: InputMapAction::Shield,
|
action: InputMapAction::Shield,
|
||||||
},
|
},
|
||||||
GamepadInputMapElement {
|
GamepadInputMapElement {
|
||||||
binding: GamepadBinding::Button(GamepadButton::RightTrigger2),
|
binding: GamepadBinding::Button(GamepadButton::RightTrigger),
|
||||||
action: InputMapAction::Shield,
|
action: InputMapAction::Shield,
|
||||||
},
|
},
|
||||||
// attack
|
// attack
|
||||||
|
|||||||
Reference in New Issue
Block a user