This commit is contained in:
Rowland Rowland 2023-05-11 11:36:10 +01:00
commit 2ef306a49c

View File

@ -54,12 +54,13 @@ void UQuestSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCom
void UQuestSystem::CheckActiveQuestConditions() void UQuestSystem::CheckActiveQuestConditions()
{ {
TArray<UQuest*> JustCompletedQuests;
for (UQuest* Quest : ActiveQuests) for (UQuest* Quest : ActiveQuests)
{ {
if (Quest->CheckConditions(GetWorldState())) if (Quest->CheckConditions(GetWorldState()))
{ {
CompletedQuests.Add(Quest); CompletedQuests.Add(Quest);
Quest->ApplyRewards(PlayerInventory); JustCompletedQuests.Add(Quest);
for (TTuple<FString, bool> QuestFlag : Quest->QuestFlagsOnComplete) for (TTuple<FString, bool> QuestFlag : Quest->QuestFlagsOnComplete)
{ {
QuestFlags.Add(QuestFlag.Key, QuestFlag.Value); QuestFlags.Add(QuestFlag.Key, QuestFlag.Value);
@ -79,6 +80,11 @@ void UQuestSystem::CheckActiveQuestConditions()
} }
UpdateQuestGoalsUI(Quest); UpdateQuestGoalsUI(Quest);
} }
for (UQuest* Quest : JustCompletedQuests)
{
ActiveQuests.Remove(Quest);
Quest->ApplyRewards(PlayerInventory);
}
} }
UWorldState* UQuestSystem::GetWorldState() const UWorldState* UQuestSystem::GetWorldState() const