Updated StatusSystem for One Status Effect of Each Type Can be Active
This commit is contained in:
parent
aa2f1fabcb
commit
f4a27fa5fe
@ -40,6 +40,17 @@ void UStatusSystem::TickComponent(float DeltaTime, ELevelTick TickType, FActorCo
|
|||||||
|
|
||||||
void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float DurationMultiplier, const bool Invoke)
|
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<UTextBlock>(ActiveStatusEffect.StatusIcon->GetWidgetFromName(TEXT("DurationText")));
|
||||||
|
StatusText->SetText(FText::FromString(FString::FromInt(ActiveStatusEffect.TimeTillExpiry)));
|
||||||
|
if (Invoke) ActiveStatusEffect.StatusEffect->Invoke(GetOwner(), ActiveStatusEffect.TimeTillExpiry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
FActiveStatusEffect NewStatusEffect;
|
FActiveStatusEffect NewStatusEffect;
|
||||||
NewStatusEffect.StatusEffect = StatusEffect;
|
NewStatusEffect.StatusEffect = StatusEffect;
|
||||||
NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());
|
NewStatusEffect.TimeInitiated = UGameplayStatics::GetRealTimeSeconds(GetWorld());
|
||||||
|
Loading…
Reference in New Issue
Block a user