Files
OpenRA/OpenRa.Game/VoicePool.cs
Chris Forbes 1faa2ae0b3 it works
2009-12-05 15:34:53 +13:00

30 lines
583 B
C#

using System.Collections.Generic;
namespace OpenRa.Game
{
class VoicePool
{
readonly string[] clips;
readonly List<string> liveclips = new List<string>();
public VoicePool(params string[] clips)
{
this.clips = clips;
}
public string GetNext()
{
if (liveclips.Count == 0)
liveclips.AddRange(clips);
if (liveclips.Count == 0)
return null; /* avoid crashing if there's no clips at all */
var i = Game.CosmeticRandom.Next(liveclips.Count);
var s = liveclips[i];
liveclips.RemoveAt(i);
return s;
}
}
}