using Photon.Pun;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.InputSystem;

public class VoiceSetup : MonoBehaviourPun
{
    [Header("Made By ShadowApe Studios / Your Fellow Dummy")]
    [TextArea(3, 10)]
    public string readMe = "This is the voice setup script for if you, the developer, wantto have push-to-talk functionality in your game. By default, this script sets the Q and E keys as push-to-talk buttons. You can modify the Update() method to change which keys are used or add additional keys as needed.";
    private Recorder recorder;

    void Awake()
    {
        recorder = GetComponent<Recorder>();
    }

    void Start()
    {
        if (!photonView.IsMine)
        {
            recorder.enabled = false;
            return;
        }

        recorder.enabled = true;
        recorder.TransmitEnabled = false;
    }

    void Update()
    {
        if (!photonView.IsMine) return;
        if (Keyboard.current == null) return;

        recorder.TransmitEnabled =
            Keyboard.current.qKey.isPressed ||
            Keyboard.current.eKey.isPressed;
    }
}
