46. PostGameplayEffectExecute
This commit is contained in:
parent
ef002ccf53
commit
ae1e28a072
BIN
Project/Binaries/Win64/UnrealEditor-GasaEditor.dll
(Stored with Git LFS)
BIN
Project/Binaries/Win64/UnrealEditor-GasaEditor.dll
(Stored with Git LFS)
Binary file not shown.
38
Project/Source/Gasa/AbilitySystem/EffectProperties.cpp
Normal file
38
Project/Source/Gasa/AbilitySystem/EffectProperties.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include "EffectProperties.h"
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "GameplayEffect.h"
|
||||
#include "GameplayEffectExtension.h"
|
||||
#include "GameFramework/Pawn.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
|
||||
void FEffectProperties::Populate(FGameplayEffectModCallbackData const& Data)
|
||||
{
|
||||
Context = Data.EffectSpec.GetContext();
|
||||
SourceAbilitySystem = Context.GetOriginalInstigatorAbilitySystemComponent();
|
||||
|
||||
if (IsValid(SourceAbilitySystem)
|
||||
&& SourceAbilitySystem->AbilityActorInfo.IsValid()
|
||||
&& SourceAbilitySystem->AbilityActorInfo->AvatarActor.IsValid())
|
||||
{
|
||||
FGameplayAbilityActorInfo* AbilityInfo = SourceAbilitySystem->AbilityActorInfo.Get();
|
||||
SourceAvatar = AbilityInfo->AvatarActor.Get();
|
||||
SourceController = AbilityInfo->PlayerController.Get();
|
||||
|
||||
if (SourceController == nullptr && SourceAvatar)
|
||||
{
|
||||
APawn* Pawn = Cast<APawn>(SourceAvatar);
|
||||
if (Pawn)
|
||||
SourceController = Pawn->GetController();
|
||||
}
|
||||
}
|
||||
|
||||
if (Data.Target.AbilityActorInfo.IsValid() && Data.Target.AbilityActorInfo->AvatarActor.IsValid())
|
||||
{
|
||||
FGameplayAbilityActorInfo* AbilityInfo = Data.Target.AbilityActorInfo.Get();
|
||||
TargetAvatar = AbilityInfo->AvatarActor.Get();
|
||||
TargetController = AbilityInfo->PlayerController.Get();
|
||||
TargetAbilitySystem = UAbilitySystemGlobals::GetAbilitySystemComponentFromActor(TargetAvatar);
|
||||
}
|
||||
}
|
34
Project/Source/Gasa/AbilitySystem/EffectProperties.h
Normal file
34
Project/Source/Gasa/AbilitySystem/EffectProperties.h
Normal file
@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "GasaCommon.h"
|
||||
|
||||
#include "EffectProperties.generated.h"
|
||||
|
||||
USTRUCT()
|
||||
struct GASA_API FEffectProperties
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
FGameplayEffectContextHandle Context;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UAbilitySystemComponent* SourceAbilitySystem;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
AActor* SourceAvatar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
AController* SourceController;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
UAbilitySystemComponent* TargetAbilitySystem;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
AActor* TargetAvatar;
|
||||
|
||||
UPROPERTY(VisibleAnywhere)
|
||||
APlayerController* TargetController;
|
||||
|
||||
void Populate(FGameplayEffectModCallbackData const& Data);
|
||||
};
|
@ -18,7 +18,7 @@ namespace Gasa
|
||||
|
||||
// From: UAbilitySystemGlobals::GetAbilitySystemComponentFromActor
|
||||
inline
|
||||
UGasaAbilitySystemComp* GetAbilitySystem(AActor* Actor, bool LookForComponent = false)
|
||||
UGasaAbilitySystemComp* GetAbilitySystem(AActor* Actor, bool LookForComponent = true)
|
||||
{
|
||||
if (Actor == nullptr)
|
||||
return nullptr;
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Generated by GasaGen/GasaGen_UGasaAttributeSet.cpp
|
||||
#include "GasaAttributeSet.h"
|
||||
#include "GasaAttributeSet_Inlines.h"
|
||||
#include "EffectProperties.h"
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "Net/UnrealNetwork.h"
|
||||
@ -21,26 +22,38 @@ void UGasaAttributeSet::Client_OnRep_Health( FGameplayAttributeData& PrevHealth
|
||||
static FProperty* UGasaAttributeSetProperty = FindFieldChecked<FProperty>(StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, Health));
|
||||
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication(FGameplayAttribute(UGasaAttributeSetProperty), Health, PrevHealth);
|
||||
}
|
||||
|
||||
void UGasaAttributeSet::Client_OnRep_MaxHealth(FGameplayAttributeData& PrevMaxHealth)
|
||||
{
|
||||
// From GAMEPLAYATTRIBUTE_REPNOTIFY
|
||||
static FProperty* UGasaAttributeSetProperty = FindFieldChecked<FProperty>(StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, MaxHealth));
|
||||
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication( FGameplayAttribute( UGasaAttributeSetProperty ), MaxHealth, PrevMaxHealth );
|
||||
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication(FGameplayAttribute(UGasaAttributeSetProperty), MaxHealth,
|
||||
PrevMaxHealth);
|
||||
}
|
||||
|
||||
void UGasaAttributeSet::Client_OnRep_Mana(FGameplayAttributeData& PrevMana)
|
||||
{
|
||||
// From GAMEPLAYATTRIBUTE_REPNOTIFY
|
||||
static FProperty* UGasaAttributeSetProperty = FindFieldChecked<FProperty>(StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, Mana));
|
||||
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication(FGameplayAttribute(UGasaAttributeSetProperty), Mana, PrevMana);
|
||||
}
|
||||
|
||||
void UGasaAttributeSet::Client_OnRep_MaxMana(FGameplayAttributeData& PrevMaxMana)
|
||||
{
|
||||
// From GAMEPLAYATTRIBUTE_REPNOTIFY
|
||||
static FProperty* UGasaAttributeSetProperty = FindFieldChecked<FProperty>(StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, MaxMana));
|
||||
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication( FGameplayAttribute( UGasaAttributeSetProperty ), MaxMana, PrevMaxMana );
|
||||
GetOwningAbilitySystemComponentChecked()->SetBaseAttributeValueFromReplication(FGameplayAttribute(UGasaAttributeSetProperty), MaxMana,
|
||||
PrevMaxMana);
|
||||
}
|
||||
#pragma endregion Rep Notifies
|
||||
|
||||
void UGasaAttributeSet::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
||||
{
|
||||
Super::PostGameplayEffectExecute(Data);
|
||||
FEffectProperties Props;
|
||||
Props.Populate(Data);
|
||||
}
|
||||
|
||||
void UGasaAttributeSet::PreAttributeChange(FGameplayAttribute const& Attribute, float& NewValue)
|
||||
{
|
||||
Super::PreAttributeChange(Attribute, NewValue);
|
||||
@ -62,6 +75,7 @@ void UGasaAttributeSet::PreAttributeChange( FGameplayAttribute const& Attribute,
|
||||
NewValue = FMath::Clamp(NewValue, 0, 99999.000000);
|
||||
}
|
||||
}
|
||||
|
||||
void UGasaAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||
{
|
||||
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||
|
@ -8,6 +8,7 @@ UCLASS()
|
||||
class GASA_API UGasaAttributeSet : public UAttributeSet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGasaAttributeSet();
|
||||
|
||||
@ -35,16 +36,19 @@ public:
|
||||
static FProperty* Prop = FindFieldChecked<FProperty>(UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, Health));
|
||||
return Prop;
|
||||
}
|
||||
|
||||
static FGameplayAttribute GetMaxHealthAttribute()
|
||||
{
|
||||
static FProperty* Prop = FindFieldChecked<FProperty>(UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, MaxHealth));
|
||||
return Prop;
|
||||
}
|
||||
|
||||
static FGameplayAttribute GetManaAttribute()
|
||||
{
|
||||
static FProperty* Prop = FindFieldChecked<FProperty>(UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, Mana));
|
||||
return Prop;
|
||||
}
|
||||
|
||||
static FGameplayAttribute GetMaxManaAttribute()
|
||||
{
|
||||
static FProperty* Prop = FindFieldChecked<FProperty>(UGasaAttributeSet::StaticClass(), GET_MEMBER_NAME_CHECKED(UGasaAttributeSet, MaxMana));
|
||||
@ -68,16 +72,19 @@ public:
|
||||
Health.SetBaseValue(NewVal);
|
||||
Health.SetCurrentValue(NewVal);
|
||||
}
|
||||
|
||||
FORCEINLINE void InitMaxHealth(float NewVal)
|
||||
{
|
||||
MaxHealth.SetBaseValue(NewVal);
|
||||
MaxHealth.SetCurrentValue(NewVal);
|
||||
}
|
||||
|
||||
FORCEINLINE void InitMana(float NewVal)
|
||||
{
|
||||
Mana.SetBaseValue(NewVal);
|
||||
Mana.SetCurrentValue(NewVal);
|
||||
}
|
||||
|
||||
FORCEINLINE void InitMaxMana(float NewVal)
|
||||
{
|
||||
MaxMana.SetBaseValue(NewVal);
|
||||
@ -87,6 +94,7 @@ public:
|
||||
|
||||
#pragma region AttributeSet
|
||||
void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override;
|
||||
void PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data) override;
|
||||
#pragma endregion AttributeSet
|
||||
|
||||
#pragma region UObject
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#pragma region Engine Forwards
|
||||
struct FInputActionValue;
|
||||
struct FGameplayEffectContextHandle;
|
||||
struct FGameplayEffectModCallbackData;
|
||||
struct FOnAttributeChangeData;
|
||||
struct FReplicationFlags;
|
||||
|
||||
|
@ -104,7 +104,7 @@ void gen_UGasaAttributeSet()
|
||||
body.append( def_pragma( txt("region AttributeSet")));
|
||||
body.append( code_str(
|
||||
void PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue) override;
|
||||
// void PostAttributeChange(const FGameplayAttribute& Attribute, float OldValue, float NewValue) override;
|
||||
void PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data) override;
|
||||
));
|
||||
body.append( def_pragma( txt("endregion AttributeSet")));
|
||||
body.append(fmt_newline);
|
||||
@ -170,6 +170,7 @@ void gen_UGasaAttributeSet()
|
||||
header.print(fmt_newline);
|
||||
source.print( def_include( txt("GasaAttributeSet.h")));
|
||||
source.print( def_include( txt("GasaAttributeSet_Inlines.h")));
|
||||
source.print( def_include( txt("EffectProperties.h")));
|
||||
source.print(fmt_newline);
|
||||
source.print( def_include( txt("AbilitySystemComponent.h")));
|
||||
source.print( def_include( txt("Net/UnrealNetwork.h")));
|
||||
@ -191,6 +192,17 @@ void gen_UGasaAttributeSet()
|
||||
|
||||
impl_attribute_fields( body, class_name, attribute_fields);
|
||||
|
||||
Code PostGameplayEffectExecute = parse_function( code(
|
||||
void UGasaAttributeSet::PostGameplayEffectExecute(FGameplayEffectModCallbackData const& Data)
|
||||
{
|
||||
Super::PostGameplayEffectExecute(Data);
|
||||
FEffectProperties Props;
|
||||
Props.Populate(Data);
|
||||
}
|
||||
));
|
||||
body.append(PostGameplayEffectExecute);
|
||||
body.append(fmt_newline);
|
||||
|
||||
CodeFn PreAttributeChange;
|
||||
{
|
||||
CodeBody attribute_clamps = def_body( CodeT::Function_Body );
|
||||
@ -221,6 +233,8 @@ void gen_UGasaAttributeSet()
|
||||
}
|
||||
)));
|
||||
}
|
||||
attribute_clamps.append(fmt_newline);
|
||||
attribute_clamps.append(fmt_newline);
|
||||
PreAttributeChange = parse_function( token_fmt( "attribute_clamps", (StrC)attribute_clamps.to_string(), stringize(
|
||||
void UGasaAttributeSet::PreAttributeChange(const FGameplayAttribute& Attribute, float& NewValue)
|
||||
{
|
||||
@ -230,6 +244,7 @@ void gen_UGasaAttributeSet()
|
||||
)));
|
||||
}
|
||||
body.append(PreAttributeChange);
|
||||
body.append(fmt_newline);
|
||||
|
||||
CodeFn GetLifetimeOfReplicatedProps;
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user