using System;
using Intrepid.Integration.Input;
using UnityEngine;

namespace Intrepid.Gameplay.Entities.Player.Sentinel.Inputs
{
    public class SentinelInputActions : SentinelInputs
    {
        public Func<bool> Dash { get; set; }
        
        public Func<Vector2> Movement { get; set; }
        public Func<bool> Interact { get; set; }
        public Func<bool> DPadLeft { get; set; }
        public Func<bool> DPadRight { get; set; }
        public Func<bool> EnterPDA { get; set; }
        
        public Func<bool> Reset { get; set; }
        
        public static SentinelInputActions BuildSentinelInputActions()
        {
            var locking = InputService.Instance.Locking;
            var inputActions = InputService.Instance.InputActions.sentinel;
            return new SentinelInputActions
            {
                Dash = () => locking.IsNotLocked && inputActions.Dash.WasPressedThisFrame(),
                
                Movement = () => locking.IsNotLocked
                    ? inputActions.Movement.ReadValue<Vector2>()
                    : Vector2.zero,
                Interact = () => locking.IsNotLocked && inputActions.Interact.WasPressedThisFrame(),
                DPadLeft = () => locking.IsNotLocked && inputActions.DPadLeft.WasPressedThisFrame(),
                DPadRight = () => locking.IsNotLocked && inputActions.DPadRight.WasPressedThisFrame(),
                EnterPDA = () => locking.IsNotLocked && inputActions.EnterPDA.WasPressedThisFrame(),
                
                // debug
                Reset = () => locking.IsNotLocked && inputActions.Reset.WasPressedThisFrame(),
            };
        }
    }
}