Add animation baking system

This commit is contained in:
2026-08-28 23:05:36 +02:00
parent c1315e09b6
commit c3f1074fe1
30 changed files with 1200 additions and 244 deletions
+10 -14
View File
@@ -4,9 +4,9 @@ use bevy::prelude::*;
use super::{FighterStateContext, FighterStateImpl, dash, ground, wait};
use crate::fighter::animation::AnimKind;
use crate::fighter::state::FighterState;
use crate::fighter::state::fall::FallState;
use crate::fighter::state::ground::{GroundedMotionResult, GroundedStateCommon};
use crate::fighter::state::FighterState;
#[derive(Debug, Clone, Hash)]
pub struct WalkState {
@@ -15,8 +15,10 @@ pub struct WalkState {
impl FighterStateImpl for WalkState {
const NAME: &'static str = "Walk";
fn check_interrupt(&self, state_context: &FighterStateContext) -> Option<FighterState> {
if let Some(state) = ground::grounded_movement_common_interrupts(state_context, &self.grounded_common) {
fn check_interrupt(&self, state_context: &mut FighterStateContext) -> Option<FighterState> {
if let Some(state) =
ground::grounded_movement_common_interrupts(state_context, &self.grounded_common)
{
return Some(state);
}
wait::check_input(state_context, &self.grounded_common)
@@ -24,27 +26,21 @@ impl FighterStateImpl for WalkState {
}
fn on_enter(&mut self, state_context: &mut FighterStateContext) {
state_context
.animation_transitions
.play(
&mut state_context.animation_player,
state_context.animations.clips[&AnimKind::Walk],
Duration::ZERO,
)
.repeat();
state_context.play_animation(AnimKind::Walk, true);
}
fn update(&mut self, state_context: &mut FighterStateContext) {
let last_frame = state_context.input.get_last_frame();
let (accel, target_vel) = state_context
.fighter_attribs
.fighter_manifest
.attributes
.get_accel_and_target_walk(&last_frame);
let accel = ground::compute_ground_accel(
accel,
target_vel,
state_context.velocity.x,
state_context.fighter_attribs,
&state_context.fighter_manifest.attributes,
&state_context.game_settings,
);
@@ -77,7 +73,7 @@ pub fn check_input(
) -> Option<FighterState> {
let input_frame = state_context.input.get_last_frame();
if input_frame.movement.x.abs() >= state_context.game_settings.input_common.stick_deadzone {
if !input_frame.movement.x.is_zero() {
return Some(FighterState::Walk(WalkState {
grounded_common: ground_state_common.clone(),
}));