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

77 lines
2.5 KiB
C++
Raw Normal View History

2025-10-14 22:20:59 -04:00
// Copyright Echo Devgroup
#include "AbilitySystem/AuraAbilitySystemComponent.h"
#include "AuraGameplayTags.h"
2025-10-16 14:33:58 -04:00
#include "AbilitySystem/GameplayAbility/AuraGameplayAbility.h"
2025-10-14 22:20:59 -04:00
void UAuraAbilitySystemComponent::AbilityActorInfoSet()
{
2025-10-16 16:52:48 -04:00
OnGameplayEffectAppliedDelegateToSelf.AddUObject( this, &UAuraAbilitySystemComponent::ClientEffectApplied);
2025-10-14 22:20:59 -04:00
}
2025-10-16 14:33:58 -04:00
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);
}
}
}
2025-10-16 16:52:48 -04:00
void UAuraAbilitySystemComponent::ClientEffectApplied_Implementation(UAbilitySystemComponent* AbilitySystemComponent,
const FGameplayEffectSpec& EffectSpec, FActiveGameplayEffectHandle ActiveEffectHandle)
2025-10-14 22:20:59 -04:00
{
//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);
}
}