RealtimeStyleTransferRuntime/Source/LyraGame/AbilitySystem/LyraGameplayEffectContext.cpp

67 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 "LyraGameplayEffectContext.h"
2022-09-13 07:18:28 +00:00
2022-05-23 18:41:30 +00:00
#include "AbilitySystem/LyraAbilitySourceInterface.h"
2022-09-13 07:18:28 +00:00
#include "Engine/HitResult.h"
#include "PhysicalMaterials/PhysicalMaterial.h"
#include "Templates/Casts.h"
#include "UObject/Object.h"
#if UE_WITH_IRIS
#include "Iris/ReplicationState/PropertyNetSerializerInfoRegistry.h"
#include "Serialization/GameplayEffectContextNetSerializer.h"
#endif
class FArchive;
2022-05-23 18:41:30 +00:00
FLyraGameplayEffectContext* FLyraGameplayEffectContext::ExtractEffectContext(struct FGameplayEffectContextHandle Handle)
{
FGameplayEffectContext* BaseEffectContext = Handle.Get();
if ((BaseEffectContext != nullptr) && BaseEffectContext->GetScriptStruct()->IsChildOf(FLyraGameplayEffectContext::StaticStruct()))
{
return (FLyraGameplayEffectContext*)BaseEffectContext;
}
return nullptr;
}
bool FLyraGameplayEffectContext::NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
{
FGameplayEffectContext::NetSerialize(Ar, Map, bOutSuccess);
// Not serialized for post-activation use:
// CartridgeID
return true;
}
2022-09-13 07:18:28 +00:00
#if UE_WITH_IRIS
namespace UE::Net
{
// Forward to FGameplayEffectContextNetSerializer
// Note: If FLyraGameplayEffectContext::NetSerialize() is modified, a custom NetSerializesr must be implemented as the current fallback will no longer be sufficient.
UE_NET_IMPLEMENT_FORWARDING_NETSERIALIZER_AND_REGISTRY_DELEGATES(LyraGameplayEffectContext, FGameplayEffectContextNetSerializer);
}
#endif
2022-05-23 18:41:30 +00:00
void FLyraGameplayEffectContext::SetAbilitySource(const ILyraAbilitySourceInterface* InObject, float InSourceLevel)
{
AbilitySourceObject = MakeWeakObjectPtr(Cast<const UObject>(InObject));
//SourceLevel = InSourceLevel;
}
const ILyraAbilitySourceInterface* FLyraGameplayEffectContext::GetAbilitySource() const
{
return Cast<ILyraAbilitySourceInterface>(AbilitySourceObject.Get());
}
const UPhysicalMaterial* FLyraGameplayEffectContext::GetPhysicalMaterial() const
{
if (const FHitResult* HitResultPtr = GetHitResult())
{
return HitResultPtr->PhysMaterial.Get();
}
return nullptr;
}