using UnityEngine;
using UnityEngine.InputSystem;

public class InGameUIManager : BaseUIManager
{
    public UserHealthUI UserHealth;
    public InteractionUI Interaction;
    public SplitWindowUI SplitWindow;
    public TooltipUI Tooltip;
    public Transform DragCanvas;
    public GameObject InventoryRoot;

    [SerializeField] private GameObject _crosshairRoot;

    public void VisibleCrossHair(bool isOn)
    {
        _crosshairRoot.SetActive(isOn);
    }

    public void InteractionVisible(bool isOn)
    {
        Interaction.gameObject.SetActive(isOn);
    }

    public SplitWindowUI GetSplitWindowUI()
    {
        return SplitWindow;
    }

    public void InventoryToggle()
    {
        InventoryOnOff(!InventoryRoot.activeSelf);
    }

    public void InventoryOnOff(bool isOn)
    {
        InventoryRoot.SetActive(isOn);

        if (isOn)
        {
            // UI 조작 모드로 변경 (캐릭터 이동 입력 차단)
            InputManager.Instance.ActiveOnlyOneActionMap("InGameUI");

            // 커서 자유롭게 풀기
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible = true;
        }
        else
        {
            // 플레이어 모드로 복귀
            InputManager.Instance.ActiveOnlyOneActionMap("Character");

            // 커서 중앙 고정 및 숨김
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible = false;
        }
    }
}
