using System; using System.Collections.Generic; using UnityEngine; // DialogGroup 하나가 활성화되기 위한 조건 묶음. 모든 항목을 만족해야 한다(AND). // 값이 0이거나 목록이 비어있으면 그 항목은 조건 없음으로 통과된다. [Serializable] public class DialogCondition { [Tooltip("메인 진행도가 이 값 이상이어야 함 (0 = 조건 없음)")] [Min(0)] public int MinMainProgress; [Tooltip("이 NPC의 호감도가 이 값 이상이어야 함 (0 = 조건 없음)")] [Min(0)] public int MinAffection; [Tooltip("먼저 완료했어야 하는 대화들 (전부 완료 필요)")] public List RequiredDialogs = new(); [Tooltip("골랐어야 하는 선택지 Code들 (전부 필요)")] public List RequiredChoiceCodes = new(); [Tooltip("밟았어야 하는 이벤트존 Id들 (전부 필요)")] public List RequiredZoneIds = new(); // affectionTarget: 호감도 조건을 검사할 캐릭터 (보통 대화를 거는 NPC 자신) public bool IsMet(CharacterData affectionTarget) { var story = StoryManager.Instance; if (story.MainProgress < MinMainProgress) return false; if (MinAffection > 0 && story.GetAffection(affectionTarget) < MinAffection) return false; foreach (var group in RequiredDialogs) if (group != null && !story.IsDialogCompleted(group.name)) return false; foreach (var code in RequiredChoiceCodes) if (!string.IsNullOrEmpty(code) && !story.HasChosen(code)) return false; foreach (var zoneId in RequiredZoneIds) if (!string.IsNullOrEmpty(zoneId) && !story.HasTriggeredZone(zoneId)) return false; return true; } }