using System;
using Intrepid.Gameplay.Codex.Visual;
using Intrepid.Utilities;
using Intrepid.Utilities.Sprite;
using UnityEngine;
using UnityEngine.UI;

namespace Intrepid.Gameplay.Codex.UI.Components
{
    public class CodexIconComponentUI : CodexComponentUI
    {
        [GroupInjections, SerializeField] private Image icon;
        [GroupInjections, SerializeField] private SpriteAnimationController iconAnimation;

        private void Awake()
        {
            iconAnimation.PostProcessingUpdateSprite = sprite =>
            {
                if (sprite.IsNull()) return;
                icon.sprite = sprite;
            };
        }
        
        public void ChangeAnimation(string animationId)
        {
            iconAnimation.ChangeAnimation(animationId);
        }
        
        public void AnimationReset()
        {
            iconAnimation.SpriteAnimation.Reset();
        }

        public override void ApplyCodexVisuals(CodexVisualContext ctx)
        {
        }
    }
}