using ImpactCFX;
using UnityEngine;

//Implementation of PooledEffectObjectBase
public class ExampleEffectPooledObject : PooledEffectObjectBase
{
    private float currentValue;

    //Called when an effect is played for the first time.
    public void PlayNewEffect(float value, Vector3 position)
    {
        currentValue = value;
        transform.position = position;
    }

    //Called when the effect is updated from sliding or rolling.
    public void UpdateActiveEffect(float value, Vector3 position)
    {
        currentValue = value;
        transform.position = position;
    }

    //Run any needed code to update the object each FixedUpdate frame.
    public override void UpdatePooledObject()
    {
        //Decrement the value.
        currentValue -= Time.deltaTime * 10f;
        transform.localScale = Vector3.one * currentValue / 10f;

        //Return the object to its pool once value is less than 0.
        if (currentValue < 0)
        {
            ReturnToPool();
        }
    }
}
