create scaffolding
This commit is contained in:
commit
82a0fbdb50
25 changed files with 6993 additions and 0 deletions
12
crates/ui_state/Cargo.toml
Normal file
12
crates/ui_state/Cargo.toml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
[package]
|
||||
name = "ui_state"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bevy = { workspace = true }
|
||||
|
||||
state = { path = "../state" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
32
crates/ui_state/src/lib.rs
Normal file
32
crates/ui_state/src/lib.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//bevy system signatures often violate these rules
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use bevy::prelude::*;
|
||||
use state::{AppState, GameState};
|
||||
|
||||
pub struct UiStatePlugin;
|
||||
|
||||
impl Plugin for UiStatePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_sub_state::<GameUIState>()
|
||||
.add_systems(OnEnter(GameState::Paused), on_pause)
|
||||
.add_systems(OnExit(GameState::Paused), on_unpause);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Hash, SubStates, Default)]
|
||||
#[source(AppState = AppState::Game)]
|
||||
pub enum GameUIState {
|
||||
#[default]
|
||||
Default,
|
||||
Paused,
|
||||
}
|
||||
|
||||
fn on_pause(mut next: ResMut<NextState<GameUIState>>) {
|
||||
next.set(GameUIState::Paused)
|
||||
}
|
||||
|
||||
fn on_unpause(mut next: ResMut<NextState<GameUIState>>) {
|
||||
next.set(GameUIState::Default)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue