31 lines
735 B
C++
31 lines
735 B
C++
|
// 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();
|
||
|
}
|