hassium_core/
state.rs

1use crate::id::ID;
2use specs::World;
3
4pub enum StateChange {
5    None,
6    Push(Box<dyn State>),
7    Pop,
8    Swap(Box<dyn State>),
9    Quit,
10}
11
12pub trait State {
13    fn on_enter(&mut self, _world: &mut World) {}
14    fn on_exit(&mut self, _world: &mut World) {}
15    fn on_pause(&mut self, _world: &mut World) {}
16    fn on_resume(&mut self, _world: &mut World) {}
17    fn on_process(&mut self, _world: &mut World) -> StateChange {
18        StateChange::None
19    }
20    fn on_process_background(&mut self, _world: &mut World) {}
21}
22
23impl State for () {}
24
25pub type StateToken = ID<()>;