﻿using ImpactCFX.Pooling;
using UnityEngine;

namespace ImpactCFX.Wwise
{
    public class WwiseAudioEffectProxyPool : ObjectPool<WwiseAudioEffectProxy>
    {
        private EffectAttachMode effectAttachMode;
        private float audioFadeOutTime;

        public void Setup(EffectAttachMode effectAttachMode, float audioFadeOutTime)
        {
            this.effectAttachMode = effectAttachMode;
            this.audioFadeOutTime = audioFadeOutTime;
        }

        protected override WwiseAudioEffectProxy createPooledObjectInstance(int index)
        {
            GameObject g = new GameObject("Wwise Audio Effect Proxy " + index);
            WwiseAudioEffectProxy f = g.AddComponent<WwiseAudioEffectProxy>();

            f.EffectAttachMode = effectAttachMode;
            f.AudioFadeOutTime = audioFadeOutTime;
            f.SetParentPoolGameObject(this.gameObject);
            f.ReturnToPool();

            AkGameObj akGameObj = g.AddComponent<AkGameObj>();

            return f;
        }
    }
}
