44 lines
1.6 KiB
C#
44 lines
1.6 KiB
C#
using System.Collections.Generic;
|
|
using Core.Runtime;
|
|
using Quest.Runtime;
|
|
using Quests.Runtime;
|
|
using UnityEngine;
|
|
|
|
namespace Quests.Runtime._.Features.Quests
|
|
{
|
|
public class QuestInitializer : BaseMonobehaviour
|
|
{
|
|
void Awake()
|
|
{
|
|
var _ = QuestManager.Instance;
|
|
QuestManager.Instance.QuestDatabase = _questFactoryDatabase;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
if (!FactExists<List<QuestClass>>(SaveKeys.Active, out var _))
|
|
{
|
|
SetFact<List<QuestClass>>(SaveKeys.Active, new List<QuestClass>(), FactPersistence.Persistent);
|
|
}
|
|
QuestManager.Instance.ActiveQuests = GetFact<List<QuestClass>>(SaveKeys.Active);
|
|
if (!FactExists<List<QuestClass>>(SaveKeys.Completed, out var _))
|
|
{
|
|
SetFact<List<QuestClass>>(SaveKeys.Completed, new List<QuestClass>(), FactPersistence.Persistent);
|
|
}
|
|
QuestManager.Instance.CompletedQuests = GetFact<List<QuestClass>>(SaveKeys.Completed);
|
|
if (!FactExists<Dictionary<System.Guid, List<QuestEventLog>>>(SaveKeys.EventLogs, out var _))
|
|
{
|
|
SetFact<Dictionary<System.Guid, List<QuestEventLog>>>(SaveKeys.EventLogs, new Dictionary<System.Guid, List<QuestEventLog>>(), FactPersistence.Persistent);
|
|
}
|
|
Invoke(nameof(NotifyLater), 0.1f);
|
|
}
|
|
|
|
void NotifyLater()
|
|
{
|
|
QuestManager.Instance.NotifyCompletedQuests();
|
|
}
|
|
|
|
[SerializeField] QuestFactoryDatabase _questFactoryDatabase;
|
|
}
|
|
}
|
|
|