From 4bba8fc1eb9eaad2d9bc4d671ad75663bf387bbc Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Mon, 22 May 2023 16:44:06 +0100 Subject: [PATCH] Bugfix Status Effects not Correctly Being Reset on Dupe --- .../TurnBasedCombatV2/StatusSystem.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp index 3d5bb9e..2043fe7 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp @@ -40,17 +40,19 @@ void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCo void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float DurationMultiplier, const bool Invoke) { - for (FActiveStatusEffect ActiveStatusEffect : ActiveStatusEffects) + TArray ToExpire; + for (const FActiveStatusEffect& ActiveStatusEffect : ActiveStatusEffects) { if (ActiveStatusEffect.StatusEffect->Name == StatusEffect->Name) { - ActiveStatusEffect.TimeTillExpiry = StatusEffect->BaseDuration * DurationMultiplier; - UTextBlock* StatusText = Cast(ActiveStatusEffect.StatusIcon->GetWidgetFromName(TEXT("DurationText"))); - StatusText->SetText(FText::FromString(FString::FromInt(ActiveStatusEffect.TimeTillExpiry))); - if (Invoke) ActiveStatusEffect.StatusEffect->Invoke(GetOwner(), ActiveStatusEffect.TimeTillExpiry); - return; + ToExpire.Add(ActiveStatusEffect.StatusEffect); } } + for (UStatusEffect* StatusEffectToExpire : ToExpire) + { + StatusEffectToExpire->OnExpiry(GetOwner()); + } + ToExpire.Empty(); FActiveStatusEffect NewStatusEffect; NewStatusEffect.StatusEffect = StatusEffect; NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());