60 lines
1.7 KiB
C++
60 lines
1.7 KiB
C++
// Project Lab - NHTV Igad
|
|
|
|
#include "UnrealProject.h"
|
|
#include "IntimidatingAuraTrigger.h"
|
|
#include "NetworkCharacter.h"
|
|
#include "NativeModifiers.h"
|
|
#include "Modifier.h"
|
|
|
|
|
|
|
|
AIntimidatingAuraTrigger::AIntimidatingAuraTrigger()
|
|
{
|
|
|
|
}
|
|
void AIntimidatingAuraTrigger::BeginPlay()
|
|
{
|
|
Super::BeginPlay();
|
|
}
|
|
void AIntimidatingAuraTrigger::Tick(float deltaTime)
|
|
{
|
|
Super::Tick(deltaTime);
|
|
}
|
|
void AIntimidatingAuraTrigger::HitEvent(ANetworkCharacter* otherActor)
|
|
{
|
|
|
|
ModifierManager* manager = otherActor->GetModifierManager();
|
|
if (playerMap.Find(otherActor)== nullptr)
|
|
{
|
|
RERROR("2 modifiers in the intimidatin aura");
|
|
}
|
|
if (manager)
|
|
{
|
|
AAttackSpeedModifierConstant* ASModifier = GetWorld()->SpawnActor<AAttackSpeedModifierConstant>();
|
|
ASModifier->lifeTime = 0;
|
|
ASModifier->attackSpeedMultiplier = attackSpeedMultiplier;
|
|
ASModifier->target = otherActor;
|
|
manager->AddModifier(ASModifier);
|
|
|
|
ASpeedModifier* SModifier = GetWorld()->SpawnActor<ASpeedModifier>();
|
|
SModifier->lifeTime = 0;
|
|
SModifier->speedMultiplier = MovementSpeedMultiplier;
|
|
SModifier->target = otherActor;
|
|
manager->AddModifier(ASModifier);
|
|
// std::pair <AModifier*, AModifier*> pair = std::pair <AModifier*, AModifier*>((AModifier*)ASModifier, (AModifier*)SModifier);
|
|
playerMap.Add(otherActor, FIntimidatingAuraPair(ASModifier,SModifier));
|
|
|
|
}
|
|
return Super::HitEvent(otherActor);
|
|
}
|
|
void AIntimidatingAuraTrigger::LeaveEvent(ANetworkCharacter* otherActor)
|
|
{
|
|
|
|
auto it =playerMap.Find(otherActor);
|
|
if (it == nullptr)
|
|
return Super::LeaveEvent(otherActor);
|
|
it->modifier0->ForceDestroy();
|
|
it->modifier1->ForceDestroy();
|
|
playerMap.Remove(otherActor);
|
|
return Super::LeaveEvent(otherActor);
|
|
} |