blaster/Source/Blaster/Pickups/HealthPickup.cpp

31 lines
843 B
C++
Raw Normal View History

2022-05-22 21:48:23 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "HealthPickup.h"
#include "Blaster/Character/BlasterCharacter.h"
2022-05-22 22:16:27 +00:00
#include "Blaster/Components/BuffComponent.h"
2022-05-22 21:48:23 +00:00
AHealthPickup::AHealthPickup()
{
bReplicates = true;
}
void AHealthPickup::OnSphereOverlap(UPrimitiveComponent* OverlappedComponent, AActor* OtherActor, UPrimitiveComponent* OtherComp, int32 OtherBodyIndex,
bool bFromSweep, const FHitResult& SweepResult)
{
Super::OnSphereOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult);
ABlasterCharacter* BlasterCharacter = Cast<ABlasterCharacter>(OtherActor);
if (BlasterCharacter)
{
2022-05-22 22:16:27 +00:00
UBuffComponent* Buff = BlasterCharacter->GetBuff();
if (Buff)
{
Buff->Heal(HealAmount, HealingTime);
}
2022-05-22 21:48:23 +00:00
}
Destroy();
}