Reviewed-on: #30 Co-authored-by: Álex Román Núñez <eirexe@eirteam.moe>
This commit was merged in pull request #30.
This commit is contained in:
+16
-22
@@ -1,6 +1,9 @@
|
||||
use std::hash::Hasher;
|
||||
|
||||
use super::{FighterStateContext, FighterStateImpl, ground, run, wait, walk};
|
||||
use super::{
|
||||
CollisionContext, EnterContext, FighterStateImpl, InterruptContext, UpdateContext, ground, run,
|
||||
wait, walk,
|
||||
};
|
||||
use crate::fighter::FighterFacingDirection;
|
||||
use crate::fighter::animation::AnimKind;
|
||||
use crate::fighter::state::FighterState;
|
||||
@@ -31,9 +34,9 @@ impl DashState {
|
||||
|
||||
impl FighterStateImpl for DashState {
|
||||
const NAME: &'static str = "Dash";
|
||||
fn check_interrupt(&self, ctx: &mut FighterStateContext) -> Option<FighterState> {
|
||||
fn check_interrupt(&self, ctx: &mut InterruptContext) -> Option<FighterState> {
|
||||
let ground = &self.ground_common;
|
||||
let attributes = ctx.fighter_manifest.attributes;
|
||||
let attributes = ctx.fighter_attributes;
|
||||
|
||||
// A reverse dash can interrupt before IASA
|
||||
if let Some(direction) =
|
||||
@@ -62,13 +65,10 @@ impl FighterStateImpl for DashState {
|
||||
None
|
||||
}
|
||||
|
||||
fn on_enter(&mut self, state_context: &mut FighterStateContext) {
|
||||
fn on_enter(&mut self, state_context: &mut EnterContext) {
|
||||
*state_context.facing_direction = self.direction;
|
||||
state_context.velocity.x = state_context
|
||||
.fighter_manifest
|
||||
.attributes
|
||||
.dash_initial_velocity
|
||||
* self.direction.to_sign();
|
||||
state_context.velocity.x =
|
||||
state_context.fighter_attributes.dash_initial_velocity * self.direction.to_sign();
|
||||
|
||||
state_context.play_animation(AnimKind::Dash, false);
|
||||
|
||||
@@ -86,24 +86,20 @@ impl FighterStateImpl for DashState {
|
||||
}
|
||||
}
|
||||
|
||||
fn update(&mut self, state_context: &mut FighterStateContext) {
|
||||
fn update(&mut self, state_context: &mut UpdateContext) {
|
||||
if state_context.get_current_animation_frame()
|
||||
< state_context
|
||||
.fighter_manifest
|
||||
.attributes
|
||||
.dash_acceleration_duration
|
||||
< state_context.fighter_attributes.dash_acceleration_duration
|
||||
{}
|
||||
|
||||
let last_frame = state_context.input.get_last_frame();
|
||||
let (accel, target_vel) = state_context
|
||||
.fighter_manifest
|
||||
.attributes
|
||||
.fighter_attributes
|
||||
.get_accel_and_target_dashrun(&last_frame, self.direction.to_sign());
|
||||
let accel = ground::compute_ground_accel(
|
||||
accel,
|
||||
target_vel,
|
||||
state_context.velocity.x,
|
||||
&state_context.fighter_manifest.attributes,
|
||||
state_context.fighter_attributes,
|
||||
state_context.game_settings,
|
||||
);
|
||||
state_context.velocity.x += accel;
|
||||
@@ -117,7 +113,7 @@ impl FighterStateImpl for DashState {
|
||||
|
||||
fn check_collision_interrupt(
|
||||
&mut self,
|
||||
state_context: &mut FighterStateContext,
|
||||
state_context: &mut CollisionContext,
|
||||
) -> Option<FighterState> {
|
||||
if let GroundedMotionResult::InAir =
|
||||
ground::collide_with_stage_grounded(state_context, &mut self.ground_common, true)
|
||||
@@ -129,9 +125,7 @@ impl FighterStateImpl for DashState {
|
||||
}
|
||||
}
|
||||
|
||||
fn check_smash_input_with_dir(
|
||||
state_context: &FighterStateContext,
|
||||
) -> Option<FighterFacingDirection> {
|
||||
fn check_smash_input_with_dir(state_context: &InterruptContext) -> Option<FighterFacingDirection> {
|
||||
if state_context.input.has_command(SmashMoveLeft) {
|
||||
return Some(FighterFacingDirection::Left);
|
||||
} else if state_context.input.has_command(SmashMoveRight) {
|
||||
@@ -142,7 +136,7 @@ fn check_smash_input_with_dir(
|
||||
}
|
||||
|
||||
pub fn check_input(
|
||||
state_context: &FighterStateContext,
|
||||
state_context: &InterruptContext,
|
||||
ground_common: &GroundedStateCommon,
|
||||
) -> Option<FighterState> {
|
||||
check_smash_input_with_dir(state_context)
|
||||
|
||||
Reference in New Issue
Block a user