Files
Babushka/scripts/CSharp/Common/Quest/QuestTrigger.cs
T

31 lines
824 B
C#
Raw Normal View History

2025-07-07 04:40:40 +02:00
using Godot;
using System;
using Babushka.scripts.CSharp.Common.Quest;
public partial class QuestTrigger : Node
{
2025-08-14 21:54:18 +02:00
[Export] public QuestResource? questResource;
2025-07-07 04:40:40 +02:00
2025-08-14 21:54:18 +02:00
[Export] public QuestStatus.Status toStatus;
2025-07-07 04:40:40 +02:00
2025-08-14 21:54:18 +02:00
[Export] private bool makeActive = false;
2025-07-07 04:41:03 +02:00
2025-07-07 04:40:40 +02:00
public void Trigger()
{
2025-07-07 04:41:03 +02:00
GD.Print("trigger");
2025-08-14 21:54:18 +02:00
if (questResource == null)
2025-07-07 04:41:03 +02:00
throw new Exception("QuestResource is not set on QuestTrigger node.");
2025-08-14 21:54:18 +02:00
if (QuestManager.Instance == null)
throw new Exception(
"QuestManager instance is not available. Make sure it is initialized before calling Trigger.");
2025-07-07 04:40:40 +02:00
QuestManager.Instance.ChangeQuestStatus(questResource, toStatus);
2025-08-14 21:54:18 +02:00
if (makeActive)
2025-07-07 04:41:03 +02:00
{
2025-08-14 21:54:18 +02:00
QuestManager.Instance.SetActiveQuest(questResource);
2025-07-07 04:41:03 +02:00
}
2025-07-07 04:40:40 +02:00
}
2025-08-14 21:54:18 +02:00
}