Added HealOverTime Status Effect for Testing
This commit is contained in:
parent
adba724dba
commit
37deb51b5f
@ -9,7 +9,7 @@
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
UCLASS(Abstract)
|
UCLASS(Abstract, Blueprintable)
|
||||||
class THE_TWILIGHT_ABYSS_API UStatusEffect : public UObject
|
class THE_TWILIGHT_ABYSS_API UStatusEffect : public UObject
|
||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
|
||||||
|
#include "HealOverTime.h"
|
||||||
|
|
||||||
|
#include "the_twilight_abyss/PlayerTemp/TempCharacter.h"
|
||||||
|
|
||||||
|
void UHealOverTime::Heal(AActor* Character, const float Amount) const
|
||||||
|
{
|
||||||
|
if (ATempCharacter* CastedCharacter = Cast<ATempCharacter>(Character); CastedCharacter->Health < 100)
|
||||||
|
{
|
||||||
|
CastedCharacter->Health += Amount;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CastedCharacter->Health = 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void UHealOverTime::Invoke(AActor* Character)
|
||||||
|
{
|
||||||
|
Super::Invoke(Character);
|
||||||
|
GetWorld()->GetTimerManager().SetTimer(HealTimerHandle, [Character, this] { Heal(Character, 1); }, 1, true, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UHealOverTime::OnExpiry(AActor* Character)
|
||||||
|
{
|
||||||
|
Super::OnExpiry(Character);
|
||||||
|
HealTimerHandle.Invalidate();
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "../StatusEffect.h"
|
||||||
|
#include "HealOverTime.generated.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
UCLASS()
|
||||||
|
class THE_TWILIGHT_ABYSS_API UHealOverTime : public UStatusEffect
|
||||||
|
{
|
||||||
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UFUNCTION()
|
||||||
|
void Heal(AActor* Character, float Amount) const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FTimerHandle HealTimerHandle;
|
||||||
|
virtual void Invoke(AActor* Character) override;
|
||||||
|
virtual void OnExpiry(AActor* Character) override;
|
||||||
|
};
|
@ -61,6 +61,7 @@ void UStatusSystem::AddStatusEffect(UStatusEffect* StatusEffect, const float Dur
|
|||||||
UImage* StatusIconImage = Cast<UImage>(NewStatusEffect.StatusIcon->GetWidgetFromName(TEXT("StatusIconImage")));
|
UImage* StatusIconImage = Cast<UImage>(NewStatusEffect.StatusIcon->GetWidgetFromName(TEXT("StatusIconImage")));
|
||||||
StatusIconImage->SetBrushFromTexture(StatusEffect->Icon);
|
StatusIconImage->SetBrushFromTexture(StatusEffect->Icon);
|
||||||
StatusIconsBox->AddChild(NewStatusEffect.StatusIcon);
|
StatusIconsBox->AddChild(NewStatusEffect.StatusIcon);
|
||||||
|
NewStatusEffect.StatusEffect->Invoke(GetOwner());
|
||||||
|
|
||||||
ActiveStatusEffects.Add(NewStatusEffect);
|
ActiveStatusEffects.Add(NewStatusEffect);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user