using StarterAssets; using UnityEngine; using Yarn.Unity; namespace NightclubArcadia.Dialogue { /// /// Trigger-zone interactable: player walks in range, presses E, and this /// starts the given Yarn node. The reverse of DialogueTransitionController's /// <> — this is the "step into dialogue" half of the loop. /// public class DialogueInteractable : MonoBehaviour { [SerializeField] private DialogueRunner dialogueRunner; [SerializeField] private GameObject dialogueUI; [SerializeField] private GameObject playerArmature; [SerializeField] private string yarnNodeName = "Bartender_Chat"; private bool playerInRange = false; void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) playerInRange = true; } void OnTriggerExit(Collider other) { if (other.CompareTag("Player")) playerInRange = false; } void Update() { if (playerInRange && Input.GetKeyDown(KeyCode.E)) { StartConversation(); } } void StartConversation() { var playerController = playerArmature.GetComponent(); if (playerController != null) playerController.enabled = false; dialogueUI.SetActive(true); dialogueRunner.StartDialogue(yarnNodeName); } } }