using NBC;

namespace NBF
{
    /// <summary>
    /// 闲置中
    /// </summary>
    public class PlayerStateIdle : PlayerStateBase
    {
        public override uint StateId => (uint)PlayerState.Idle;
        private bool _nextState = false;

        protected override void onEnter()
        {
            Log.Info("enter PlayerStateIdle");
            _nextState = false;
            InputManager.OnOp1Action += OnOp1Action;
        }

        private void OnOp1Action(bool performed)
        {
            if (!Player.Rod) return;
            if (performed)
            {
                _nextState = true;
            }
        }

        protected override void onExit()
        {
            InputManager.OnOp1Action -= OnOp1Action;
        }

        protected override uint onUpdate()
        {
            if (_nextState)
            {
                return (uint)PlayerState.Prepare;
            }

            return States.None;
        }
    }
}