initialize audio tween pool with 16 instances

pull/47/head
cosmonaut 2023-03-07 00:12:45 -08:00
parent c0ed7bc13d
commit 34aa069d6b
2 changed files with 9 additions and 2 deletions

View File

@ -26,7 +26,15 @@ namespace MoonWorks.Audio
internal class AudioTweenPool internal class AudioTweenPool
{ {
private Queue<AudioTween> Tweens = new Queue<AudioTween>(); private Queue<AudioTween> Tweens = new Queue<AudioTween>(16);
public AudioTweenPool()
{
for (int i = 0; i < 16; i += 1)
{
Tweens.Enqueue(new AudioTween());
}
}
public AudioTween Obtain() public AudioTween Obtain()
{ {

View File

@ -106,7 +106,6 @@ namespace MoonWorks.Audio
) { ) {
if (AudioTweens.TryGetValue((audioTween.SoundInstanceReference, audioTween.Property), out var currentTween)) if (AudioTweens.TryGetValue((audioTween.SoundInstanceReference, audioTween.Property), out var currentTween))
{ {
Logger.LogInfo("overriding tween!");
AudioTweenPool.Free(currentTween); AudioTweenPool.Free(currentTween);
} }