Make music loop

This commit is contained in:
Sofia 2026-07-28 21:13:07 +03:00
parent fac936b97a
commit 927a904c72
4 changed files with 14 additions and 4 deletions

View File

@ -32,7 +32,17 @@ impl MusicManager {
get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL) get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL)
} }
pub fn play(&mut self, music: Option<Music>) { pub fn ready(&mut self) {
if let Some(player) = self.player.clone() {
player.signals().finished().connect_other(self, |s| {
if let Some(playing) = s.currently_playing {
s.play(Some(playing), true);
}
});
}
}
pub fn play(&mut self, music: Option<Music>, force: bool) {
if self.currently_playing == music { if self.currently_playing == music {
return; return;
} }

View File

@ -460,7 +460,7 @@ impl Game {
} }
MusicManager::singleton() MusicManager::singleton()
.bind_mut() .bind_mut()
.play(Some(Music::Map(self.selected_map_idx))); .play(Some(Music::Map(self.selected_map_idx)), false);
self.run_deferred(|_| { self.run_deferred(|_| {
if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer { if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer {

View File

@ -192,7 +192,7 @@ impl IPanel for LobbyPanel {
MusicManager::singleton() MusicManager::singleton()
.bind_mut() .bind_mut()
.play(Some(Music::MainMenu)); .play(Some(Music::MainMenu), false);
} }
} }

View File

@ -102,7 +102,7 @@ impl INode3D for MainMenu {
MusicManager::singleton() MusicManager::singleton()
.bind_mut() .bind_mut()
.play(Some(Music::MainMenu)); .play(Some(Music::MainMenu), false);
} }
fn process(&mut self, _delta: f64) { fn process(&mut self, _delta: f64) {