RealtimeStyleTransferRuntime/Source/LyraGame/AbilitySystem/LyraGameplayEffectContext.h

87 lines
2.5 KiB
C
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameplayEffectTypes.h"
2022-09-13 07:18:28 +00:00
#include "HAL/Platform.h"
#include "UObject/Class.h"
#include "UObject/WeakObjectPtr.h"
#include "UObject/WeakObjectPtrTemplates.h"
2022-05-23 18:41:30 +00:00
#include "LyraGameplayEffectContext.generated.h"
2022-09-13 07:18:28 +00:00
class AActor;
class FArchive;
2022-05-23 18:41:30 +00:00
class ILyraAbilitySourceInterface;
2022-09-13 07:18:28 +00:00
class UObject;
2022-05-23 18:41:30 +00:00
class UPhysicalMaterial;
USTRUCT()
struct FLyraGameplayEffectContext : public FGameplayEffectContext
{
GENERATED_BODY()
FLyraGameplayEffectContext()
: FGameplayEffectContext()
{
}
FLyraGameplayEffectContext(AActor* InInstigator, AActor* InEffectCauser)
: FGameplayEffectContext(InInstigator, InEffectCauser)
{
}
/** Returns the wrapped FLyraGameplayEffectContext from the handle, or nullptr if it doesn't exist or is the wrong type */
static LYRAGAME_API FLyraGameplayEffectContext* ExtractEffectContext(struct FGameplayEffectContextHandle Handle);
/** Sets the object used as the ability source */
void SetAbilitySource(const ILyraAbilitySourceInterface* InObject, float InSourceLevel);
/** Returns the ability source interface associated with the source object. Only valid on the authority. */
const ILyraAbilitySourceInterface* GetAbilitySource() const;
virtual FGameplayEffectContext* Duplicate() const override
{
FLyraGameplayEffectContext* NewContext = new FLyraGameplayEffectContext();
*NewContext = *this;
if (GetHitResult())
{
// Does a deep copy of the hit result
NewContext->AddHitResult(*GetHitResult(), true);
}
return NewContext;
}
virtual UScriptStruct* GetScriptStruct() const override
{
return FLyraGameplayEffectContext::StaticStruct();
}
/** Overridden to serialize new fields */
virtual bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess) override;
/** Returns the physical material from the hit result if there is one */
const UPhysicalMaterial* GetPhysicalMaterial() const;
public:
/** ID to allow the identification of multiple bullets that were part of the same cartridge */
UPROPERTY()
int32 CartridgeID = -1;
protected:
/** Ability Source object (should implement ILyraAbilitySourceInterface). NOT replicated currently */
UPROPERTY()
TWeakObjectPtr<const UObject> AbilitySourceObject;
};
template<>
struct TStructOpsTypeTraits<FLyraGameplayEffectContext> : public TStructOpsTypeTraitsBase2<FLyraGameplayEffectContext>
{
enum
{
WithNetSerializer = true,
WithCopy = true
};
};