create scaffolding
This commit is contained in:
commit
82a0fbdb50
25 changed files with 6993 additions and 0 deletions
14
crates/ui_pause/Cargo.toml
Normal file
14
crates/ui_pause/Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "ui_pause"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
bevy = { workspace = true }
|
||||
|
||||
state = { path = "../state" }
|
||||
input = { path = "../input" }
|
||||
ui_state = { path = "../ui_state" }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
30
crates/ui_pause/src/lib.rs
Normal file
30
crates/ui_pause/src/lib.rs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
//bevy system signatures often violate these rules
|
||||
#![allow(clippy::type_complexity)]
|
||||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use bevy::prelude::*;
|
||||
use input::{actions::InputAction, conditions::action_just_pressed};
|
||||
use state::{GameState, GameSystemSet};
|
||||
|
||||
pub struct UiPausePlugin;
|
||||
|
||||
impl Plugin for UiPausePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_systems(
|
||||
Update,
|
||||
toggle_pause
|
||||
.in_set(GameSystemSet::PreUpdate)
|
||||
.run_if(action_just_pressed::<Update>(InputAction::TogglePause)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn toggle_pause(state: Res<State<GameState>>, mut next_state: ResMut<NextState<GameState>>) {
|
||||
let next = match state.get() {
|
||||
GameState::Loading => GameState::Loading,
|
||||
GameState::Running => GameState::Paused,
|
||||
GameState::Paused => GameState::Running,
|
||||
};
|
||||
info!("toggle pause, changing to {:?}", next);
|
||||
next_state.set(next);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue