Add animation baking system
This commit is contained in:
+27
-29
@@ -3,15 +3,18 @@ use std::time::Duration;
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::fighter::{
|
||||
animation::AnimKind,
|
||||
state::{
|
||||
FighterState, FighterStateContext, FighterStateImpl, dash,
|
||||
fall::FallState,
|
||||
ground::{self, GroundedMotionResult, GroundedStateCommon},
|
||||
wait::WaitState,
|
||||
walk,
|
||||
animation::AnimKind,
|
||||
state::{
|
||||
FighterState, FighterStateContext, FighterStateImpl, dash,
|
||||
fall::FallState,
|
||||
ground::{
|
||||
self, GroundedMotionResult, GroundedStateCommon,
|
||||
grounded_movement_standstill_common_interrupts,
|
||||
},
|
||||
};
|
||||
wait::WaitState,
|
||||
walk,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Hash)]
|
||||
pub struct LandingState {
|
||||
@@ -31,12 +34,10 @@ impl LandingState {
|
||||
impl FighterStateImpl for LandingState {
|
||||
const NAME: &'static str = "Landing";
|
||||
|
||||
fn check_interrupt(&self, state_context: &FighterStateContext) -> Option<FighterState> {
|
||||
if self.duration_counter >= state_context.fighter_attribs.landing_duration {
|
||||
Some(FighterState::Wait(WaitState {
|
||||
grounded_common: self.grounded_common.clone(),
|
||||
}))
|
||||
} else if self.duration_counter >= state_context.fighter_attribs.landing_iasa {
|
||||
fn check_interrupt(&self, state_context: &mut FighterStateContext) -> Option<FighterState> {
|
||||
if state_context.is_current_animation_finished() {
|
||||
grounded_movement_standstill_common_interrupts(state_context, &self.grounded_common)
|
||||
} else if self.duration_counter >= state_context.fighter_manifest.attributes.landing_iasa {
|
||||
dash::check_input(state_context, &self.grounded_common).or_else(|| {
|
||||
ground::grounded_movement_common_interrupts(state_context, &self.grounded_common)
|
||||
.or_else(|| walk::check_input(state_context, &self.grounded_common))
|
||||
@@ -49,16 +50,17 @@ impl FighterStateImpl for LandingState {
|
||||
fn update(&mut self, state_context: &mut FighterStateContext) {
|
||||
self.duration_counter += 1;
|
||||
|
||||
let friction =
|
||||
if state_context.velocity.x.abs() > state_context.fighter_attribs.max_walk_vel {
|
||||
state_context.fighter_attribs.ground_friction
|
||||
* state_context
|
||||
.game_settings
|
||||
.fighter_common
|
||||
.ground_friction_over_walk_speed_multiplier
|
||||
} else {
|
||||
state_context.fighter_attribs.ground_friction
|
||||
};
|
||||
let friction = if state_context.velocity.x.abs()
|
||||
> state_context.fighter_manifest.attributes.max_walk_vel
|
||||
{
|
||||
state_context.fighter_manifest.attributes.ground_friction
|
||||
* state_context
|
||||
.game_settings
|
||||
.fighter_common
|
||||
.ground_friction_over_walk_speed_multiplier
|
||||
} else {
|
||||
state_context.fighter_manifest.attributes.ground_friction
|
||||
};
|
||||
|
||||
let ground_velocity = state_context.velocity.x;
|
||||
|
||||
@@ -85,10 +87,6 @@ impl FighterStateImpl for LandingState {
|
||||
}
|
||||
|
||||
fn on_enter(&mut self, state_context: &mut FighterStateContext) {
|
||||
state_context.animation_transitions.play(
|
||||
state_context.animation_player,
|
||||
state_context.animations.clips[&AnimKind::Landing],
|
||||
Duration::ZERO,
|
||||
);
|
||||
state_context.play_animation(AnimKind::Landing, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user