using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;

namespace PlayerInput
{
    public abstract class InputSource<TTarget> where TTarget : MonoBehaviour
    {
        public enum InputButton
        {
            MenuSelect,
            MenuCancel,
        }

        public enum InputAxis
        {
            MoveX,
            MoveY,

            MenuX,
            MenuY,

            RakeX,
            RakeY,
        }

        public abstract bool ButtonPressedThisFrame(InputButton button);
        public abstract bool ButtonReleasedThisFrame(InputButton button);
        public abstract bool ButtonDown(InputButton button);

        public abstract float Axis(InputAxis axis);

        // TODO old
        //private SimpleTimer vibrateTimer = new SimpleTimer();
        public void Vibrate(float time, float left, float right)
        {
            /*
            vibrateTimer.Stop();
            VibrateInternal(left, right);            
            vibrateTimer.Start(time, () => VibrateInternal(0, 0));
            */
        }

        private TTarget target;
        public TTarget Target { get { return target; } }
        public void SetTarget(TTarget target)
        {
            if (this.target != target)
            {
                this.target = target;
                TargetUpdated(target);
            }
        }

        protected virtual void TargetUpdated(TTarget target)
        {

        }

        protected virtual void VibrateInternal(float left, float right)
        {

        }
    }
}
