Refactor state system
This commit is contained in:
+22
-3
@@ -1,8 +1,11 @@
|
||||
use bevy::prelude::*;
|
||||
use crate::fighter::states;
|
||||
use bevy_egui::{EguiContexts, EguiPrimaryContextPass, egui};
|
||||
use crate::fighter::state::StateNameDebug;
|
||||
use crate::fighter::{FighterVelocity, states};
|
||||
use crate::fighter::{
|
||||
FighterECB, FighterTranslation, FighterVelocity, apply_motion, collide_fighter_with_scene, integrate_gravity, state::state_interrupt_system,
|
||||
apply_motion, collide_fighter_with_scene, integrate_gravity, state::state_interrupt_system,
|
||||
};
|
||||
use crate::input::player::FighterInput;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct FighterPlugin;
|
||||
@@ -16,14 +19,30 @@ impl Plugin for FighterPlugin {
|
||||
state_interrupt_system::<states::wait::WaitState>,
|
||||
state_interrupt_system::<states::walk::WalkState>,
|
||||
state_interrupt_system::<states::dash::DashState>,
|
||||
state_interrupt_system::<states::run::RunState>,
|
||||
states::wait::wait_update,
|
||||
states::walk::walk_update,
|
||||
states::dash::dash_update,
|
||||
states::run::run_update,
|
||||
integrate_gravity,
|
||||
apply_motion,
|
||||
collide_fighter_with_scene,
|
||||
)
|
||||
.chain(),
|
||||
)
|
||||
.add_observer(states::dash::on_insert_dash);
|
||||
.add_observer(states::dash::on_insert_dash)
|
||||
.add_systems(EguiPrimaryContextPass, fighter_debug);
|
||||
}
|
||||
}
|
||||
|
||||
fn fighter_debug(mut contexts: EguiContexts, query: Query<(&FighterVelocity, &FighterInput, &StateNameDebug)>) -> Result {
|
||||
for (vel, input, name) in query {
|
||||
egui::Window::new("Hello").show(contexts.ctx_mut()?, |ui| {
|
||||
ui.label(format!("State: {}", name.0));
|
||||
ui.label(format!("{:?}", vel));
|
||||
ui.label(format!("{:?}", input.get_last_frame()));
|
||||
});
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user