AzureAbyss/Source/the_twilight_abyss/TurnBasedCombatV2/StatusEffects/HealOverTime.cpp
2023-04-27 17:59:06 +01:00

31 lines
807 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, float TimeOfExpiry)
{
Super::Invoke(Character, TimeOfExpiry);
GetWorld()->GetTimerManager().SetTimer(HealTimerHandle, [this, Character] { Heal(Character, HealAmount); }, 1, true, 0);
}
void UHealOverTime::OnExpiry(AActor* Character)
{
GetWorld()->GetTimerManager().ClearTimer(HealTimerHandle);
Super::OnExpiry(Character);
}