musicbox wip

This commit is contained in:
minjaesong
2024-04-15 20:57:27 +09:00
parent 96954983f0
commit c19184a55f
9 changed files with 220 additions and 34 deletions

View File

@@ -7,6 +7,8 @@ import com.badlogic.gdx.utils.Disposable
*/
abstract class AudioBank : Disposable {
open val notCopyable: Boolean = false
protected val hash = System.nanoTime()
abstract fun makeCopy(): AudioBank

View File

@@ -8,8 +8,10 @@ class MusicCache(val trackName: String) : Disposable {
private val cache = HashMap<String, AudioBank>()
fun getOrPut(music: AudioBank?): AudioBank? {
if (music != null)
if (music != null && !music.notCopyable)
return cache.getOrPut(music.name) { music.makeCopy() }
else if (music != null)
return music
return null
}