RealtimeStyleTransferRuntime/Source/LyraGame/Feedback/NumberPops/LyraNumberPopComponent_Niag...

64 lines
2.1 KiB
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraNumberPopComponent_NiagaraText.h"
2022-09-13 07:18:28 +00:00
#include "Containers/UnrealString.h"
#include "Feedback/NumberPops/LyraNumberPopComponent.h"
#include "GameFramework/Actor.h"
#include "Logging/LogCategory.h"
#include "Logging/LogMacros.h"
2022-05-23 18:41:30 +00:00
#include "LyraDamagePopStyleNiagara.h"
#include "LyraLogChannels.h"
2022-09-13 07:18:28 +00:00
#include "Math/UnrealMathSSE.h"
#include "Math/Vector.h"
#include "Math/Vector4.h"
#include "Misc/AssertionMacros.h"
#include "NiagaraComponent.h"
#include "NiagaraDataInterfaceArrayFunctionLibrary.h"
#include "Trace/Detail/Channel.h"
#include "UObject/ObjectPtr.h"
2022-05-23 18:41:30 +00:00
ULyraNumberPopComponent_NiagaraText::ULyraNumberPopComponent_NiagaraText(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
}
void ULyraNumberPopComponent_NiagaraText::AddNumberPop(const FLyraNumberPopRequest& NewRequest)
{
int32 LocalDamage = NewRequest.NumberToDisplay;
//Change Damage to negative to differentiate Critial vs Normal hit
if (NewRequest.bIsCriticalDamage)
{
LocalDamage *= -1;
}
//Add a NiagaraComponent if we don't already have one
if (!NiagaraComp)
{
NiagaraComp = NewObject<UNiagaraComponent>(GetOwner());
if (Style != nullptr)
{
NiagaraComp->SetAsset(Style->TextNiagara);
NiagaraComp->bAutoActivate = false;
}
NiagaraComp->SetupAttachment(nullptr);
check(NiagaraComp);
NiagaraComp->RegisterComponent();
}
NiagaraComp->Activate(false);
NiagaraComp->SetWorldLocation(NewRequest.WorldLocation);
UE_LOG(LogLyra, Log, TEXT("DamageHit location : %s"), *(NewRequest.WorldLocation.ToString()));
//Add Damage information to the current Niagara list - Damage informations are packed inside a FVector4 where XYZ = Position, W = Damage
TArray<FVector4> DamageList = UNiagaraDataInterfaceArrayFunctionLibrary::GetNiagaraArrayVector4(NiagaraComp, Style->NiagaraArrayName);
DamageList.Add(FVector4(NewRequest.WorldLocation.X, NewRequest.WorldLocation.Y, NewRequest.WorldLocation.Z, LocalDamage));
UNiagaraDataInterfaceArrayFunctionLibrary::SetNiagaraArrayVector4(NiagaraComp, Style->NiagaraArrayName, DamageList);
}