void UAbilityTask_VisualizeTargeting::Activate() { // Need to handle case where target actor was passed into task if (Ability && (TargetClass == NULL)) { if (TargetActor.IsValid()) { AGameplayAbilityTargetActor* SpawnedActor = TargetActor.Get(); TargetClass = SpawnedActor->GetClass(); if (ShouldSpawnTargetActor()) { InitializeTargetActor(SpawnedActor); FinalizeTargetActor(SpawnedActor); } else { TargetActor = NULL; // We may need a better solution here. We don't know the target actor isn't needed till after it's already been spawned. SpawnedActor->Destroy(); SpawnedActor = nullptr; } } else { EndTask(); } } }
void UAbilityTask_WaitTargetData::FinishSpawningActor(UObject* WorldContextObject, AGameplayAbilityTargetActor* SpawnedActor) { if (SpawnedActor && !SpawnedActor->IsPendingKill()) { check(TargetActor == SpawnedActor); const FTransform SpawnTransform = AbilitySystemComponent->GetOwner()->GetTransform(); SpawnedActor->FinishSpawning(SpawnTransform); FinalizeTargetActor(SpawnedActor); } }
void UAbilityTask_WaitTargetData::Activate() { // Need to handle case where target actor was passed into task if (Ability && (TargetClass == nullptr)) { if (TargetActor) { AGameplayAbilityTargetActor* SpawnedActor = TargetActor; TargetClass = SpawnedActor->GetClass(); RegisterTargetDataCallbacks(); if (IsPendingKill()) { return; } if (ShouldSpawnTargetActor()) { InitializeTargetActor(SpawnedActor); FinalizeTargetActor(SpawnedActor); // Note that the call to FinalizeTargetActor, this task could finish and our owning ability may be ended. } else { TargetActor = NULL; // We may need a better solution here. We don't know the target actor isn't needed till after it's already been spawned. SpawnedActor->Destroy(); SpawnedActor = nullptr; } } else { EndTask(); } } }