From 2615bbcb86bf8d23fd456f930bd40fb8e72b6e0d Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Mon, 11 Mar 2019 01:43:26 -0700 Subject: [PATCH] play(String,boolean) will now select a random file from the group (if any) --- core/src/com/riiablo/audio/Audio.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/com/riiablo/audio/Audio.java b/core/src/com/riiablo/audio/Audio.java index d04c8372..371cd7f3 100644 --- a/core/src/com/riiablo/audio/Audio.java +++ b/core/src/com/riiablo/audio/Audio.java @@ -5,6 +5,7 @@ import com.badlogic.gdx.assets.AssetDescriptor; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.audio.Music; import com.badlogic.gdx.audio.Sound; +import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.ObjectMap; import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Pools; @@ -128,6 +129,11 @@ public class Audio { if (id.isEmpty()) return null; Sounds.Entry sound = Riiablo.files.Sounds.get(id); if (sound == null) return null; + if (sound.Group_Size > 0) { + int randomId = sound.Index + MathUtils.random.nextInt(sound.Group_Size); + sound = Riiablo.files.Sounds.get(randomId); + } + return play(sound, global); } }