use crate::app::{App, Stage};
use crate::ecs::world::World;
pub fn current_state<S: Copy + PartialEq + Send + Sync + 'static>(world: &World) -> S {
freecs::state::current_state::<S, World>(world)
}
impl App {
pub fn insert_state<S: Copy + PartialEq + Send + Sync + 'static>(
&mut self,
initial: S,
) -> &mut Self {
freecs::state::insert_state(&mut self.world, initial);
self.add_system(
Stage::First,
freecs::state::apply_state_transition::<S, World>,
);
self
}
pub fn on_enter<S: Copy + PartialEq + Send + Sync + 'static, Marker>(
&mut self,
state: S,
systems: impl freecs::state::IntoGroupRunner<World, Marker>,
) -> &mut Self {
self.add_system(Stage::First, freecs::state::on_enter(state, systems));
self
}
pub fn on_exit<S: Copy + PartialEq + Send + Sync + 'static, Marker>(
&mut self,
state: S,
systems: impl freecs::state::IntoGroupRunner<World, Marker>,
) -> &mut Self {
self.add_system(Stage::First, freecs::state::on_exit(state, systems));
self
}
}