CI / build-and-test (push) Successful in 1m22s
Reviewed-on: #42 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
70 lines
2.0 KiB
Rust
70 lines
2.0 KiB
Rust
use super::{
|
|
CollisionContext, EnterContext, FighterStateImpl, InterruptContext, UpdateContext, ground,
|
|
};
|
|
use crate::fighter::animation::AnimKind;
|
|
use crate::fighter::state::FighterState;
|
|
use crate::fighter::state::ground::GroundedStateCommon;
|
|
|
|
#[derive(Debug, Clone, Hash)]
|
|
pub struct WaitState {
|
|
pub grounded_common: GroundedStateCommon,
|
|
}
|
|
|
|
impl FighterStateImpl for WaitState {
|
|
const NAME: &'static str = "Wait";
|
|
fn check_interrupt(&self, state_context: &mut InterruptContext) -> Option<FighterState> {
|
|
if let Some(state) =
|
|
ground::grounded_movement_common_interrupts(state_context, &self.grounded_common)
|
|
{
|
|
Some(state)
|
|
} else if let Some(state) = ground::grounded_movement_standstill_common_interrupts(
|
|
state_context,
|
|
&self.grounded_common,
|
|
) {
|
|
// Don't transition into yourself
|
|
if let FighterState::Wait(_) = state {
|
|
None
|
|
} else {
|
|
Some(state)
|
|
}
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
|
|
fn on_enter(&mut self, state_context: &mut EnterContext) {
|
|
state_context.play_animation(AnimKind::Wait, true);
|
|
}
|
|
|
|
fn update(&mut self, state_context: &mut UpdateContext) {
|
|
ground::update_friction_motion(state_context);
|
|
}
|
|
|
|
fn check_collision_interrupt(
|
|
&mut self,
|
|
state_context: &mut CollisionContext,
|
|
) -> Option<FighterState> {
|
|
ground::collision_interrupt(state_context, &mut self.grounded_common, false)
|
|
}
|
|
|
|
fn is_visually_grounded<'a>(
|
|
&'a self,
|
|
) -> bool {
|
|
true
|
|
}
|
|
}
|
|
|
|
pub fn check_input(
|
|
state_context: &InterruptContext,
|
|
ground_state_common: &GroundedStateCommon,
|
|
) -> 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 {
|
|
return Some(FighterState::Wait(WaitState {
|
|
grounded_common: ground_state_common.clone(),
|
|
}));
|
|
}
|
|
None
|
|
}
|