using Net.Eagle0.Eagle.Views;
using TMPro;
using UnityEngine.UI;

namespace eagle {
    public class UnitSelectorHeroRowController : TableRowController, System.IDisposable {
        public RawImage professionImage;
        public RawImage archeryImage;
        public RawImage fireImage;
        public TMP_Text heroNameLabel;

        private DynamicHeroTextUpdater textUpdater = new DynamicHeroTextUpdater();

        public HeroView Hero {
            set {
                professionImage.texture =
                        gameObject.GetComponentInParent<EagleCommonTextures>().Profession(
                                value.Profession);
                textUpdater.SetHeroText(heroNameLabel, value.NameTextId, "Hero");
                archeryImage.gameObject.SetActive(value.ArcheryCapable);
                fireImage.gameObject.SetActive(value.StartFireCapable);
                professionImage.gameObject.SetActive(professionImage.texture != null);
            }
        }

        public void Dispose() { textUpdater?.Dispose(); }

        private void OnDestroy() { Dispose(); }
    }
}