using Godot; using System; using System.Linq; using Babushka.scripts.CSharp.Common.Quest; /// /// Acts as a base for scripts to check for conditions to complete quests. /// /// The derived Class is responsible for triggering the Check. /// It is recommended to always check on QuestManager.Instance!.QuestsChanged /// public abstract partial class QuestFulfillmentBase : Node { [Export] private QuestResource _onAvailableQuest = null!; [Export] private QuestResource _toNextQuest = null!; [Export] private bool _whenFulfilledSetAvailableQuestToDone = true; [Export] private bool _whenFulfilledSetNextQuestToAvailable = true; [Export] private bool _whenFulfilledSetNextQuestToActive = true; [Signal] private delegate void OnFulfilledEventHandler(); protected void Fulfill() { if (_whenFulfilledSetAvailableQuestToDone) { QuestManager.Instance!.ChangeQuestStatus(_onAvailableQuest, QuestStatus.Status.Done); } if (_whenFulfilledSetNextQuestToAvailable) { QuestManager.Instance!.ChangeQuestStatus(_toNextQuest, QuestStatus.Status.Available); } if (_whenFulfilledSetNextQuestToActive) { QuestManager.Instance!.SetActiveQuest(_toNextQuest); } EmitSignalOnFulfilled(); } protected bool IsQuestActive() { return QuestManager.Instance!.GetAvailableQuests().Any(q => q.Key == _onAvailableQuest); } }