using EscapeRoomEngine.Engine.Runtime.Modules;
using UnityEngine;

namespace EscapeRoomEngine.Desert.Runtime.Portal
{
    /// <summary>
    /// The desert theme includes its own version of a portal that changes colour when it is unlocked.
    /// </summary>
    [RequireComponent(typeof(Emission))]
    public class DesertPortal : EscapeRoomEngine.Portal.Runtime.Portal
    {
        private Emission _emission;

        protected override void Awake()
        {
            base.Awake();
            
            _emission = GetComponent<Emission>();
            
            DoorEvent += (_, type) =>
            {
                // ReSharper disable once SwitchStatementMissingSomeEnumCasesNoDefault ConvertSwitchStatementToSwitchExpression
                switch (type)
                {
                    case DoorEventType.Unlocked:
                        _emission.color = Engine.Runtime.Engine.Theme.solvedColor.hdr;
                        break;
                    case DoorEventType.Locked:
                        _emission.color = Engine.Runtime.Engine.Theme.puzzleColor.hdr;
                        break;
                }
            };

            _emission.active = true;
        }
    }
}