using DG.Tweening;
using UnityEngine;

public class LoopingScale : MonoBehaviour
{
    [SerializeField] private float targetScale = 1.2f;
    [SerializeField] private float duration = 1.5f;

    private Tween scaleTween;
    private Vector3 originalScale;

    private void Awake()
    {
        originalScale = transform.localScale;
    }

    public void StartLoop()
    {
        if (scaleTween != null && scaleTween.IsActive())
            return;

        scaleTween = transform.DOScale(originalScale * targetScale, duration)
            .SetLoops(-1, LoopType.Yoyo)
            .SetEase(Ease.InOutSine)
            .SetUpdate(true);
    }

    public void StopLoop()
    {
        if (scaleTween != null)
        {
            scaleTween.Kill();
            scaleTween = null;
        }

        transform.localScale = originalScale;
    }
}