﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

namespace Arugula.Audio
{
    public abstract class PhonicUIHandlerBase : PhonicHandlerBase
    {
        [System.Flags]
        public enum InteractableFlags
        {
            Interactable = 0x1,
            NonInteractable = 0x2
        }

        public InteractableFlags interactableMask = InteractableFlags.Interactable;
        protected Selectable selectable;


        protected virtual void Start()
        {
            selectable = GetComponent<Selectable>();
        }

        public override void Play(string sound)
        {
            if (selectable != null)
            {
                //Debug.Log(gameObject.name + " : " + selectable.IsInteractable() + " : " + interactableMask);
                if (((int)(selectable.IsInteractable() ? InteractableFlags.Interactable : InteractableFlags.NonInteractable) & (int)interactableMask) > 0)
                {
                    base.Play(sound);
                    return;
                }
                else
                {
                    return;
                }

            }

            base.Play(sound);
        }
    }

}
