create scaffolding
This commit is contained in:
commit
82a0fbdb50
25 changed files with 6993 additions and 0 deletions
49
crates/setup/src/lib.rs
Normal file
49
crates/setup/src/lib.rs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//bevy system signatures often violate these rules
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use bevy::prelude::*;
|
||||
use state::AppState;
|
||||
|
||||
pub struct SetupPlugin;
|
||||
|
||||
impl Plugin for SetupPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_sub_state::<LoadState>()
|
||||
.add_sub_state::<ExampleLoadSubState>()
|
||||
.add_systems(OnEnter(LoadState::NotStarted), start_loading)
|
||||
.add_systems(
|
||||
Update,
|
||||
finish_loading.run_if(
|
||||
in_state(LoadState::Loading).and(in_state(ExampleLoadSubState::Loaded)),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, SubStates, Default)]
|
||||
#[source(AppState = AppState::Setup)]
|
||||
enum LoadState {
|
||||
#[default]
|
||||
NotStarted,
|
||||
Loading,
|
||||
}
|
||||
|
||||
fn start_loading(mut next_state: ResMut<NextState<LoadState>>) {
|
||||
info!("started loading...");
|
||||
next_state.set(LoadState::Loading);
|
||||
}
|
||||
|
||||
fn finish_loading(mut next_state: ResMut<NextState<AppState>>) {
|
||||
info!("finished loading");
|
||||
next_state.set(AppState::Game);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, SubStates, Default)]
|
||||
#[source(LoadState = LoadState::Loading)]
|
||||
#[allow(dead_code)]
|
||||
enum ExampleLoadSubState {
|
||||
Loading,
|
||||
#[default]
|
||||
Loaded,
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue