Implement hitstun and knockback.

This commit is contained in:
2026-09-13 23:01:25 +02:00
parent 811578af2f
commit 4570860d64
26 changed files with 840 additions and 246 deletions
+17 -6
View File
@@ -26,14 +26,19 @@ impl FighterStateImpl for GroundAttackState {
}
fn update(&mut self, state_context: &mut super::FighterStateContext) {
let animation_frame = state_context.get_current_animation_frame();
let script = state_context
.attack_scripts
.get(&state_context.attack_script_assets.scripts[&self.attack_kind]);
if let Some(script) = script {
let animation_frame = state_context.get_current_animation_frame();
update_active_hitbox_list(
script,
&mut state_context.hitboxes.active_hitboxes,
&mut state_context
.hitboxes
.0
.as_mut()
.expect("ground attack must have active hitboxes")
.active_hitboxes,
animation_frame,
);
}
@@ -41,13 +46,19 @@ impl FighterStateImpl for GroundAttackState {
fn on_enter(&mut self, state_context: &mut super::FighterStateContext) {
state_context.play_animation(self.attack_kind.get_animation(), false);
state_context.hitboxes.attack_script =
Some(state_context.attack_script_assets.scripts[&self.attack_kind].clone());
state_context.hitboxes.active_hitboxes.clear();
let script = state_context.attack_script_assets.scripts[&self.attack_kind].clone();
state_context.stale_move_queue.push(self.attack_kind);
state_context.hitboxes.0 = Some(crate::fighter::FighterActiveAttack {
kind: self.attack_kind,
script,
active_hitboxes: Vec::new(),
solved_hitboxes: Vec::new(),
hit_fighters: Vec::new(),
});
}
fn on_exit(&mut self, state_context: &mut super::FighterStateContext) {
state_context.hitboxes.clear();
state_context.hitboxes.0 = None;
}
fn check_collision_interrupt(