53. Gameplay Effect Delegates
This commit is contained in:
		@@ -1 +1,20 @@
 | 
				
			|||||||
#include "GasaAbilitySystemComponent.h"
 | 
					#include "GasaAbilitySystemComponent.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "Engine/Engine.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UGasaAbilitySystemComp::OnAbilityActorInfoSet()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UGasaAbilitySystemComp::EffectApplied(UAbilitySystemComponent* AbilitySystem, FGameplayEffectSpec const& Spec,
 | 
				
			||||||
 | 
						FActiveGameplayEffectHandle ActiveEffect)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						GEngine->AddOnScreenDebugMessage(1, 8.f, FColor::Yellow, FString("Effect applied"));
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void UGasaAbilitySystemComp::InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						Super::InitAbilityActorInfo(InOwnerActor, InAvatarActor);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						OnGameplayEffectAppliedDelegateToSelf.AddUObject(this, & ThisClass::EffectApplied);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,10 +6,17 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "GasaAbilitySystemComponent.generated.h"
 | 
					#include "GasaAbilitySystemComponent.generated.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
UCLASS(BlueprintType)
 | 
					UCLASS(BlueprintType)
 | 
				
			||||||
class GASA_API UGasaAbilitySystemComp : public UAbilitySystemComponent
 | 
					class GASA_API UGasaAbilitySystemComp : public UAbilitySystemComponent
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	GENERATED_BODY()
 | 
						GENERATED_BODY()
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
 | 
						// TODO(Ed): If hes only using this to bind the EffectApplied to a delegate, then just use the init override instead.
 | 
				
			||||||
 | 
						void OnAbilityActorInfoSet();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void EffectApplied(UAbilitySystemComponent* AbilitySystem, FGameplayEffectSpec const& Spec, FActiveGameplayEffectHandle ActiveEffect);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#pragma region AbilitySystemComponent
 | 
				
			||||||
 | 
						void InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor) override;
 | 
				
			||||||
 | 
					#pragma endregion AbilitySystemComponent
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,11 +156,10 @@ void AGasaCharacter::PossessedBy(AController* NewController)
 | 
				
			|||||||
			GetMesh()->bOnlyAllowAutonomousTickPose = true;
 | 
								GetMesh()->bOnlyAllowAutonomousTickPose = true;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#if 0
 | 
				
			||||||
	if (bAutoAbilitySystem)
 | 
						if (bAutoAbilitySystem)
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		// TODO(Ed): Do we need to do this for enemies?
 | 
					 | 
				
			||||||
		AbilitySystem->InitAbilityActorInfo(this, this);
 | 
							AbilitySystem->InitAbilityActorInfo(this, this);
 | 
				
			||||||
	}
 | 
					#endif
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AGasaCharacter::SetPlayerDefaults()
 | 
					void AGasaCharacter::SetPlayerDefaults()
 | 
				
			||||||
@@ -179,11 +178,10 @@ void AGasaCharacter::BeginPlay()
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	Super::BeginPlay();
 | 
						Super::BeginPlay();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// TODO(Ed): Find out if this is the best spot todo this
 | 
				
			||||||
 | 
						// There is also OnPossessed, PostInitializeComponents, etc...
 | 
				
			||||||
	if (bAutoAbilitySystem)
 | 
						if (bAutoAbilitySystem)
 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		// TODO(Ed): Do we need to do this for enemies?
 | 
					 | 
				
			||||||
		AbilitySystem->InitAbilityActorInfo(this, this);
 | 
							AbilitySystem->InitAbilityActorInfo(this, this);
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void AGasaCharacter::Tick(float DeltaSeconds)
 | 
					void AGasaCharacter::Tick(float DeltaSeconds)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user