Files
Aura-TopDownRPG-GAS/Source/Aura/Private/AbilitySystem/AuraAbilitySystemComponent.cpp

79 lines
2.7 KiB
C++

// Copyright Echo Devgroup
#include "AbilitySystem/AuraAbilitySystemComponent.h"
#include "AuraGameplayTags.h"
#include "AbilitySystem/GameplayAbility/AuraGameplayAbility.h"
void UAuraAbilitySystemComponent::AbilityActorInfoSet()
{
OnGameplayEffectAppliedDelegateToSelf.AddUObject( this, &UAuraAbilitySystemComponent::EffectApplied);
//const FAuraGameplayTags& GameplayTags = FAuraGameplayTags::Get();
//GameplayTags.Attributes_Secondary_Armor.ToString();
}
void UAuraAbilitySystemComponent::AddCharacterAbilities(const TArray<TSubclassOf<UGameplayAbility>>& StartupAbilities)
{
for (const TSubclassOf<UGameplayAbility> AbilityClass : StartupAbilities)
{
FGameplayAbilitySpec AbilitySpec = FGameplayAbilitySpec(AbilityClass, 1); //Cannot be Const if GiveAbilityAndActivateOnce
if (const UAuraGameplayAbility* AuraAbility = Cast<UAuraGameplayAbility>(AbilitySpec.Ability))
{
//AbilitySpec.DynamicAbilityTags is depreciated, use GetDynamicSpecSourceTags() instead.
AbilitySpec.GetDynamicSpecSourceTags().AddTag(AuraAbility->StartupInputTag);
GiveAbility(AbilitySpec);
}
}
}
void UAuraAbilitySystemComponent::AbilityInputTagHeld(const FGameplayTag& InputTag)
{
if (!InputTag.IsValid()) return;
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
{
//AbilitySpec.DynamicAbilityTags is depreciated, use GetDynamicSpecSourceTags() instead.
if (AbilitySpec.GetDynamicSpecSourceTags().HasTagExact(InputTag))
{
AbilitySpecInputPressed(AbilitySpec);
if (!AbilitySpec.IsActive())
{
TryActivateAbility(AbilitySpec.Handle);
}
}
}
}
void UAuraAbilitySystemComponent::AbilityInputTagReleased(const FGameplayTag& InputTag)
{
if (!InputTag.IsValid()) return;
for (FGameplayAbilitySpec& AbilitySpec : GetActivatableAbilities())
{
//AbilitySpec.DynamicAbilityTags is depreciated, use GetDynamicSpecSourceTags() instead.
if (AbilitySpec.GetDynamicSpecSourceTags().HasTagExact(InputTag))
{
AbilitySpecInputPressed(AbilitySpec);
}
}
}
void UAuraAbilitySystemComponent::EffectApplied(UAbilitySystemComponent* AbilitySystemComponent,
const FGameplayEffectSpec& EffectSpec, FActiveGameplayEffectHandle ActiveEffectHandle)
{
//GEngine->AddOnScreenDebugMessage(1,8.f, FColor::Blue,FString("Effect Applied!"));
FGameplayTagContainer TagContainer;
EffectSpec.GetAllAssetTags(TagContainer);
EffectAssetTags.Broadcast(TagContainer);
for (const FGameplayTag& Tag : TagContainer)
{
//TODO: Broadcast the tag to the widget controller
//Message for Debugging tags being applied
//const FString msg = FString::Printf(TEXT("GE Tag: %s"), *Tag.ToString());
//GEngine->AddOnScreenDebugMessage(-1,8.f, FColor::Blue,msg);
}
}