Bugfix Stack Overflow on Adding Reward Items
This commit is contained in:
parent
902163d4fe
commit
067bb41820
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user