Formatting
This commit is contained in:
@@ -64,7 +64,7 @@ pub fn apply_animation(
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Deserialize, serde::Serialize, Reflect, EnumIter
|
||||
Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Deserialize, serde::Serialize, Reflect, EnumIter,
|
||||
)]
|
||||
pub enum AnimKind {
|
||||
Wait,
|
||||
|
||||
+34
-22
@@ -6,11 +6,18 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
fighter::{
|
||||
Fighter, FighterAttributes, FighterFacingDirection, FighterHitboxes, FighterTranslation, animation::{AnimKind, FighterAnimationFrame}, baked_animation::{FighterBoneMatrices, FixedMat4}, hurtbox::{FixedAffineCapsule, FixedCapsule}, manifest::FighterManifest,
|
||||
}, math::{
|
||||
Fighter, FighterAttributes, FighterFacingDirection, FighterHitboxes, FighterTranslation,
|
||||
animation::{AnimKind, FighterAnimationFrame},
|
||||
baked_animation::{FighterBoneMatrices, FixedMat4},
|
||||
hurtbox::{FixedAffineCapsule, FixedCapsule},
|
||||
manifest::FighterManifest,
|
||||
},
|
||||
math::{
|
||||
int::{FGi32, FGi32Ext},
|
||||
vec3::FGVec3,
|
||||
}, schedule::GameplaySet, scripting::FighterAttackScript,
|
||||
},
|
||||
schedule::GameplaySet,
|
||||
scripting::FighterAttackScript,
|
||||
};
|
||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||
pub struct FighterDamage(FGi32);
|
||||
@@ -207,18 +214,23 @@ pub fn solve_hitboxes(
|
||||
&FighterTranslation,
|
||||
&FighterFacingDirection,
|
||||
&mut FighterHitboxes,
|
||||
&FighterAnimationFrame
|
||||
&FighterAnimationFrame,
|
||||
)>,
|
||||
attack_scripts: Res<Assets<FighterAttackScript>>,
|
||||
) {
|
||||
for (matrices, translation, facing_direction, mut hitboxes, animation_frame) in &mut query {
|
||||
hitboxes.active_hitboxes_solved.clear();
|
||||
if let Some(ref attack_script) = hitboxes.attack_script {
|
||||
let attack_script = attack_scripts.get(attack_script).expect("Attack script should be valid");
|
||||
let attack_script = attack_scripts
|
||||
.get(attack_script)
|
||||
.expect("Attack script should be valid");
|
||||
let fighter_trf = translation.get_3d_transform(facing_direction);
|
||||
let active_hitboxes = hitboxes.active_hitboxes.clone();
|
||||
for hitbox_idx in active_hitboxes {
|
||||
let hitbox = attack_script.hitboxes.get(hitbox_idx).expect("Hitbox IDX should be valid");
|
||||
let hitbox = attack_script
|
||||
.hitboxes
|
||||
.get(hitbox_idx)
|
||||
.expect("Hitbox IDX should be valid");
|
||||
let matrices = matrices.get(&hitbox.bone);
|
||||
|
||||
if let None = matrices {
|
||||
@@ -233,23 +245,19 @@ pub fn solve_hitboxes(
|
||||
|
||||
if hitbox.start_frame == animation_frame.frame {
|
||||
// Sphere only
|
||||
hitboxes.active_hitboxes_solved.push(
|
||||
FixedCapsule {
|
||||
start: curr_hbox_pos,
|
||||
end: curr_hbox_pos,
|
||||
radius: hitbox.radius
|
||||
}
|
||||
)
|
||||
hitboxes.active_hitboxes_solved.push(FixedCapsule {
|
||||
start: curr_hbox_pos,
|
||||
end: curr_hbox_pos,
|
||||
radius: hitbox.radius,
|
||||
})
|
||||
} else {
|
||||
let prev_hbox_matrix = fighter_trf.mul(prev_bone_matrix);
|
||||
let prev_hbox_pos = prev_hbox_matrix.transform_point(hitbox.offset);
|
||||
hitboxes.active_hitboxes_solved.push(
|
||||
FixedCapsule {
|
||||
start: prev_hbox_pos,
|
||||
end: curr_hbox_pos,
|
||||
radius: hitbox.radius
|
||||
}
|
||||
);
|
||||
hitboxes.active_hitboxes_solved.push(FixedCapsule {
|
||||
start: prev_hbox_pos,
|
||||
end: curr_hbox_pos,
|
||||
radius: hitbox.radius,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -303,7 +311,10 @@ pub fn solve_hurtboxes(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn intersect_attacks_with_hurtboxes(query: Query<(Entity, &FighterSolvedHurtboxes, &FighterHitboxes)>, attack_scripts: Res<Assets<FighterAttackScript>>) {
|
||||
pub fn intersect_attacks_with_hurtboxes(
|
||||
query: Query<(Entity, &FighterSolvedHurtboxes, &FighterHitboxes)>,
|
||||
attack_scripts: Res<Assets<FighterAttackScript>>,
|
||||
) {
|
||||
/*for (entity_hurting, _, hitboxes) in query {
|
||||
if hitboxes.attack_script.is_none() {
|
||||
continue;
|
||||
@@ -338,7 +349,8 @@ impl Plugin for FighterAttackPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
GgrsSchedule,
|
||||
(solve_hurtboxes, solve_hitboxes).chain()
|
||||
(solve_hurtboxes, solve_hitboxes)
|
||||
.chain()
|
||||
.after(crate::fighter::baked_animation::update_fighter_bone_matrices)
|
||||
.in_set(GameplaySet::Animation),
|
||||
);
|
||||
|
||||
+19
-15
@@ -49,23 +49,27 @@ pub fn air_collide_with_stage(
|
||||
|
||||
for (poly_idx, poly) in state_context.stage_collision.stage_polys.iter().enumerate() {
|
||||
if let Some(intersect_result) = poly.intersect_ray(ray_segment) {
|
||||
intersect_results.push((AirCollisionWithStageResult {
|
||||
line_id: {
|
||||
StageLineID {
|
||||
polygon: poly_idx,
|
||||
segment: intersect_result.segment_idx,
|
||||
}
|
||||
intersect_results.push((
|
||||
AirCollisionWithStageResult {
|
||||
line_id: {
|
||||
StageLineID {
|
||||
polygon: poly_idx,
|
||||
segment: intersect_result.segment_idx,
|
||||
}
|
||||
},
|
||||
hit_position: intersect_result.position,
|
||||
hit_normal: intersect_result.normal,
|
||||
},
|
||||
hit_position: intersect_result.position,
|
||||
hit_normal: intersect_result.normal,
|
||||
}, intersect_result.position.distance_squared(ray_segment.point2())));
|
||||
intersect_result
|
||||
.position
|
||||
.distance_squared(ray_segment.point2()),
|
||||
));
|
||||
}
|
||||
}
|
||||
intersect_results.sort_by(| (_, a), (_, b) | {
|
||||
a.cmp(b)
|
||||
});
|
||||
intersect_results.sort_by(|(_, a), (_, b)| a.cmp(b));
|
||||
|
||||
intersect_results.iter().last().map(|(val, _)| {
|
||||
val.to_owned().clone()
|
||||
})
|
||||
intersect_results
|
||||
.iter()
|
||||
.last()
|
||||
.map(|(val, _)| val.to_owned().clone())
|
||||
}
|
||||
|
||||
+2
-11
@@ -73,7 +73,6 @@ impl FixedAffineCapsule {
|
||||
// current simplex to fixed-point precision, so conservatively collide.
|
||||
true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
trait SupportMap {
|
||||
@@ -243,18 +242,10 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn affine_scale_changes_capsule_intersection() {
|
||||
let sphere = FixedAffineCapsule::new(
|
||||
FixedMat4::IDENTITY,
|
||||
FGi32::ZERO,
|
||||
FGi32::lit("1"),
|
||||
);
|
||||
let sphere = FixedAffineCapsule::new(FixedMat4::IDENTITY, FGi32::ZERO, FGi32::lit("1"));
|
||||
let mut squashed_transform = FixedMat4::IDENTITY;
|
||||
squashed_transform.cols[1][1] = FGi32::lit("0.5");
|
||||
let squashed = FixedAffineCapsule::new(
|
||||
squashed_transform,
|
||||
FGi32::ZERO,
|
||||
FGi32::lit("1"),
|
||||
);
|
||||
let squashed = FixedAffineCapsule::new(squashed_transform, FGi32::ZERO, FGi32::lit("1"));
|
||||
let target = FixedCapsule::new(
|
||||
FGVec3::lit("0", "1.4", "0"),
|
||||
FGVec3::lit("0", "1.4", "0"),
|
||||
|
||||
+14
-3
@@ -30,8 +30,19 @@ pub use motion::{FighterPreviousTranslation, FighterTranslation, FighterVelocity
|
||||
|
||||
use crate::{
|
||||
fighter::{
|
||||
attack::{FighterAttackPlugin, FighterAttackScriptAssets, FighterSolvedHurtboxes}, baked_animation::FighterBoneMatrices, hurtbox::FixedCapsule, manifest::FighterManifest, state::{FighterState, fall::FallState}, visual::FighterAnimations,
|
||||
}, input::FighterInput, math::{int::FGi32, vec::FGVec2}, player::Player, schedule::GameplaySet, scripting::FighterAttackScript, stage::line::StageCollision,
|
||||
attack::{FighterAttackPlugin, FighterAttackScriptAssets, FighterSolvedHurtboxes},
|
||||
baked_animation::FighterBoneMatrices,
|
||||
hurtbox::FixedCapsule,
|
||||
manifest::FighterManifest,
|
||||
state::{FighterState, fall::FallState},
|
||||
visual::FighterAnimations,
|
||||
},
|
||||
input::FighterInput,
|
||||
math::{int::FGi32, vec::FGVec2},
|
||||
player::Player,
|
||||
schedule::GameplaySet,
|
||||
scripting::FighterAttackScript,
|
||||
stage::line::StageCollision,
|
||||
};
|
||||
use state::state_interrupt_system;
|
||||
|
||||
@@ -221,7 +232,7 @@ pub fn spawn_fighter(
|
||||
FighterHitboxes {
|
||||
attack_script: None,
|
||||
active_hitboxes: vec![],
|
||||
active_hitboxes_solved: vec![]
|
||||
active_hitboxes_solved: vec![],
|
||||
},
|
||||
),
|
||||
(
|
||||
|
||||
@@ -71,7 +71,10 @@ pub fn check_interrupt(
|
||||
.input
|
||||
.has_command(crate::input::FighterCommands::Attack)
|
||||
{
|
||||
let attack_kind = state_context.input.get_attack_command_type().to_attack_kind_grounded();
|
||||
let attack_kind = state_context
|
||||
.input
|
||||
.get_attack_command_type()
|
||||
.to_attack_kind_grounded();
|
||||
Some(FighterState::GroundAttack(GroundAttackState {
|
||||
attack_kind,
|
||||
grounded_common: grounded_common.clone(),
|
||||
|
||||
Reference in New Issue
Block a user