using UnityEngine;

public class FaceoffDebugVisualizer : MonoBehaviour
{
    [SerializeField] private FaceoffManager faceoffManager;
    [SerializeField] private bool showDebug = true;

    private Vector3 lastPassStart;
    private Vector3 lastPassEnd;
    private float debugTimer = 0f;

    void Update()
    {
        if (debugTimer > 0)
        {
            debugTimer -= Time.deltaTime;
        }
    }

    void OnDrawGizmos()
    {
        if (!showDebug || debugTimer <= 0) return;

        // Draw pass line
        Gizmos.color = Color.cyan;
        Gizmos.DrawLine(lastPassStart, lastPassEnd);
        Gizmos.DrawSphere(lastPassStart, 0.2f);
        Gizmos.DrawSphere(lastPassEnd, 0.2f);

        // Draw arrow
        Vector3 direction = (lastPassEnd - lastPassStart).normalized;
        Vector3 arrowPoint = lastPassStart + direction * Vector3.Distance(lastPassStart, lastPassEnd) * 0.5f;
        Gizmos.DrawLine(arrowPoint, arrowPoint + Quaternion.Euler(0, -30, 0) * -direction * 0.5f);
        Gizmos.DrawLine(arrowPoint, arrowPoint + Quaternion.Euler(0, 30, 0) * -direction * 0.5f);
    }

    public void DrawPass(Vector3 start, Vector3 end, float duration = 3f)
    {
        lastPassStart = start;
        lastPassEnd = end;
        debugTimer = duration;
    }
}