mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
musicbox wip
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user