38 lines
1.0 KiB
C++
38 lines
1.0 KiB
C++
#include "Gas/BusyGameAbility.h"
|
|
#include "AbilitySystemBlueprintLibrary.h"
|
|
#include "AbilitySystemComponent.h"
|
|
|
|
UBusyGameAbility::UBusyGameAbility()
|
|
{
|
|
}
|
|
|
|
bool UBusyGameAbility::GetAbilityEffectSpecHandle(const FName& EffectName, const UAbilitySystemComponent* Asc, const int32 Level,
|
|
FGameplayEffectSpecHandle& Handle) const
|
|
{
|
|
// 1. 查找对应的GameplayEffectClass
|
|
const TSubclassOf<UGameplayEffect> *EffectClass = AbilityEffects.Find(EffectName);
|
|
if (!EffectClass) return false;
|
|
|
|
// 2. 创建并设置GameplayEffect上下文
|
|
FGameplayEffectContextHandle EffectContextHandle = Asc->MakeEffectContext();
|
|
|
|
// 3. 将当前对象设置为效果来源
|
|
EffectContextHandle.AddSourceObject(this);
|
|
|
|
// 4. 创建GameplayEffectSpecHandle
|
|
Handle = Asc->MakeOutgoingSpec(*EffectClass, 1.f, EffectContextHandle); // 这里的1.f是等级
|
|
|
|
return Handle.IsValid();
|
|
}
|
|
|
|
void UBusyGameAbility::PostInitProperties()
|
|
{
|
|
Super::PostInitProperties();
|
|
if (SoftDataAsset)
|
|
{
|
|
Data = SoftDataAsset.LoadSynchronous();
|
|
Data->TargetAbility = this;
|
|
}
|
|
}
|
|
|