mirror of
https://github.com/kristoferssolo/maze-ascension.git
synced 2025-10-21 19:20:34 +00:00
feat(music): remove music
This commit is contained in:
parent
29b18d0ed0
commit
6685e3e2c9
Binary file not shown.
Binary file not shown.
@ -53,7 +53,7 @@ impl Plugin for AppPlugin {
|
||||
})
|
||||
.set(AudioPlugin {
|
||||
global_volume: GlobalVolume {
|
||||
volume: Volume::new(0.),
|
||||
volume: Volume::new(0.3),
|
||||
},
|
||||
..default()
|
||||
}),
|
||||
|
||||
@ -3,7 +3,7 @@ mod movement;
|
||||
pub mod setup;
|
||||
mod vertical_transition;
|
||||
|
||||
use crate::screens::Screen;
|
||||
use crate::{screens::Screen, AppSet};
|
||||
use bevy::prelude::*;
|
||||
use input::player_input;
|
||||
use movement::player_movement;
|
||||
@ -12,7 +12,11 @@ use vertical_transition::handle_floor_transition;
|
||||
pub(super) fn plugin(app: &mut App) {
|
||||
app.add_systems(
|
||||
Update,
|
||||
(player_input, player_movement, handle_floor_transition)
|
||||
(
|
||||
player_input.in_set(AppSet::RecordInput),
|
||||
player_movement,
|
||||
handle_floor_transition.in_set(AppSet::RecordInput),
|
||||
)
|
||||
.chain()
|
||||
.run_if(in_state(Screen::Gameplay)),
|
||||
);
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
//! The screen state for the main gameplay.
|
||||
|
||||
use bevy::{input::common_conditions::input_just_pressed, prelude::*};
|
||||
|
||||
use crate::maze::spawn_level_command;
|
||||
use crate::player::spawn_player_command;
|
||||
use crate::{asset_tracking::LoadResource, audio::Music, screens::Screen};
|
||||
use crate::screens::Screen;
|
||||
|
||||
use bevy::{input::common_conditions::input_just_pressed, prelude::*};
|
||||
|
||||
pub(super) fn plugin(app: &mut App) {
|
||||
app.add_systems(
|
||||
@ -12,10 +12,6 @@ pub(super) fn plugin(app: &mut App) {
|
||||
(spawn_level_command, spawn_player_command).chain(),
|
||||
);
|
||||
|
||||
app.load_resource::<GameplayMusic>();
|
||||
app.add_systems(OnEnter(Screen::Gameplay), play_gameplay_music);
|
||||
app.add_systems(OnExit(Screen::Gameplay), stop_music);
|
||||
|
||||
app.add_systems(
|
||||
Update,
|
||||
return_to_title_screen
|
||||
@ -23,41 +19,6 @@ pub(super) fn plugin(app: &mut App) {
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(Resource, Asset, Reflect, Clone)]
|
||||
pub struct GameplayMusic {
|
||||
#[dependency]
|
||||
handle: Handle<AudioSource>,
|
||||
entity: Option<Entity>,
|
||||
}
|
||||
|
||||
impl FromWorld for GameplayMusic {
|
||||
fn from_world(world: &mut World) -> Self {
|
||||
let assets = world.resource::<AssetServer>();
|
||||
Self {
|
||||
handle: assets.load("audio/music/Fluffing A Duck.ogg"),
|
||||
entity: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn play_gameplay_music(mut commands: Commands, mut music: ResMut<GameplayMusic>) {
|
||||
music.entity = Some(
|
||||
commands
|
||||
.spawn((
|
||||
AudioPlayer::<AudioSource>(music.handle.clone()),
|
||||
PlaybackSettings::LOOP,
|
||||
Music,
|
||||
))
|
||||
.id(),
|
||||
);
|
||||
}
|
||||
|
||||
fn stop_music(mut commands: Commands, mut music: ResMut<GameplayMusic>) {
|
||||
if let Some(entity) = music.entity.take() {
|
||||
commands.entity(entity).despawn_recursive();
|
||||
}
|
||||
}
|
||||
|
||||
fn return_to_title_screen(mut next_screen: ResMut<NextState<Screen>>) {
|
||||
next_screen.set(Screen::Title);
|
||||
}
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::{
|
||||
screens::{gameplay::GameplayMusic, Screen},
|
||||
screens::Screen,
|
||||
theme::{interaction::InteractionAssets, prelude::*},
|
||||
};
|
||||
|
||||
pub(super) fn plugin(app: &mut App) {
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(OnEnter(Screen::Loading), spawn_loading_screen);
|
||||
|
||||
app.add_systems(
|
||||
@ -33,9 +33,6 @@ fn continue_to_title_screen(mut next_screen: ResMut<NextState<Screen>>) {
|
||||
next_screen.set(Screen::Title);
|
||||
}
|
||||
|
||||
const fn all_assets_loaded(
|
||||
interaction_assets: Option<Res<InteractionAssets>>,
|
||||
gameplay_music: Option<Res<GameplayMusic>>,
|
||||
) -> bool {
|
||||
interaction_assets.is_some() && gameplay_music.is_some()
|
||||
const fn all_assets_loaded(interaction_assets: Option<Res<InteractionAssets>>) -> bool {
|
||||
interaction_assets.is_some()
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ use bevy::{
|
||||
|
||||
use crate::{screens::Screen, theme::prelude::*, AppSet};
|
||||
|
||||
pub(super) fn plugin(app: &mut App) {
|
||||
pub fn plugin(app: &mut App) {
|
||||
// Spawn splash screen.
|
||||
app.insert_resource(ClearColor(SPLASH_BACKGROUND_COLOR));
|
||||
app.add_systems(OnEnter(Screen::Splash), spawn_splash_screen);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user