using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;

public class GameManager : MonoBehaviour
{
    [Header("UI do ukrycia")]
    public GameObject startCanvas;

    [Header("Komponenty gracza")]
    public PlayerMove movementScript;
    public MouseLook lookScript;

    // public MqttCollector mqttScript; // Odkomentujesz to później

    private bool hasStarted = false;

    void Start()
    {
        // Blokada na starcie
        if (movementScript != null) movementScript.enabled = false;
        if (lookScript != null) lookScript.canLook = false;

        Cursor.lockState = CursorLockMode.None;
        Cursor.visible = true;

        // Czekamy na dowolny klawisz
        InputSystem.onAnyButtonPress.CallOnce(ctrl => Begin());
    }

    void Begin()
    {
        if (hasStarted) return;
        hasStarted = true;

        if (startCanvas != null) startCanvas.SetActive(false);
        if (movementScript != null) movementScript.enabled = true;
        if (lookScript != null) lookScript.EnableLooking();

        // if (mqttScript != null) mqttScript.BeginSession();
        Debug.Log("Gra wystartowała!");
    }
}