using System;
using Intrepid.Utilities;
using Unity.Collections;
using UnityEngine;

namespace Intrepid.Gameplay.Entities.Player.Sentinel
{
    [Serializable]
    [CreateAssetMenu(fileName = "Sentinel Controls", menuName = "GON/Services/Sentinel/Sentinel Controls")]
    public class SentinelControls : ScriptableObject
    {
        [GroupConfigurations, SerializeField, Range(0, 5)] private int dashBreakingThreshold = 3;
        [GroupConfigurations, SerializeField, Range(0, 10)] private int cadenceConnectedThreshold = 3;
        [GroupDebug, SerializeField, ReadOnly] private int cadenceConnectedCounter;
        [GroupDebug, SerializeField, ReadOnly] private int dashCounter;
        
        public int DashCounter => dashCounter;
        public int CadenceConnectedCounter => cadenceConnectedCounter;
        public bool ShouldDashBreak => DashCounter >= dashBreakingThreshold;
        public bool OnCadence => CadenceConnectedCounter > cadenceConnectedThreshold;
        public bool IsDashing => DashCounter > 0;

        public void Reset()
        {
            ResetDash();
            ExpireCadence();
        }

        public void DashCounterInc()
        {
            dashCounter++;
        }
        
        public void ResetDash()
        {
            dashCounter = 0;
        }
        
        public void CadenceConnectedCounterInc()
        {
            cadenceConnectedCounter++;
        }
        
        public void ExpireCadence()
        {
            cadenceConnectedCounter = 0;
        }
    }
}