You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
using Godot;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace Babushka.scripts.CSharp.Common.Quest;
|
|
|
|
using QuestPair = KeyValuePair<QuestResource, QuestStatus>;
|
|
public partial class QuestManager : Node
|
|
{
|
|
public static QuestManager Instance { get; private set; }
|
|
|
|
public override void _EnterTree()
|
|
{
|
|
Instance = this;
|
|
}
|
|
|
|
private Godot.Collections.Dictionary<QuestResource, QuestStatus> _questStatus = new();
|
|
|
|
|
|
public void ChangeQuestStatus(QuestResource questResource, QuestStatus.Status newStatus)
|
|
{
|
|
if (!_questStatus.TryGetValue(questResource, out var value))
|
|
{
|
|
value = new QuestStatus();
|
|
_questStatus.Add(questResource, value);
|
|
}
|
|
|
|
value.status = newStatus;
|
|
}
|
|
|
|
public IEnumerable<QuestPair> GetVisibleQuests()
|
|
{
|
|
return _questStatus.Where(qs => qs.Value.status != QuestStatus.Status.Hidden);
|
|
}
|
|
|
|
public IEnumerable<QuestPair> GetActiveQuests()
|
|
{
|
|
return _questStatus.Where(qs => qs.Value.status == QuestStatus.Status.Active);
|
|
}
|
|
}
|