2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
2022-09-13 07:18:28 +00:00
# include "Containers/Array.h"
# include "Containers/Map.h"
# include "Engine/EngineTypes.h"
2022-05-23 18:41:30 +00:00
# include "LyraNumberPopComponent.h"
2022-09-13 07:18:28 +00:00
# include "Math/Color.h"
# include "Math/Transform.h"
# include "Math/UnrealMathSSE.h"
# include "UObject/NameTypes.h"
# include "UObject/UObjectGlobals.h"
2022-05-23 18:41:30 +00:00
# include "LyraNumberPopComponent_MeshText.generated.h"
class ULyraDamagePopStyle ;
2022-09-13 07:18:28 +00:00
class UMaterialInstanceDynamic ;
class UObject ;
class UStaticMesh ;
class UStaticMeshComponent ;
2022-05-23 18:41:30 +00:00
USTRUCT ( )
struct FPooledNumberPopComponentList
{
GENERATED_BODY ( )
UPROPERTY ( transient )
2022-09-13 07:18:28 +00:00
TArray < TObjectPtr < UStaticMeshComponent > > Components ;
2022-05-23 18:41:30 +00:00
} ;
USTRUCT ( )
struct FLiveNumberPopEntry
{
GENERATED_BODY ( )
/** The component that is currently live */
UPROPERTY ( transient )
2022-09-13 07:18:28 +00:00
TObjectPtr < UStaticMeshComponent > Component = nullptr ;
2022-05-23 18:41:30 +00:00
/** The pool this component will go into when released */
FPooledNumberPopComponentList * Pool = nullptr ;
/** The world time that this component will be released to the pool */
float ReleaseTime = 0.0f ;
FLiveNumberPopEntry ( )
{ }
FLiveNumberPopEntry ( UStaticMeshComponent * InComponent , FPooledNumberPopComponentList * InPool , float InReleaseTime )
: Component ( InComponent ) , Pool ( InPool ) , ReleaseTime ( InReleaseTime )
{ }
} ;
/** Struct that holds the info for a new damage number */
struct FTempNumberPopInfo
{
UStaticMeshComponent * StaticMeshComponent = nullptr ;
TArray < UMaterialInstanceDynamic * > MeshMIDs ;
TArray < int32 > DamageNumberArray ;
} ;
UCLASS ( Blueprintable )
class ULyraNumberPopComponent_MeshText : public ULyraNumberPopComponent
{
GENERATED_BODY ( )
public :
ULyraNumberPopComponent_MeshText ( const FObjectInitializer & ObjectInitializer = FObjectInitializer : : Get ( ) ) ;
//~ULyraNumberPopComponent interface
virtual void AddNumberPop ( const FLyraNumberPopRequest & NewRequest ) override ;
//~End of ULyraNumberPopComponent interface
protected :
void SetMaterialParameters ( const FLyraNumberPopRequest & Request , FTempNumberPopInfo & NewDamageNumberInfo , const FTransform & CameraTransform , const FVector & NumberLocation ) ;
FLinearColor DetermineColor ( const FLyraNumberPopRequest & Request ) const ;
UStaticMesh * DetermineStaticMesh ( const FLyraNumberPopRequest & Request ) const ;
/** Releases components back to the pool that have exceeded their lifespan */
void ReleaseNextComponents ( ) ;
/** Style patterns to attempt to apply to the incoming number pops */
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Style " )
2022-09-13 07:18:28 +00:00
TArray < TObjectPtr < ULyraDamagePopStyle > > Styles ;
2022-05-23 18:41:30 +00:00
UPROPERTY ( EditDefaultsOnly , BlueprintReadWrite , Category = " Number Pop|Style " )
float ComponentLifespan ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Style " )
float DistanceFromCameraBeforeDoublingSize ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Style " )
float CriticalHitSizeMultiplier ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Font " )
float FontXSize ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Font " )
float FontYSize ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Font " )
float SpacingPercentageForOnes ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Style " )
float NumberOfNumberRotations ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
FName SignDigitParameterName ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
FName ColorParameterName ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
FName AnimationLifespanParameterName ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
FName IsCriticalHitParameterName ;
/** Damage numbers by default are given a depth close to the camera in the material to make sure they are never occluded. This can be toggled off here, should only be 0/1. */
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
FName MoveToCameraParameterName ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
TArray < FName > PositionParameterNames ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
TArray < FName > ScaleRotationAngleParameterNames ;
UPROPERTY ( EditDefaultsOnly , Category = " Number Pop|Material Bindings " )
TArray < FName > DurationParameterNames ;
UPROPERTY ( Transient )
2022-09-13 07:18:28 +00:00
TMap < TObjectPtr < UStaticMesh > , FPooledNumberPopComponentList > PooledComponentMap ;
2022-05-23 18:41:30 +00:00
UPROPERTY ( transient )
TArray < FLiveNumberPopEntry > LiveComponents ;
FTimerHandle ReleaseTimerHandle ;
} ;