From efca0b8e8cc31a66d273ebe48819d11cd8d09aad Mon Sep 17 00:00:00 2001 From: Luke Hubmayer-Werner Date: Thu, 18 Jul 2024 14:46:40 +0930 Subject: [PATCH] don't delete cache for currently playing bgm --- test/audio_system.gd | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/audio_system.gd b/test/audio_system.gd index a07835e..e319215 100644 --- a/test/audio_system.gd +++ b/test/audio_system.gd @@ -94,10 +94,14 @@ func evaluate_bgm(id: int): bgm_tracksets[id] = tracks func _play_bgm_jaot(key: String) -> void: + self.queued_bgm_playback = '' var target_time := 0.0 var bgm_key_and_tempo_thou := key.split('-') var bgm_key := bgm_key_and_tempo_thou[0] var tempo_thou := int(bgm_key_and_tempo_thou[1]) + if key == self.current_bgm_playback: + self.audio_player.play(0) + return if audio_player.playing and self.current_bgm_playback.begins_with(bgm_key): var old_tempo_thou := int(self.current_bgm_playback.split('-')[1]) var old_playback_pos: float = audio_player.get_playback_position() @@ -109,7 +113,6 @@ func _play_bgm_jaot(key: String) -> void: self.audio_player.play(target_time) self.prerendered_bgms.erase(self.current_bgm_playback) # purge previous stream from cache self.current_bgm_playback = key - self.queued_bgm_playback = '' func play_bgm(id: int, live: bool) -> void: