first commit
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
using OTGIntegrated.Player;
|
||||
using OTGIntegrated.Quests;
|
||||
using UnityEngine;
|
||||
|
||||
namespace OTGIntegrated.Dialogue
|
||||
{
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public sealed class NPCInteract : MonoBehaviour, IInteractable
|
||||
{
|
||||
public string npcId;
|
||||
public string displayName = "NPC";
|
||||
public DialogueNode startNode;
|
||||
public QuestData offeredQuest;
|
||||
public QuestData completionQuest;
|
||||
public bool canOpenCrafting;
|
||||
|
||||
private DialogueManager dialogueManager;
|
||||
|
||||
public Transform InteractTransform => transform;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Collider ownCollider = GetComponent<Collider>();
|
||||
ownCollider.isTrigger = true;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
dialogueManager = FindObjectOfType<DialogueManager>();
|
||||
}
|
||||
|
||||
public string GetPrompt()
|
||||
{
|
||||
return $"E — поговорить: {displayName}";
|
||||
}
|
||||
|
||||
public bool CanInteract(GameObject interactor)
|
||||
{
|
||||
return startNode != null && dialogueManager != null;
|
||||
}
|
||||
|
||||
public void Interact(GameObject interactor)
|
||||
{
|
||||
if (dialogueManager != null)
|
||||
{
|
||||
dialogueManager.StartDialogue(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user