Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37b5d2f974 | ||
|
|
b9f1a52bbc |
@@ -17,7 +17,14 @@
|
|||||||
knockback_decay_per_frame: "0.051",
|
knockback_decay_per_frame: "0.051",
|
||||||
knockback_launch_velocity_multiplier: "0.03",
|
knockback_launch_velocity_multiplier: "0.03",
|
||||||
hitstun_frames_per_unit_knockback: "0.4",
|
hitstun_frames_per_unit_knockback: "0.4",
|
||||||
|
tumble_bounce_hitstop_threshold: 32,
|
||||||
|
attack_ground_to_airborne_transition_vertical_angle_threshold: "90.0",
|
||||||
|
meteor_angle_threshold: "10.0",
|
||||||
|
visual_shake_frames_per_hitstop_frame: "1.2",
|
||||||
|
visual_shake_table: [
|
||||||
|
-3.0, -1.5, 1.5, 3.0
|
||||||
|
],
|
||||||
|
attacker_visual_shake_multiplier: 0.4
|
||||||
),
|
),
|
||||||
stage_manifest_paths: [
|
stage_manifest_paths: [
|
||||||
"stages/battlefield/test.stage.ron"
|
"stages/battlefield/test.stage.ron"
|
||||||
|
|||||||
@@ -1,22 +1,12 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
camera::MatchCamera,
|
camera::MatchCamera, fighter::{
|
||||||
fighter::{
|
FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop, FighterHitstopShake, FighterPreviousFacingDirection, FighterPreviousTranslation, FighterTranslation, FighterVelocity, Grounded, animation::FighterAnimationFrame, attack::{
|
||||||
FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop,
|
|
||||||
FighterPreviousFacingDirection, FighterPreviousTranslation, FighterTranslation,
|
|
||||||
FighterVelocity, Grounded,
|
|
||||||
animation::FighterAnimationFrame,
|
|
||||||
attack::{
|
|
||||||
FighterDamage, FighterKnockbackVelocity, FighterPendingHitReaction, FighterPendingHits,
|
FighterDamage, FighterKnockbackVelocity, FighterPendingHitReaction, FighterPendingHits,
|
||||||
FighterSolvedHurtboxes, FighterStaleMoveQueue,
|
FighterSolvedHurtboxes, FighterStaleMoveQueue,
|
||||||
},
|
}, baked_animation::FighterBoneMatrices, state::FighterState,
|
||||||
baked_animation::FighterBoneMatrices,
|
}, input::FighterInput, player::Player, stage::line::StageCollision,
|
||||||
state::FighterState,
|
|
||||||
},
|
|
||||||
input::FighterInput,
|
|
||||||
player::Player,
|
|
||||||
stage::line::StageCollision,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
@@ -48,6 +38,7 @@ struct FighterCheckpoint {
|
|||||||
damage: FighterDamage,
|
damage: FighterDamage,
|
||||||
pending_hit_reaction: FighterPendingHitReaction,
|
pending_hit_reaction: FighterPendingHitReaction,
|
||||||
hitstop: FighterHitstop,
|
hitstop: FighterHitstop,
|
||||||
|
hitstop_shake: FighterHitstopShake,
|
||||||
knockback_velocity: FighterKnockbackVelocity,
|
knockback_velocity: FighterKnockbackVelocity,
|
||||||
stale_moves: FighterStaleMoveQueue,
|
stale_moves: FighterStaleMoveQueue,
|
||||||
hitboxes: FighterHitboxes,
|
hitboxes: FighterHitboxes,
|
||||||
@@ -146,6 +137,7 @@ pub(super) fn save_or_restore(world: &mut World) {
|
|||||||
entity.insert(saved.damage);
|
entity.insert(saved.damage);
|
||||||
entity.insert(saved.pending_hit_reaction.clone());
|
entity.insert(saved.pending_hit_reaction.clone());
|
||||||
entity.insert(saved.hitstop);
|
entity.insert(saved.hitstop);
|
||||||
|
entity.insert(saved.hitstop_shake);
|
||||||
entity.insert(saved.knockback_velocity);
|
entity.insert(saved.knockback_velocity);
|
||||||
entity.insert(saved.stale_moves.clone());
|
entity.insert(saved.stale_moves.clone());
|
||||||
entity.insert(saved.hitboxes.clone());
|
entity.insert(saved.hitboxes.clone());
|
||||||
@@ -183,6 +175,7 @@ fn capture_fighter(world: &World, entity: Entity) -> Option<FighterCheckpoint> {
|
|||||||
damage: *fighter.get::<FighterDamage>()?,
|
damage: *fighter.get::<FighterDamage>()?,
|
||||||
pending_hit_reaction: fighter.get::<FighterPendingHitReaction>()?.clone(),
|
pending_hit_reaction: fighter.get::<FighterPendingHitReaction>()?.clone(),
|
||||||
hitstop: *fighter.get::<FighterHitstop>()?,
|
hitstop: *fighter.get::<FighterHitstop>()?,
|
||||||
|
hitstop_shake: *fighter.get::<FighterHitstopShake>()?,
|
||||||
knockback_velocity: *fighter.get::<FighterKnockbackVelocity>()?,
|
knockback_velocity: *fighter.get::<FighterKnockbackVelocity>()?,
|
||||||
stale_moves: fighter.get::<FighterStaleMoveQueue>()?.clone(),
|
stale_moves: fighter.get::<FighterStaleMoveQueue>()?.clone(),
|
||||||
hitboxes: fighter.get::<FighterHitboxes>()?.clone(),
|
hitboxes: fighter.get::<FighterHitboxes>()?.clone(),
|
||||||
|
|||||||
@@ -82,6 +82,10 @@ impl HitStop {
|
|||||||
|
|
||||||
Self(frames)
|
Self(frames)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn calculate_shake_frames(&self, game_settings: &GameSettings) -> u32 {
|
||||||
|
(FGi32::from_num(self.0) * game_settings.fighter_common.visual_shake_frames_per_hitstop_frame).floor().to_num()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize)]
|
||||||
|
|||||||
@@ -5,15 +5,8 @@ use fixed_math::SinCos;
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
fighter::{
|
fighter::{
|
||||||
Fighter, FighterFacingDirection, FighterHitboxes, FighterHitstop,
|
Fighter, FighterFacingDirection, FighterHitboxes, FighterHitstop, FighterHitstopShake, FighterHitstopShakeKind, FighterHitstopShakeRole, FighterPendingHitReaction, FighterStaleMoveQueue, errors::FighterErrors, manifest::FighterManifest, state::FighterState,
|
||||||
FighterPendingHitReaction, FighterStaleMoveQueue, errors::FighterErrors,
|
}, game_settings::GameSettings, math::{int::FGi32, vec::FGVec2}, player::Player, schedule::GameplaySet, scripting::FighterAttackScript,
|
||||||
manifest::FighterManifest,
|
|
||||||
},
|
|
||||||
game_settings::GameSettings,
|
|
||||||
math::{int::FGi32, vec::FGVec2},
|
|
||||||
player::Player,
|
|
||||||
schedule::GameplaySet,
|
|
||||||
scripting::FighterAttackScript,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn resolve_fighter_hits(
|
pub fn resolve_fighter_hits(
|
||||||
@@ -24,8 +17,9 @@ pub fn resolve_fighter_hits(
|
|||||||
&FighterHitboxes,
|
&FighterHitboxes,
|
||||||
&Player,
|
&Player,
|
||||||
&mut FighterHitstop,
|
&mut FighterHitstop,
|
||||||
|
&mut FighterHitstopShake,
|
||||||
)>,
|
)>,
|
||||||
mut receiver: Query<(&mut FighterDamage, &Fighter, &mut FighterPendingHitReaction)>,
|
mut receiver: Query<(&mut FighterDamage, &Fighter, &mut FighterPendingHitReaction, &FighterState)>,
|
||||||
attack_scripts: Res<Assets<FighterAttackScript>>,
|
attack_scripts: Res<Assets<FighterAttackScript>>,
|
||||||
game_settings: Res<GameSettings>,
|
game_settings: Res<GameSettings>,
|
||||||
fighter_manifests: Res<Assets<FighterManifest>>,
|
fighter_manifests: Res<Assets<FighterManifest>>,
|
||||||
@@ -40,7 +34,7 @@ pub fn resolve_fighter_hits(
|
|||||||
.position(|hit| hit.defender != defender)
|
.position(|hit| hit.defender != defender)
|
||||||
.map_or(hits.len(), |offset| hit_offset + offset);
|
.map_or(hits.len(), |offset| hit_offset + offset);
|
||||||
|
|
||||||
let Ok((mut receiver_damage, fighter, mut pending_reaction)) = receiver.get_mut(defender)
|
let Ok((mut receiver_damage, fighter, mut pending_reaction, receiver_state)) = receiver.get_mut(defender)
|
||||||
else {
|
else {
|
||||||
hit_offset = next_defender;
|
hit_offset = next_defender;
|
||||||
continue;
|
continue;
|
||||||
@@ -49,7 +43,7 @@ pub fn resolve_fighter_hits(
|
|||||||
let damage_data = hits[hit_offset..next_defender]
|
let damage_data = hits[hit_offset..next_defender]
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|hit| {
|
.filter_map(|hit| {
|
||||||
let Ok((stale_move_queue, facing_dir, _hitboxes, player, _)) =
|
let Ok((stale_move_queue, facing_dir, _hitboxes, player, _, _)) =
|
||||||
attacker.get(hit.attacker)
|
attacker.get(hit.attacker)
|
||||||
else {
|
else {
|
||||||
return None;
|
return None;
|
||||||
@@ -115,10 +109,23 @@ pub fn resolve_fighter_hits(
|
|||||||
receiver_damage.0 += total_damage_received_this_frame;
|
receiver_damage.0 += total_damage_received_this_frame;
|
||||||
|
|
||||||
for (attacker_entity, _, reaction) in &reactions {
|
for (attacker_entity, _, reaction) in &reactions {
|
||||||
let Ok((.., mut hitstop)) = attacker.get_mut(*attacker_entity) else {
|
let Ok((.., mut hitstop, mut hitstop_shake)) = attacker.get_mut(*attacker_entity) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
hitstop.remaining_frames = reaction.hitstop_frames.max(hitstop.remaining_frames);
|
|
||||||
|
if hitstop.remaining_frames < reaction.hitstop_frames.0 {
|
||||||
|
let shake_kind = if receiver_state.is_visually_grounded() {
|
||||||
|
FighterHitstopShakeKind::Horizontal
|
||||||
|
} else {
|
||||||
|
FighterHitstopShakeKind::Vertical
|
||||||
|
};
|
||||||
|
hitstop.remaining_frames = reaction.hitstop_frames.0;
|
||||||
|
let shake_frames = reaction.hitstop_frames.calculate_shake_frames(&game_settings);
|
||||||
|
hitstop_shake.total_frames = shake_frames;
|
||||||
|
hitstop_shake.remaining_frames = shake_frames;
|
||||||
|
hitstop_shake.kind = shake_kind;
|
||||||
|
hitstop_shake.role = FighterHitstopShakeRole::Attacker;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pending_reaction.0 = reactions
|
pending_reaction.0 = reactions
|
||||||
|
|||||||
+32
-17
@@ -33,24 +33,13 @@ pub use motion::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
AppState,
|
AppState, fighter::{
|
||||||
fighter::{
|
|
||||||
attack::{
|
attack::{
|
||||||
AttackKind, FighterAttackPlugin, FighterAttackScriptAssets, FighterDamage,
|
AttackKind, FighterAttackPlugin, FighterAttackScriptAssets, FighterDamage,
|
||||||
FighterKnockbackVelocity, FighterPendingHitReaction, FighterSolvedHurtboxes,
|
FighterKnockbackVelocity, FighterPendingHitReaction, FighterSolvedHurtboxes,
|
||||||
FighterStaleMoveQueue,
|
FighterStaleMoveQueue,
|
||||||
},
|
}, baked_animation::{FighterBoneIndexMap, FighterBoneMatrices}, manifest::FighterManifest, state::{FighterState, fall::FallState}, visual::FighterAnimations,
|
||||||
baked_animation::{FighterBoneIndexMap, FighterBoneMatrices},
|
}, input::FighterInput, math::{int::FGi32, vec::FGVec2}, player::Player, schedule::GameplaySet, scripting::FighterAttackScript, stage::line::StageCollision,
|
||||||
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;
|
use state::state_interrupt_system;
|
||||||
|
|
||||||
@@ -65,7 +54,30 @@ pub enum FighterFacingDirection {
|
|||||||
Right,
|
Right,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Copy, Clone, Hash, Debug, PartialEq, Reflect, Default)]
|
||||||
|
pub enum FighterHitstopShakeKind {
|
||||||
|
#[default]
|
||||||
|
Horizontal,
|
||||||
|
Vertical
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Copy, Clone, Hash, Debug, PartialEq, Reflect, Default)]
|
||||||
|
pub enum FighterHitstopShakeRole {
|
||||||
|
#[default]
|
||||||
|
Attacker,
|
||||||
|
Receiver
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Component, Default, Copy, Clone, Hash)]
|
#[derive(Component, Default, Copy, Clone, Hash)]
|
||||||
|
pub struct FighterHitstopShake {
|
||||||
|
pub remaining_frames: u32,
|
||||||
|
pub total_frames: u32,
|
||||||
|
pub kind: FighterHitstopShakeKind,
|
||||||
|
pub role: FighterHitstopShakeRole
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Component, Default, Copy, Clone, Hash)]
|
||||||
|
#[require(FighterHitstopShake)]
|
||||||
pub struct FighterHitstop {
|
pub struct FighterHitstop {
|
||||||
pub remaining_frames: u32,
|
pub remaining_frames: u32,
|
||||||
}
|
}
|
||||||
@@ -120,7 +132,8 @@ pub struct FighterVisual;
|
|||||||
FighterDamage,
|
FighterDamage,
|
||||||
FighterPendingHitReaction,
|
FighterPendingHitReaction,
|
||||||
FighterHitstop,
|
FighterHitstop,
|
||||||
FighterKnockbackVelocity
|
FighterKnockbackVelocity,
|
||||||
|
FighterTranslation,
|
||||||
)]
|
)]
|
||||||
pub struct Fighter {
|
pub struct Fighter {
|
||||||
pub manifest: Handle<FighterManifest>,
|
pub manifest: Handle<FighterManifest>,
|
||||||
@@ -230,6 +243,7 @@ impl Plugin for FighterPlugin {
|
|||||||
.rollback_component_with_clone::<FighterState>()
|
.rollback_component_with_clone::<FighterState>()
|
||||||
.rollback_component_with_clone::<FighterHitboxes>()
|
.rollback_component_with_clone::<FighterHitboxes>()
|
||||||
.rollback_component_with_clone::<FighterBoneMatrices>()
|
.rollback_component_with_clone::<FighterBoneMatrices>()
|
||||||
|
.rollback_component_with_clone::<FighterHitstopShake>()
|
||||||
.checksum_component_with_hash::<FighterHitboxes>()
|
.checksum_component_with_hash::<FighterHitboxes>()
|
||||||
.rollback_component_with_clone::<FighterSolvedHurtboxes>()
|
.rollback_component_with_clone::<FighterSolvedHurtboxes>()
|
||||||
.checksum_component_with_hash::<FighterSolvedHurtboxes>()
|
.checksum_component_with_hash::<FighterSolvedHurtboxes>()
|
||||||
@@ -299,8 +313,9 @@ pub fn spawn_fighter(
|
|||||||
.id()
|
.id()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decay_hitstop(query: Query<&mut FighterHitstop>) {
|
pub fn decay_hitstop(query: Query<(&mut FighterHitstop, &mut FighterHitstopShake)>) {
|
||||||
for mut hitstop in query {
|
for (mut hitstop, mut hitstop_shake) in query {
|
||||||
hitstop.remaining_frames = hitstop.remaining_frames.saturating_sub(1);
|
hitstop.remaining_frames = hitstop.remaining_frames.saturating_sub(1);
|
||||||
|
hitstop_shake.remaining_frames = hitstop_shake.remaining_frames.saturating_sub(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-9
@@ -5,6 +5,8 @@ use bevy::prelude::*;
|
|||||||
use bevy_ggrs::GgrsFrameTiming;
|
use bevy_ggrs::GgrsFrameTiming;
|
||||||
|
|
||||||
use crate::debug_tools::PresentationMotionMode;
|
use crate::debug_tools::PresentationMotionMode;
|
||||||
|
use crate::fighter::{FighterHitstopShake};
|
||||||
|
use crate::game_settings::GameSettings;
|
||||||
use crate::{
|
use crate::{
|
||||||
fighter::{FighterECB, FighterFacingDirection, baked_animation::FixedMat4},
|
fighter::{FighterECB, FighterFacingDirection, baked_animation::FixedMat4},
|
||||||
math::{int::FGi32, vec::FGVec2, vec3::FGVec3},
|
math::{int::FGi32, vec::FGVec2, vec3::FGVec3},
|
||||||
@@ -58,13 +60,15 @@ pub fn apply_fighter_translation_to_visuals(
|
|||||||
&FighterTranslation,
|
&FighterTranslation,
|
||||||
&FighterPreviousTranslation,
|
&FighterPreviousTranslation,
|
||||||
&FighterECB,
|
&FighterECB,
|
||||||
|
&FighterHitstopShake,
|
||||||
&mut Transform,
|
&mut Transform,
|
||||||
)>,
|
)>,
|
||||||
timing: Res<GgrsFrameTiming>,
|
timing: Res<GgrsFrameTiming>,
|
||||||
debug_settings: Res<crate::debug_tools::DebugSettings>,
|
debug_settings: Res<crate::debug_tools::DebugSettings>,
|
||||||
|
game_settings: Res<GameSettings>,
|
||||||
) {
|
) {
|
||||||
let overstep_fraction = timing.overstep_fraction();
|
let overstep_fraction = timing.overstep_fraction();
|
||||||
for (translation, previous_translation, ecb, mut transform) in query {
|
for (translation, previous_translation, ecb, hitstop_shake, mut transform) in query {
|
||||||
let translation = sample_presentation_translation(
|
let translation = sample_presentation_translation(
|
||||||
*previous_translation,
|
*previous_translation,
|
||||||
*translation,
|
*translation,
|
||||||
@@ -77,6 +81,28 @@ pub fn apply_fighter_translation_to_visuals(
|
|||||||
translation.y + bottom.y.to_num::<f32>(),
|
translation.y + bottom.y.to_num::<f32>(),
|
||||||
0.0,
|
0.0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if hitstop_shake.remaining_frames > 0 && hitstop_shake.total_frames > 0 && !game_settings.fighter_common.visual_shake_table.is_empty() {
|
||||||
|
let total = hitstop_shake.total_frames as f32;
|
||||||
|
let curr = hitstop_shake.remaining_frames as f32;
|
||||||
|
let elapsed = 1.0 - curr / total;
|
||||||
|
|
||||||
|
|
||||||
|
let access_index = (hitstop_shake.remaining_frames as usize) % game_settings.fighter_common.visual_shake_table.len();
|
||||||
|
let shake_multiplier = match hitstop_shake.role {
|
||||||
|
super::FighterHitstopShakeRole::Attacker => game_settings.fighter_common.attacker_visual_shake_multiplier,
|
||||||
|
super::FighterHitstopShakeRole::Receiver => 1.0,
|
||||||
|
};
|
||||||
|
let shake_amount: f32 = 1.0 - EaseFunction::QuinticIn.sample(elapsed).unwrap_or_default();
|
||||||
|
let shake_amount = game_settings.fighter_common.visual_shake_table[access_index] * shake_amount * shake_multiplier;
|
||||||
|
|
||||||
|
let shake_offset = match hitstop_shake.kind {
|
||||||
|
super::FighterHitstopShakeKind::Horizontal => Vec3::new(shake_amount, 0.0, 0.0),
|
||||||
|
super::FighterHitstopShakeKind::Vertical => Vec3::new(0.0, shake_amount, 0.0),
|
||||||
|
};
|
||||||
|
|
||||||
|
transform.translation += shake_offset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,22 +111,15 @@ pub fn apply_air_motion(
|
|||||||
&FighterVelocity,
|
&FighterVelocity,
|
||||||
&mut FighterTranslation,
|
&mut FighterTranslation,
|
||||||
&mut FighterPreviousTranslation,
|
&mut FighterPreviousTranslation,
|
||||||
&mut Transform,
|
|
||||||
)>,
|
)>,
|
||||||
_time: Res<Time<Fixed>>,
|
_time: Res<Time<Fixed>>,
|
||||||
) {
|
) {
|
||||||
for (velocity, mut translation, mut prev_translation, _transform) in fighters {
|
for (velocity, mut translation, mut prev_translation) in fighters {
|
||||||
prev_translation.0 = translation.0;
|
prev_translation.0 = translation.0;
|
||||||
translation.0 += velocity.0;
|
translation.0 += velocity.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn copy_fighter_transform_to_visuals(fighters: Query<(&FighterTranslation, &mut Transform)>) {
|
|
||||||
for (translation, mut transform) in fighters {
|
|
||||||
transform.translation = Vec3::new(translation.x.to_num(), translation.y.to_num(), 0.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn fighter_movement() {}
|
pub fn fighter_movement() {}
|
||||||
|
|
||||||
pub fn snapshot_fighter_motion(
|
pub fn snapshot_fighter_motion(
|
||||||
|
|||||||
@@ -49,6 +49,12 @@ impl FighterStateImpl for AirDodgeState {
|
|||||||
state_context.velocity.0 =
|
state_context.velocity.0 =
|
||||||
self.direction * state_context.fighter_attributes.air_dodge_velocity;
|
self.direction * state_context.fighter_attributes.air_dodge_velocity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
|
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ impl FighterStateImpl for DashState {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
ground::collision_interrupt(state_context, &mut self.ground_common, true)
|
ground::collision_interrupt(state_context, &mut self.ground_common, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn check_smash_input_with_dir(state_context: &InterruptContext) -> Option<FighterFacingDirection> {
|
fn check_smash_input_with_dir(state_context: &InterruptContext) -> Option<FighterFacingDirection> {
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ impl FighterStateImpl for FallState {
|
|||||||
crate::fighter::state::land::LandingType::Normal,
|
crate::fighter::state::land::LandingType::Normal,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
|
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
|
||||||
|
|||||||
@@ -67,6 +67,12 @@ impl FighterStateImpl for GroundAttackState {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_interrupt(
|
pub fn check_interrupt(
|
||||||
|
|||||||
@@ -95,4 +95,13 @@ impl FighterStateImpl for HitstunState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
match self.hitstop_kind {
|
||||||
|
HitstopStateKind::Grounded(_) => true,
|
||||||
|
HitstopStateKind::Airborne => false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,12 @@ impl FighterStateImpl for JumpSquatState {
|
|||||||
state_context.play_animation(AnimKind::JumpSquat, false);
|
state_context.play_animation(AnimKind::JumpSquat, false);
|
||||||
state_context.input.clear_command(FighterCommands::Jump);
|
state_context.input.clear_command(FighterCommands::Jump);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FighterStateImpl for JumpState {
|
impl FighterStateImpl for JumpState {
|
||||||
@@ -174,6 +180,12 @@ impl FighterStateImpl for JumpState {
|
|||||||
crate::fighter::state::land::LandingType::Normal,
|
crate::fighter::state::land::LandingType::Normal,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(
|
pub fn check_input(
|
||||||
|
|||||||
@@ -69,4 +69,10 @@ impl FighterStateImpl for LandingState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ use crate::fighter::manifest::FighterManifest;
|
|||||||
use crate::fighter::state::hitstun::HitstunState;
|
use crate::fighter::state::hitstun::HitstunState;
|
||||||
use crate::fighter::visual::FighterAnimations;
|
use crate::fighter::visual::FighterAnimations;
|
||||||
use crate::fighter::{
|
use crate::fighter::{
|
||||||
Fighter, FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop,
|
Fighter, FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop, FighterHitstopShake, FighterHitstopShakeKind, FighterHitstopShakeRole, FighterPreviousTranslation, FighterTranslation, FighterVelocity,
|
||||||
FighterPreviousTranslation, FighterTranslation, FighterVelocity,
|
|
||||||
};
|
};
|
||||||
use crate::game_settings::GameSettings;
|
use crate::game_settings::GameSettings;
|
||||||
use crate::input::FighterInput;
|
use crate::input::FighterInput;
|
||||||
@@ -66,6 +65,10 @@ macro_rules! fighter_states {
|
|||||||
pub fn check_collision_interrupt(&mut self, ctx: &mut CollisionContext) -> Option<FighterState> {
|
pub fn check_collision_interrupt(&mut self, ctx: &mut CollisionContext) -> Option<FighterState> {
|
||||||
match self { $(Self::$variant(s) => s.check_collision_interrupt(ctx)),* }
|
match self { $(Self::$variant(s) => s.check_collision_interrupt(ctx)),* }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_visually_grounded(&self) -> bool {
|
||||||
|
match self { $(Self::$variant(s) => s.is_visually_grounded()),* }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(impl From<$ty> for FighterState {
|
$(impl From<$ty> for FighterState {
|
||||||
@@ -91,6 +94,10 @@ pub trait FighterStateImpl: Sized {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AnimationStatus {
|
pub struct AnimationStatus {
|
||||||
@@ -320,6 +327,7 @@ pub struct StatefulFighterQuery {
|
|||||||
pub attack_script_assets: &'static FighterAttackScriptAssets,
|
pub attack_script_assets: &'static FighterAttackScriptAssets,
|
||||||
pub pending_hit_reaction: &'static mut FighterPendingHitReaction,
|
pub pending_hit_reaction: &'static mut FighterPendingHitReaction,
|
||||||
pub hitstop: &'static mut FighterHitstop,
|
pub hitstop: &'static mut FighterHitstop,
|
||||||
|
pub hitstop_shake: &'static mut FighterHitstopShake,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn state_update_system(
|
pub fn state_update_system(
|
||||||
@@ -384,6 +392,7 @@ pub fn state_interrupt_system(
|
|||||||
attack_script_assets,
|
attack_script_assets,
|
||||||
mut pending_hit_reaction,
|
mut pending_hit_reaction,
|
||||||
mut hitstop,
|
mut hitstop,
|
||||||
|
mut hitstop_shake,
|
||||||
} = fighter;
|
} = fighter;
|
||||||
let manifest = fighter_manifests
|
let manifest = fighter_manifests
|
||||||
.get(&fighter.manifest)
|
.get(&fighter.manifest)
|
||||||
@@ -391,6 +400,16 @@ pub fn state_interrupt_system(
|
|||||||
|
|
||||||
let new_state = if let Some(reaction) = pending_hit_reaction.take() {
|
let new_state = if let Some(reaction) = pending_hit_reaction.take() {
|
||||||
hitstop.remaining_frames = *reaction.hitstop_frames;
|
hitstop.remaining_frames = *reaction.hitstop_frames;
|
||||||
|
let shake_frames = reaction.hitstop_frames.calculate_shake_frames(&game_settings);
|
||||||
|
hitstop_shake.role = FighterHitstopShakeRole::Receiver;
|
||||||
|
hitstop_shake.total_frames = shake_frames;
|
||||||
|
hitstop_shake.remaining_frames = shake_frames;
|
||||||
|
hitstop_shake.kind = if state.is_visually_grounded() {
|
||||||
|
FighterHitstopShakeKind::Horizontal
|
||||||
|
} else {
|
||||||
|
FighterHitstopShakeKind::Vertical
|
||||||
|
};
|
||||||
|
|
||||||
let mut hitstop_kind = match &*state {
|
let mut hitstop_kind = match &*state {
|
||||||
FighterState::Wait(value) => {
|
FighterState::Wait(value) => {
|
||||||
hitstun::HitstopStateKind::Grounded(value.grounded_common.clone())
|
hitstun::HitstopStateKind::Grounded(value.grounded_common.clone())
|
||||||
|
|||||||
@@ -64,6 +64,12 @@ impl FighterStateImpl for RunState {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
ground::collision_interrupt(state_context, &mut self.grounded_common, true)
|
ground::collision_interrupt(state_context, &mut self.grounded_common, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(
|
pub fn check_input(
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ impl FighterStateImpl for TurnState {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(
|
pub fn check_input(
|
||||||
|
|||||||
@@ -46,6 +46,12 @@ impl FighterStateImpl for WaitState {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(
|
pub fn check_input(
|
||||||
|
|||||||
@@ -56,6 +56,12 @@ impl FighterStateImpl for WalkState {
|
|||||||
) -> Option<FighterState> {
|
) -> Option<FighterState> {
|
||||||
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_visually_grounded<'a>(
|
||||||
|
&'a self,
|
||||||
|
) -> bool {
|
||||||
|
true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_input(
|
pub fn check_input(
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ pub struct FighterSettingsCommon {
|
|||||||
|
|
||||||
/// Angle diff from straight up under which the attack will force an airborne state
|
/// Angle diff from straight up under which the attack will force an airborne state
|
||||||
pub attack_ground_to_airborne_transition_vertical_angle_threshold: FGi32,
|
pub attack_ground_to_airborne_transition_vertical_angle_threshold: FGi32,
|
||||||
|
pub visual_shake_frames_per_hitstop_frame: FGi32,
|
||||||
|
// offsets applied when the fighter is in hitstop
|
||||||
|
pub visual_shake_table: Vec<f32>,
|
||||||
|
/// The attacker will always get less hitstop
|
||||||
|
pub attacker_visual_shake_multiplier: f32,
|
||||||
}
|
}
|
||||||
#[derive(Reflect, Serialize, Deserialize, Clone)]
|
#[derive(Reflect, Serialize, Deserialize, Clone)]
|
||||||
#[reflect(opaque)]
|
#[reflect(opaque)]
|
||||||
|
|||||||
Reference in New Issue
Block a user