From f4a27fa5fed6feade4479ad6312663e33b0f35e3 Mon Sep 17 00:00:00 2001 From: PHILIP White Date: Thu, 11 May 2023 05:13:19 +0100 Subject: [PATCH] Updated StatusSystem for One Status Effect of Each Type Can be Active --- .../TurnBasedCombatV2/StatusSystem.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp index 046bc5e..3d5bb9e 100644 --- a/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp +++ b/Source/the_twilight_abyss/TurnBasedCombatV2/StatusSystem.cpp @@ -40,6 +40,17 @@ void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCo void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float DurationMultiplier, const bool Invoke) { + for (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; + } + } FActiveStatusEffect NewStatusEffect; NewStatusEffect.StatusEffect = StatusEffect; NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());