Bugfix Status Effects not Correctly Being Reset on Dupe
This commit is contained in:
parent
36834676e8
commit
4bba8fc1eb
@ -40,17 +40,19 @@ 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)
|
TArray<UStatusEffect*> ToExpire;
|
||||||
|
for (const FActiveStatusEffect& ActiveStatusEffect : ActiveStatusEffects)
|
||||||
{
|
{
|
||||||
if (ActiveStatusEffect.StatusEffect->Name == StatusEffect->Name)
|
if (ActiveStatusEffect.StatusEffect->Name == StatusEffect->Name)
|
||||||
{
|
{
|
||||||
ActiveStatusEffect.TimeTillExpiry = StatusEffect->BaseDuration * DurationMultiplier;
|
ToExpire.Add(ActiveStatusEffect.StatusEffect);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (UStatusEffect* StatusEffectToExpire : ToExpire)
|
||||||
|
{
|
||||||
|
StatusEffectToExpire->OnExpiry(GetOwner());
|
||||||
|
}
|
||||||
|
ToExpire.Empty();
|
||||||
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