56{
58 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Behaviors);
59 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Tasks);
60 FBTTaskPredictLocationMemory* PredictLocationMemory = reinterpret_cast<FBTTaskPredictLocationMemory*>(NodeMemory);
61 if(PredictLocationMemory == nullptr){FinishLatentTask(OwnerComp, EBTNodeResult::Failed);}
62 if(GetWorld()->GetTimeSeconds() - PredictLocationMemory->StartTime >=
DelayDuration)
63 {
64 FActorPerceptionBlueprintInfo SenseInfo;
65 if(OwnerComp.GetAIOwner() != nullptr && OwnerComp.GetAIOwner()->GetAIPerceptionComponent() != nullptr && PredictLocationMemory->TargetActor != nullptr)
66 {
67 const bool bSuccess = OwnerComp.GetAIOwner()->GetAIPerceptionComponent()->GetActorsPerception(PredictLocationMemory->TargetActor, SenseInfo);
68 if(bSuccess)
69 {
70 FAIStimulus PredictionInfo;
71 for(const auto Info : SenseInfo.LastSensedStimuli)
72 {
74 {
75 PredictionInfo = Info;
76 break;
77 }
78 }
79 if(PredictionInfo.IsValid())
80 {
81 UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent();
82 if(BlackboardComp != nullptr)
83 {
84 BlackboardComp->SetValueAsVector(
TargetFireLocation.SelectedKeyName, PredictionInfo.StimulusLocation);
85 }
86 }
87 }
88 }
89 FinishLatentTask(OwnerComp, EBTNodeResult::Succeeded);
90 }
91}
static EAISense GetSenseFromStimulus(const FAIStimulus &Stimulus)
Definition AIBPLib.cpp:21
virtual void TickTask(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory, float DeltaSeconds) override
Definition BTTask_PredictLocation.cpp:55