using UnityEngine;

namespace pdinklag.CPW.Common
{
    public class Jumpable : MonoBehaviour
    {
        [Tooltip("The reference point for jumping over.")]
        public Transform JumpReferencePoint;

        [Tooltip("The reference point for navigation link generation.")]
        public Transform NavReferencePoint;

        [Tooltip("The jumpable width of the obstacle.")]
        public float JumpableWidth = 1.0f;

        [Tooltip("The thickness of the obstacle.")]
        public float Thickness = 0.25f;

#if UNITY_EDITOR
        private void OnDrawGizmos()
        {
            if (JumpReferencePoint)
            {
                Gizmos.color = Color.yellow;
                var start = JumpReferencePoint.position - 0.5f * JumpableWidth * JumpReferencePoint.right - 0.5f * Thickness * JumpReferencePoint.forward;
                var end = start + JumpableWidth * JumpReferencePoint.right;
                Gizmos.DrawLine(start, end);

                start += Thickness * JumpReferencePoint.forward;
                end += Thickness * JumpReferencePoint.forward;
                Gizmos.DrawLine(start, end);
            }

            if (NavReferencePoint)
            {
                var linkStart = NavReferencePoint.position - 2 * Thickness * NavReferencePoint.forward;
                var linkEnd = NavReferencePoint.position + 2 * Thickness * NavReferencePoint.forward;
                Gizmos.color = Color.green;
                Gizmos.DrawLine(linkStart, linkEnd);
            }
        }
#endif
    }
}
