// Oleg Petruny proprietary.

#include "QuestManager.h"

#include "MainGameModeBase.h"
#include "Widgets/WidgetsManager.h"

void AQuestManager::BeginPlay()
{
    if(auto gamemode = AMainGameModeBase::Get())
        gamemode->questsUpdateDelegate.AddDynamic(this, &AQuestManager::Update);
}

void AQuestManager::EndPlay(const EEndPlayReason::Type EndPlayReason)
{
    if(auto gamemode = AMainGameModeBase::Get())
        gamemode->questsUpdateDelegate.RemoveDynamic(this, &AQuestManager::Update);
}

void AQuestManager::Update(TArray<FText> quests)
{
    if(auto WM = AMainGameModeBase::GetWidgetsManager())
        WM->UpdateJournal(quests);
}
