File size: 2,168 Bytes
1e67697 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | // Copyright Epic Games, Inc. All Rights Reserved.
#include "LyraGameplayEffectContext.h"
#include "AbilitySystem/LyraAbilitySourceInterface.h"
#include "Engine/HitResult.h"
#include "PhysicalMaterials/PhysicalMaterial.h"
#if UE_WITH_IRIS
#include "Iris/ReplicationState/PropertyNetSerializerInfoRegistry.h"
#include "Serialization/GameplayEffectContextNetSerializer.h"
#endif
#include UE_INLINE_GENERATED_CPP_BY_NAME(LyraGameplayEffectContext)
class FArchive;
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;
}
#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
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;
}
|