Fix music not looping

This commit is contained in:
Sofia 2026-07-29 00:57:42 +03:00
parent f8759423bc
commit 5ccb0cd794
2 changed files with 10 additions and 8 deletions

View File

@ -9,4 +9,3 @@ main_menu_songs = Array[AudioStream]([ExtResource("1_xy4vl"), ExtResource("2_t25
[node name="audio_stream_player" type="AudioStreamPlayer" parent="." unique_id=1469531096]
bus = &"Music"
playback_type = 1

View File

@ -27,12 +27,9 @@ pub struct MusicManager {
base: Base<Node3D>,
}
impl MusicManager {
pub fn singleton() -> Gd<MusicManager> {
get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL)
}
pub fn ready(&mut self) {
#[godot_api]
impl INode3D for MusicManager {
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 {
@ -41,9 +38,15 @@ impl MusicManager {
});
}
}
}
impl MusicManager {
pub fn singleton() -> Gd<MusicManager> {
get_autoload_by_name::<MusicManager>(MUSIC_MANAGER_GLOBAL)
}
pub fn play(&mut self, music: Option<Music>, force: bool) {
if self.currently_playing == music {
if self.currently_playing == music && !force {
return;
}
self.currently_playing = music;