Add authoritative fighter surface state (#60)
## Summary - add a rollback-tracked `FighterSurfaceState` as the single source of truth for stage contact - move active stage line ownership out of individual grounded fighter states - update landing, airborne motion, ledge departure, hit reactions, and debug save states to maintain surface contact - add tests for contact lifecycle, connected-segment traversal, and ledge departure Reviewed-on: #60 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #60.
This commit is contained in:
+12
-21
@@ -1,13 +1,11 @@
|
||||
use super::{CollisionContext, EnterContext, FighterStateImpl, InterruptContext, UpdateContext};
|
||||
use crate::fighter::animation::AnimKind;
|
||||
use crate::fighter::state::ground::{self, GroundedStateCommon};
|
||||
use crate::fighter::state::ground;
|
||||
use crate::fighter::state::{FighterState, dash, jump, wait, walk};
|
||||
use crate::input::FighterCommands;
|
||||
|
||||
#[derive(Debug, Clone, Hash)]
|
||||
pub struct TurnState {
|
||||
pub grounded_common: GroundedStateCommon,
|
||||
}
|
||||
pub struct TurnState;
|
||||
|
||||
impl FighterStateImpl for TurnState {
|
||||
const NAME: &'static str = "Turn";
|
||||
@@ -19,19 +17,19 @@ impl FighterStateImpl for TurnState {
|
||||
.input_common
|
||||
.turn_into_dashback_window as u32
|
||||
{
|
||||
if let Some(state) = dash::check_input(state_context, &self.grounded_common) {
|
||||
if let Some(state) = dash::check_input(state_context) {
|
||||
return Some(state);
|
||||
}
|
||||
}
|
||||
if let Some(state) = jump::check_input(state_context, &self.grounded_common) {
|
||||
if let Some(state) = jump::check_input(state_context) {
|
||||
*state_context.facing_direction = state_context.facing_direction.reverse();
|
||||
Some(state)
|
||||
} else if state_context.is_current_animation_finished() {
|
||||
if let Some(state) = dash::check_input(state_context, &self.grounded_common) {
|
||||
if let Some(state) = dash::check_input(state_context) {
|
||||
Some(state)
|
||||
} else if let Some(state) = walk::check_input(state_context, &self.grounded_common) {
|
||||
} else if let Some(state) = walk::check_input(state_context) {
|
||||
Some(state)
|
||||
} else if let Some(state) = wait::check_input(state_context, &self.grounded_common) {
|
||||
} else if let Some(state) = wait::check_input(state_context) {
|
||||
Some(state)
|
||||
} else {
|
||||
None
|
||||
@@ -54,20 +52,15 @@ impl FighterStateImpl for TurnState {
|
||||
&mut self,
|
||||
state_context: &mut CollisionContext,
|
||||
) -> Option<FighterState> {
|
||||
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
||||
ground::collision_interrupt(state_context, false)
|
||||
}
|
||||
|
||||
fn is_visually_grounded<'a>(
|
||||
&'a self,
|
||||
) -> bool {
|
||||
|
||||
fn is_visually_grounded<'a>(&'a self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
pub fn check_input(
|
||||
state_context: &InterruptContext,
|
||||
grounded_common: &GroundedStateCommon,
|
||||
) -> Option<FighterState> {
|
||||
pub fn check_input(state_context: &InterruptContext) -> Option<FighterState> {
|
||||
let input_frame = state_context.input.get_last_frame();
|
||||
|
||||
let has_smash_input = state_context
|
||||
@@ -81,9 +74,7 @@ pub fn check_input(
|
||||
&& input_frame.movement.x.signum() != state_context.facing_direction.to_sign()
|
||||
&& !has_smash_input
|
||||
{
|
||||
return Some(FighterState::Turn(TurnState {
|
||||
grounded_common: grounded_common.clone(),
|
||||
}));
|
||||
return Some(FighterState::Turn(TurnState));
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user