using UnityEngine;

public class BrotherBlueView : MonoBehaviour
{
    [SerializeField] private Animator animator;
    private static readonly int Sell = Animator.StringToHash("Sell");
    private static readonly int Open = Animator.StringToHash("Open");
    private static readonly int CleaningA = Animator.StringToHash("CleaningA");
    private static readonly int CleaningB = Animator.StringToHash("CleaningB");
    private static readonly int MoveSideways = Animator.StringToHash("MoveSideways");
    private static readonly int[] CloseTriggerArray = {CleaningA, CleaningB, MoveSideways};
    private Vector3 initScale;

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

    public void SellAction()
    {
        animator.SetTrigger(Sell);
    }

    public void OpenAction()
    {
        animator.SetTrigger(Open);
    }

    public void CloseAction()
    {
        animator.SetTrigger(CloseTriggerArray.RandomChoose());
    }

    public void SetActive(bool active)
    {
        animator.speed = active ? 1f : 0f;
        animator.transform.localScale = active ? initScale : Vector3.zero;
    }
}
