Skip to content
Snippets Groups Projects
flow.rs 1.37 KiB
Newer Older
Louis's avatar
Louis committed
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>();
	}
}