using UnityEngine;
using System;
using System.Collections.Generic;
using mgaia.Utils;

namespace mgaia.tk2d
{
    /// <summary>
    /// Extensões para facilitar o trabalho com tk2dSpriteAnimator
    /// </summary>
    /// <owner>Victor</owner>
    public static class Tk2dSpriteAnimatorExtensions
    {
        /// <summary>
        /// Retorna o bounds do frame atual de um animator
        /// </summary>
        public static Bounds GetBoundsOfCurrentFrame(this tk2dSpriteAnimator animator, bool scaleForAtualScale = true)
        {
            tk2dSpriteAnimationClip clip = animator.CurrentClip;

            tk2dSpriteAnimationFrame frame = clip.frames[animator.CurrentFrame];

            tk2dSpriteCollectionData collection = frame.spriteCollection;

            tk2dSpriteDefinition definition = collection.spriteDefinitions[frame.spriteId];

            Bounds bounds = definition.GetBounds();

            if (scaleForAtualScale)
            {
                bounds = bounds.Multiply(animator.Sprite.scale);
            }

            return bounds;
        }
    }
}