51 lines
1.3 KiB
C#
51 lines
1.3 KiB
C#
|
|
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);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|