using System.Collections.Generic; namespace OpenRa.Game { class VoicePool { readonly string[] clips; readonly List liveclips = new List(); 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; } } }