コード例 #1
0
void UAbilityTask_WaitGameplayEffectRemoved::Activate()
{
    if (Handle.IsValid() == false)
    {
        InvalidHandle.Broadcast();
        EndTask();
        return;;
    }

    UAbilitySystemComponent* EffectOwningAbilitySystemComponent = Handle.GetOwningAbilitySystemComponent();

    if (EffectOwningAbilitySystemComponent)
    {
        FOnActiveGameplayEffectRemoved* DelPtr = EffectOwningAbilitySystemComponent->OnGameplayEffectRemovedDelegate(Handle);
        if (DelPtr)
        {
            OnGameplayEffectRemovedDelegateHandle = DelPtr->AddUObject(this, &UAbilityTask_WaitGameplayEffectRemoved::OnGameplayEffectRemoved);
            Registered = true;
        }
    }

    if (!Registered)
    {
        // GameplayEffect was already removed, treat this as a warning? Could be cases of immunity or chained gameplay rules that would instant remove something
        OnGameplayEffectRemoved();
    }
}
void UAbilityTask_WaitGameplayEffectStackChange::OnDestroy(bool AbilityIsEnding)
{
	UAbilitySystemComponent* EffectOwningAbilitySystemComponent = Handle.GetOwningAbilitySystemComponent();
	if (EffectOwningAbilitySystemComponent && OnGameplayEffectStackChangeDelegateHandle.IsValid())
	{
		FOnActiveGameplayEffectRemoved* DelPtr = EffectOwningAbilitySystemComponent->OnGameplayEffectRemovedDelegate(Handle);
		if (DelPtr)
		{
			DelPtr->Remove(OnGameplayEffectStackChangeDelegateHandle);
		}
	}

	Super::OnDestroy(AbilityIsEnding);
}