-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestManager.cs
More file actions
32 lines (27 loc) · 1.05 KB
/
Copy pathQuestManager.cs
File metadata and controls
32 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections.Generic;
using Extensions.Patterns;
using Extensions.Singleton;
namespace QuestSystem
{
/**
* Manages quest objectives and their instances within the game. Persists across scene loads and
* provides methods to retrieve or create quest objective instances and check their completion status.
*/
public class QuestManager : LazySingleton<QuestManager>
{
private readonly Dictionary<QuestObjective, QuestObjectiveInstance> questInstances = new();
public QuestObjectiveInstance GetOrCreateInstance(QuestObjective objective)
{
if (!questInstances.TryGetValue(objective, out var instance))
{
instance = new QuestObjectiveInstance(objective);
questInstances[objective] = instance;
}
return instance;
}
public bool IsObjectiveComplete(QuestObjective objective, int times = 1)
{
return questInstances.TryGetValue(objective, out var state) && state.ConditionsMet(times);
}
}
}