GE 设置
蓝图方法
C++
.h
#include "AbilitySystemComponent.h"
public:
UFUNCTION(BlueprintCallable, meta=(WorldContext=WorldContextObject, Keywords="Apply Effect"), Category="Star Chapter Global|GameplayAbilitySystem|Effect")
static FActiveGameplayEffectHandle ApplyGameplayEffectToSelfSetByCallerMagnitudes(
UAbilitySystemComponent* AbilitySystemComponent,
TSubclassOf<UGameplayEffect> GameplayEffectClass,
float Level,
TMap<FGameplayTag, float> NewSetByCallerValues
);
UFUNCTION(BlueprintCallable, meta=(WorldContext=WorldContextObject, Keywords="Apply Effect"), Category="Star Chapter Global|GameplayAbilitySystem|Effect")
static FActiveGameplayEffectHandle ApplyGameplayEffectToSelfSetByCallerMagnitude(
UAbilitySystemComponent* AbilitySystemComponent,
TSubclassOf<UGameplayEffect> GameplayEffectClass,
float Level,
FGameplayTag SetByCallerTag,
float NewSetByCallerValue
);
.cpp
FActiveGameplayEffectHandle UStarChapterBlueprintFunctionLibrary::ApplyGameplayEffectToSelfSetByCallerMagnitudes(
UAbilitySystemComponent* AbilitySystemComponent, TSubclassOf<UGameplayEffect> GameplayEffectClass, float Level,
TMap<FGameplayTag, float> NewSetByCallerValues)
{
if (AbilitySystemComponent)
{
FGameplayEffectSpecHandle SpecHandle = AbilitySystemComponent->MakeOutgoingSpec(GameplayEffectClass, Level, AbilitySystemComponent->MakeEffectContext());
for (auto Element : NewSetByCallerValues)
{
SpecHandle = UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(SpecHandle, Element.Key, Element.Value);
}
return AbilitySystemComponent->ApplyGameplayEffectSpecToSelf(*SpecHandle.Data.Get());
}
return FActiveGameplayEffectHandle();
}
FActiveGameplayEffectHandle UStarChapterBlueprintFunctionLibrary::ApplyGameplayEffectToSelfSetByCallerMagnitude(
UAbilitySystemComponent* AbilitySystemComponent, TSubclassOf<UGameplayEffect> GameplayEffectClass, float Level,
FGameplayTag SetByCallerTag, float NewSetByCallerValue)
{
if (AbilitySystemComponent)
{
FGameplayEffectSpecHandle SpecHandle = AbilitySystemComponent->MakeOutgoingSpec(GameplayEffectClass, Level, AbilitySystemComponent->MakeEffectContext());
SpecHandle = UAbilitySystemBlueprintLibrary::AssignTagSetByCallerMagnitude(SpecHandle, SetByCallerTag, NewSetByCallerValue);
return AbilitySystemComponent->ApplyGameplayEffectSpecToSelf(*SpecHandle.Data.Get());
}
return FActiveGameplayEffectHandle();
}