1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::app::Phase;
use starbase_macros::{system, State};

// This is a hack for starbase macros to work from within
// the starbase crate itself!
mod starbase {
    pub use crate::*;
}

#[derive(Debug, State)]
pub struct AppState {
    pub phase: Phase,
}

#[system]
pub async fn start_startup_phase(states: StatesMut) {
    states.set(AppState {
        phase: Phase::Startup,
    });
}

#[system]
pub async fn start_analyze_phase(app_state: StateMut<AppState>) {
    app_state.phase = Phase::Analyze;
}

#[system]
pub async fn start_execute_phase(app_state: StateMut<AppState>) {
    app_state.phase = Phase::Execute;
}

#[system]
pub async fn start_shutdown_phase(app_state: StateMut<AppState>) {
    app_state.phase = Phase::Shutdown;
}