AActor* UBTNode::GetGameplayTaskAvatar(const UGameplayTask* Task) const { if (Task == nullptr) { if (IsInstanced()) { const UBehaviorTreeComponent* BTComponent = Cast<const UBehaviorTreeComponent>(GetOuter()); //not having BT component for an instanced BT node is invalid! check(BTComponent); return BTComponent->GetAIOwner(); } else { UE_LOG(LogBehaviorTree, Warning, TEXT("%s: Unable to determine default GameplayTaskAvatar!"), *GetName()); return nullptr; } } const UAITask* AITask = Cast<const UAITask>(Task); if (AITask) { return AITask->GetAIController() ? AITask->GetAIController()->GetPawn() : nullptr; } const UGameplayTasksComponent* TasksComponent = Task->GetGameplayTasksComponent(); return TasksComponent ? TasksComponent->GetGameplayTaskAvatar(Task) : nullptr; }
UWorld* UBTNode::GetWorld() const { // instanced nodes are created for behavior tree component owning that instance // template nodes are created for behavior tree manager, which is located directly in UWorld return GetOuter() == NULL ? NULL : IsInstanced() ? (Cast<UBehaviorTreeComponent>(GetOuter()))->GetWorld() : Cast<UWorld>(GetOuter()->GetOuter()); }