using UnityEngine;
using UnityEngine.InputSystem;
using Unity.Cinemachine;

public class OrbitCameraMouseControl : MonoBehaviour
{
    [Header("Input Actions")]
    public InputActionReference aimAction; // CM Default / Aim

    [Header("Cinemachine Components")]
    public CinemachineInputAxisController inputAxisController;

    private bool aimingBlocked = false;

    private void OnEnable()
    {
        if (aimAction != null)
            aimAction.action.Enable();
    }

    private void OnDisable()
    {
        if (aimAction != null)
            aimAction.action.Disable();
    }

    void Update()
    {
        bool isAiming = aimAction != null && aimAction.action.ReadValue<float>() > 0.5f && !aimingBlocked;

        if (inputAxisController != null) // aimingBlocked wird durch hover States der Menü-Elemente gesetzt
        {
            inputAxisController.Controllers[0].Enabled = isAiming;
            inputAxisController.Controllers[1].Enabled = isAiming;
            inputAxisController.Controllers[2].Enabled = !aimingBlocked;
        }
    }

    public void SetBlocker(bool value)
    {
        aimingBlocked = value;
    }
}
