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());