Newer
Older
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
36
37
38
39
40
41
42
43
use bevy::prelude::*;
/// An enum representing the current set of systems that should be running
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, Debug, Hash, States, Default)]
pub enum AppState {
/// During the preload state, embedded resources will be registered with Bevy.
/// Embedded resources will be attached to the asset system with the path
/// `internal:{resource-name}`
#[default]
Preload,
/// During the setup state, external resources will be registered by reading from
/// the filesystem or the network. Progress can be displayed using the embedded
/// resources loaded in the previous state
Setup,
/// The splash state exists solely to render attributions & logos before starting
/// the game
Splash,
/// An initial landing page that will present players with options
Menu,
/// The in game state runs all of the actual gameplay logic. Most of the runtime
/// will be spent here.
InGame,
}
pub fn run_in_game(state: Res<State<AppState>>) -> bool {
**state == AppState::InGame
}
pub fn run_in_menu(state: Res<State<AppState>>) -> bool {
**state == AppState::Menu
}
pub fn run_in_splash(state: Res<State<AppState>>) -> bool {
**state == AppState::Splash
}
pub fn run_in_setup(state: Res<State<AppState>>) -> bool {
**state == AppState::Setup
}
pub struct FlowPlugin;
impl Plugin for FlowPlugin {
fn build(&self, app: &mut App) {
app.add_state::<AppState>();
}
}