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
use bevy::prelude::*;
use game_library::state::{AppState, Game};

/// Plugin and control flow for the settings menu.
pub struct InGamePlugin;

impl Plugin for InGamePlugin {
    fn build(&self, app: &mut App) {
        app.add_systems(OnEnter(AppState::InGame), trigger_generate);
        app.add_systems(
            OnEnter(AppState::MainMenu),
            trigger_disabled.run_if(not(in_state(Game::Disabled))),
        );
    }
}

fn trigger_generate(mut next_game_state: ResMut<NextState<Game>>) {
    tracing::info!("Triggering game generation");
    next_game_state.set(Game::Generating);
}

fn trigger_disabled(mut next_game_state: ResMut<NextState<Game>>) {
    tracing::info!("Triggering game disabled");
    next_game_state.set(Game::Disabled);
}