void UAbilitySystemBlueprintLibrary::SendGameplayEventToActor(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload) { if (Actor && !Actor->IsPendingKill()) { IAbilitySystemInterface* AbilitySystemInterface = Cast<IAbilitySystemInterface>(Actor); if (AbilitySystemInterface != NULL) { UAbilitySystemComponent* AbilitySystemComponent = AbilitySystemInterface->GetAbilitySystemComponent(); if (AbilitySystemComponent != NULL) { FScopedPredictionWindow NewScopedWindow(AbilitySystemComponent, true); AbilitySystemComponent->HandleGameplayEvent(EventTag, &Payload); } } } }
// TODO: polymorphic payload void UGameplayAbility::SendGameplayEvent(FGameplayTag EventTag, FGameplayEventData Payload) { if (NetExecutionPolicy == EGameplayAbilityNetExecutionPolicy::Predictive) { Payload.PredictionKey = CurrentActivationInfo.GetPredictionKeyForNewAction(); } AActor *OwnerActor = Cast<AActor>(GetOuter()); if (OwnerActor) { UAbilitySystemComponent* AbilitySystemComponent = OwnerActor->FindComponentByClass<UAbilitySystemComponent>(); if (ensure(AbilitySystemComponent)) { AbilitySystemComponent->HandleGameplayEvent(EventTag, &Payload); } } }