52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
// Project Lab - NHTV Igad
|
|
|
|
#include "UnrealProject.h"
|
|
#include "poisonAuraTrigger.h"
|
|
#include "NetworkCharacter.h"
|
|
#include "NativeModifiers.h"
|
|
#include "Modifier.h"
|
|
|
|
|
|
|
|
ApoisonAuraTrigger::ApoisonAuraTrigger()
|
|
{
|
|
|
|
}
|
|
void ApoisonAuraTrigger::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
}
|
|
void ApoisonAuraTrigger::Tick(float deltaTime)
|
|
{
|
|
Super::Tick(deltaTime);
|
|
}
|
|
void ApoisonAuraTrigger::HitEvent(ANetworkCharacter* otherActor)
|
|
{
|
|
|
|
ModifierManager* manager = otherActor->GetModifierManager();
|
|
if (playerMap.Find(otherActor) == nullptr)
|
|
{
|
|
RERROR("2 modifiers in the intimidatin aura");
|
|
}
|
|
if (manager)
|
|
{
|
|
ADOTModifier* ASModifier = GetWorld()->SpawnActor<ADOTModifier>();
|
|
ASModifier->lifeTime = 0;
|
|
ASModifier->damagePerTick = damage;
|
|
ASModifier->target = otherActor;
|
|
manager->AddModifier(ASModifier);
|
|
playerMap.Add(otherActor, ASModifier);
|
|
|
|
}
|
|
return Super::HitEvent(otherActor);
|
|
}
|
|
void ApoisonAuraTrigger::LeaveEvent(ANetworkCharacter* otherActor)
|
|
{
|
|
|
|
auto it = playerMap.Find(otherActor);
|
|
if (it == nullptr)
|
|
return Super::LeaveEvent(otherActor);
|
|
(*it)->ForceDestroy();
|
|
playerMap.Remove(otherActor);
|
|
return Super::LeaveEvent(otherActor);
|
|
} |