use super::*; /// A good starting place for creating a game building on top of the base Bevy app pub struct BaseGamePlugin; impl Plugin for BaseGamePlugin { fn build(&self, app: &mut App) { app.add_plugins(DefaultPlugins) .add_plugins(DebuggingPlugin) .add_plugins(MeshPickingPlugin) .add_plugins(RapierPhysicsPlugin::::default()) .add_plugins(LoadingPlugin) .add_systems(Startup, setup_camera) .init_state::(); } } #[derive(States, Clone, PartialEq, Eq, Hash, Debug, Default)] pub enum GameState { #[default] Loading, Main, } /// System to toggle the visibility of entities based on their state pub fn toggle_state_visibility( mut q: Query<(Entity, &mut Visibility, &S)>, curr: Res>, ) { q.iter_mut().for_each(|(e, mut v, s)| { if curr.get() == s { *v = Visibility::Inherited; } else { *v = Visibility::Hidden; } debug!("Changing visibility of {:?} to {:?}", e, *v); }); } pub fn setup_camera(mut commands: Commands) { commands.spawn((Camera3d { ..default() }, Camera { ..default() })); }