using UnityEngine; using EasyTalk.Nodes; using System.Collections.Generic; [CreateAssetMenu(fileName = "New NPC Data", menuName = "RPG/NPC Data")] public class NPCData : ScriptableObject { [Header("Basic Info")] public string npcName = "NPC"; public string interactionText = "Press {E} to talk with {NPCName}"; [Header("Interaction Settings")] [Range(1f, 10f)] public float interactionRange = 2f; public bool canInteract = true; public InteractionType interactionType = InteractionType.NPC; [Header("Dialogue")] public Dialogue dialogue; [Header("Quest System")] public bool isQuestGiver = false; [SerializeField] private List questsToGive = new List(); public bool giveQuestsInOrder = true; public bool repeatQuests = false; [Header("Quest Dialogue")] public string noQuestDialogue; // When no quests are available public string questStartDialogue; // When offering a new quest public string questInProgressDialogue; // When player has active quest from this NPC public string questCompletedDialogue; // When player completes a quest public string questFailedDialogue; // When a quest has failed [Header("Optional Settings")] [TextArea(3, 5)] public string description = "A friendly NPC"; public bool isShopkeeper = false; // Runtime quest tracking [System.NonSerialized] public int currentQuestIndex = 0; // Method to validate the NPC data public bool IsValid() { return !string.IsNullOrEmpty(npcName) && dialogue != null; } // Quest management methods public List GetQuests() { return new List(questsToGive); } public void AddQuest(Quest quest) { if (quest != null && !questsToGive.Contains(quest)) { questsToGive.Add(quest); } } public void RemoveQuest(Quest quest) { questsToGive.Remove(quest); } /// /// Update interaction type based on NPC properties /// private void OnValidate() { // Automatically set interaction type based on NPC role if (isQuestGiver) { interactionType = InteractionType.Quest; } else if (isShopkeeper) { interactionType = InteractionType.Shop; } else if (interactionType == InteractionType.Quest && !isQuestGiver) { // Reset to default if no longer a quest giver interactionType = InteractionType.NPC; } } }