/// <summary>
        /// Get the status of the button given. If the buffer is being checked,
        /// the button returned will be from when it was first pressed within the window, if it exist.
        /// Otherwise, the button at the offset is given.
        /// </summary>
        /// <param name="buttonID">The ID of the button to get.</param>
        /// <param name="frameOffset">The offset from the current frame to check.</param>
        /// <param name="checkBuffer">If the buffer should be checked.</param>
        /// <param name="bufferFrames">How many frames to check for buffer.</param>
        /// <returns>The button and the information about it on the frame.</returns>
        public virtual InputRecordButton GetButton(int buttonID, out int gotOffset, int frameOffset = 0, bool checkBuffer = false, int bufferFrames = 3)
        {
            gotOffset = 0;
            if (InputRecord.Count == 0)
            {
                return(new InputRecordButton());
            }

            if (checkBuffer && (InputRecord.Count - 1) >= (frameOffset + bufferFrames))
            {
                for (int i = 0; i < bufferFrames; i++)
                {
                    InputRecordButton b = ((InputRecordButton)InputRecord[(InputRecord.Count - 1) - (frameOffset + bufferFrames)].inputs[buttonID]);
                    //Can't go further, already used buffer past here.
                    if (b.usedInBuffer)
                    {
                        break;
                    }
                    if (b.firstPress)
                    {
                        gotOffset = i;
                        return(b);
                    }
                }
            }
            return((InputRecordButton)InputRecord[(InputRecord.Count - 1) - frameOffset].inputs[buttonID]);
        }
        public void Process(InputRecordInput lastInput)
        {
            InputRecordButton lsb = (InputRecordButton)lastInput;

            if (isDown && !lsb.isDown)
            {
                firstPress = true;
            }
            else if (!isDown && lsb.isDown)
            {
                released = true;
            }
        }
        /// <summary>
        /// Handles finding and locking on to targets.
        /// </summary>
        protected override void HandleLockon()
        {
            InputRecordButton lockonButton = InputManager.GetButton((int)EntityInputs.Lockon);

            LockedOn = false;
            if (lockonButton.released)
            {
                lookHandler.SetLockOnTarget(null);
            }
            if (!lockonButton.isDown)
            {
                return;
            }
            LockedOn = true;

            if (lockonButton.firstPress)
            {
                PickLockonTarget();
                // No target but holding down lock on menas you lock the visuals rotation.
                LockonForward = visual.transform.forward;
                lookHandler.SetLockOnTarget(LockonTarget?.GetComponent <EntityManager>());
            }

            // No target.
            if (LockonTarget == null)
            {
                return;
            }

            // Target out of range.
            if (Vector3.Distance(transform.position, LockonTarget.transform.position) > lockonRadius)
            {
                LockonTarget = null;
                lookHandler.SetLockOnTarget(null);
                return;
            }

            // We have a target and they're in range, set our wanted forward direction.
            Vector3 dir = (LockonTarget.transform.position - transform.position);

            dir.y         = 0;
            LockonForward = dir.normalized;
        }