FSO.Content.Audio.GetSFX C# (CSharp) Method

GetSFX() public method

Gets a sound effect from the sound effects cache.
public GetSFX ( uint InstanceID ) : SoundEffect
InstanceID uint The InstanceID of the sound effect.
return Microsoft.Xna.Framework.Audio.SoundEffect
        public SoundEffect GetSFX(uint InstanceID)
        {
            if (SFXCache.ContainsKey(InstanceID)) return SFXCache[InstanceID];

            byte[] data = GetAudioFrom(InstanceID, TSOAudio);
            if (data == null) data = GetAudioFrom(InstanceID, tsov2);
            if (data == null) data = GetAudioFrom(InstanceID, Stings);
            if (data == null) data = GetAudioFrom(InstanceID, EP5Samps);
            if (data == null) data = GetAudioFrom(InstanceID, EP2);

            if (data != null)
            {
                var stream = new MemoryStream(data);

                    var sfx = SoundEffect.FromStream(stream);
                    stream.Close();
                    SFXCache.Add(InstanceID, sfx);
                    return sfx; //remember to clear the sfx cache between lots!

            }
            else
            {
                //GCHandle pinnedArray = GCHandle.Alloc(new byte[1], GCHandleType.Weak);
                return null;// pinnedArray; //we couldn't find anything! can't return null so do this... not the best idea tbh
            }
        }