using EscapeRoomEngine.Engine.Runtime.Modules.State;
using NaughtyAttributes;
using Station46.Scripts;
using UnityEngine;

namespace Station46.Modules.Laser.Scripts
{
    [RequireComponent(typeof(LaserReceiver))]
    public class LaserPuzzleSink : StatePuzzle
    {
        [BoxGroup("Internal")] [SerializeField] private Emission emission;
        
        protected override void Start()
        {
            base.Start();

            PuzzleEvent += (_, type) => emission.active = type == PuzzleEventType.Solved;

            GetComponent<LaserReceiver>().LaserEvent += (_, type) =>
            {
                if (type == LaserEventType.Hit)
                {
                    SetState(0, 1, true);
                }
            };
        }
    }
}