AzureAbyss/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/HealOverTime.cpp

31 lines
735 B
C++
Raw Normal View History

// 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();
}