using RothenburgAR.Exhibition;
using UnityEngine;
using Vuforia;

namespace RothenburgAR.PointOfInterest
{
    public class PoiBehaviour : MonoBehaviour
    {
        public GameObject ImageContainer;

        public string ReferencedID { get; set; }
        public ExhibitBehaviour Exhibit { get; set; }
        public bool IsActive { get; private set; }

        public void Awake()
        {
            SetActive(false);
        }

        public bool IsTitlePoi
        {
            get { return GetComponent<Animator>().GetBool("IsTitlePoi"); }
            set { GetComponent<Animator>().SetBool("IsTitlePoi", value); }
        }

        public void SetActive(bool newIsActive)
        {
            IsActive = newIsActive;

            if (Exhibit != null && Exhibit.Tracker.CurrentStatus != TrackableBehaviour.Status.TRACKED )
                ImageContainer.GetComponent<MeshCollider>().enabled = false;
            else 
                ImageContainer.GetComponent<MeshCollider>().enabled = !newIsActive;

            GetComponent<Animator>().SetBool("FadeOut", newIsActive);
        }
    }
}