using System.Collections.Generic;
using Intrepid.Gameplay.Entities.Player.ActionBelt;
using Intrepid.Localization;
using Intrepid.Utilities;
using UnityEngine;

namespace Temporary
{
    [RequireComponent(typeof(MeshColorSetter))]
    public class SwitchActionCallable : ActionCallable
    {
        [GroupConfigurations, SerializeField] private LocalizationTag actionLocalizationOn;
        [GroupConfigurations, SerializeField] private LocalizationTag actionLocalizationOff;
        [GroupConfigurations, SerializeField] private LocalizationTag descriptionLocalization;
        
        private MeshColorSetter Setter { get; set; }
        private bool IsSwitchOn { get; set; } = true;
        
        protected override LocalizationTag ActionLocalization => IsSwitchOn ? actionLocalizationOff : actionLocalizationOn;
        protected override LocalizationTag DescriptionLocalization => descriptionLocalization;
        protected override List<string> Parameters => new();

        private void Awake()
        {
            Setter = GetComponent<MeshColorSetter>();
            IsSwitchOn = true;
            Setter.Color = Color.yellow;
        }

        protected override void Execute(ActionIdentifier identifier)
        {
            if (IsSwitchOn)
            {
                IsSwitchOn = false;
                Setter.Color = Color.black;
            }
            else
            {
                IsSwitchOn = true;
                Setter.Color = Color.yellow;
            }
        }
    }
}