Space Plunder
Loading...
Searching...
No Matches
UBTS_PredictLocation Class Reference

This class is a behavior tree service node that predicts the location of a target actor and sets it in the blackboard. More...

#include <BTS_PredictLocation.h>

Inheritance diagram for UBTS_PredictLocation:

Classes

struct  FPredictLocationMemory
 

Public Member Functions

 UBTS_PredictLocation ()
 

Protected Member Functions

virtual void TickNode (UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory, float DeltaSeconds) override
 
virtual FString GetStaticDescription () const override
 
virtual uint16 GetInstanceMemorySize () const override
 

Protected Attributes

FBlackboardKeySelector TargetActor
 
FBlackboardKeySelector TargetLocation
 
bool bDebuggingMode = false
 
float SphereSize = 10.0f
 
float SphereLifetime = 1.0f
 
FColor TargetSphereColor = FColor::Red
 

Detailed Description

This class is a behavior tree service node that predicts the location of a target actor and sets it in the blackboard.

The UBTS_PredictLocation class inherits from UBTService and provides the functionality to predict the location of a target actor and set the location in the blackboard. The predicted location is determined using an AI Actions interface which must be implemented by the AI controller.

Constructor & Destructor Documentation

◆ UBTS_PredictLocation()

UBTS_PredictLocation::UBTS_PredictLocation ( )
16{
17 NodeName = TEXT("Predict Target Location");
18 INIT_SERVICE_NODE_NOTIFY_FLAGS();
19
20#if WITH_EDITOR
21 bDebuggingMode = true;
22#endif // WITH_EDITOR
23}
bool bDebuggingMode
Definition BTS_PredictLocation.h:39

Member Function Documentation

◆ GetInstanceMemorySize()

uint16 UBTS_PredictLocation::GetInstanceMemorySize ( ) const
overrideprotectedvirtual
90{
91 return sizeof(FPredictLocationMemory);
92}

◆ GetStaticDescription()

FString UBTS_PredictLocation::GetStaticDescription ( ) const
overrideprotectedvirtual
57{
58 FString Description;
60 {
61 Description += FString::Printf(TEXT("\n DEBUG ACTIVE"));
62 }
63 if(TargetActor.SelectedKeyName.IsValid())
64 {
65 Description += FString::Printf(TEXT("\nTarget Object: %s"), *TargetActor.SelectedKeyName.ToString());
66 }
67 else
68 {
69 Description += TEXT("\nTarget Object: None");
70 }
71 if(TargetLocation.SelectedKeyName.IsValid())
72 {
73 Description += FString::Printf(TEXT("\nSet: %s"), *TargetLocation.SelectedKeyName.ToString());
74 }
75 else
76 {
77 Description += TEXT("\nTarget Location: None");
78 }
79 return Description;
80}
FBlackboardKeySelector TargetActor
Definition BTS_PredictLocation.h:34
FBlackboardKeySelector TargetLocation
Definition BTS_PredictLocation.h:36

◆ TickNode()

void UBTS_PredictLocation::TickNode ( UBehaviorTreeComponent & OwnerComp,
uint8 * NodeMemory,
float DeltaSeconds )
overrideprotectedvirtual
26{
27 TRACE_CPUPROFILER_EVENT_SCOPE(UBTS_PredictLocation::TickNode);
28 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Behaviors);
29 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Services);
30
31 Super::TickNode(OwnerComp, NodeMemory, DeltaSeconds);
32 FPredictLocationMemory* SelectTargetMemory = reinterpret_cast<FPredictLocationMemory*>(NodeMemory);
33 if(SelectTargetMemory == nullptr){return;}
34 UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent();
35 if(BlackboardComp != nullptr)
36 {
37 SelectTargetMemory->TargetActor = Cast<AActor>(BlackboardComp->GetValueAsObject(TargetActor.SelectedKeyName));
38 }
39 if(SelectTargetMemory->TargetActor == nullptr){return;}
40 if(OwnerComp.GetAIOwner() == nullptr && OwnerComp.GetAIOwner()->GetPawn() == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("AI Owner NULL in Check Line Of Sight"))return;}
41 IAIActionsInterface* AIActions = Cast<IAIActionsInterface>(OwnerComp.GetAIOwner());
42 if(AIActions != nullptr)
43 {
44 SelectTargetMemory->TargetLocation = AIActions->PredictLocation(SelectTargetMemory->TargetActor);
46 {
47 DrawDebugSphere(GetWorld(), SelectTargetMemory->TargetLocation, SphereSize, 16, TargetSphereColor, false, SphereLifetime, 1, 1.0f);
48 }
49 }
50 if(BlackboardComp != nullptr)
51 {
52 BlackboardComp->SetValueAsVector(TargetLocation.SelectedKeyName, SelectTargetMemory->TargetLocation);
53 }
54}
Definition AIActionsInterface.h:20
virtual FVector PredictLocation(AActor *TargetActor)=0
FColor TargetSphereColor
Definition BTS_PredictLocation.h:45
float SphereLifetime
Definition BTS_PredictLocation.h:43
float SphereSize
Definition BTS_PredictLocation.h:41
virtual void TickNode(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory, float DeltaSeconds) override
Definition BTS_PredictLocation.cpp:25

Member Data Documentation

◆ bDebuggingMode

bool UBTS_PredictLocation::bDebuggingMode = false
protected

◆ SphereLifetime

float UBTS_PredictLocation::SphereLifetime = 1.0f
protected

◆ SphereSize

float UBTS_PredictLocation::SphereSize = 10.0f
protected

◆ TargetActor

FBlackboardKeySelector UBTS_PredictLocation::TargetActor
protected

◆ TargetLocation

FBlackboardKeySelector UBTS_PredictLocation::TargetLocation
protected

◆ TargetSphereColor

FColor UBTS_PredictLocation::TargetSphereColor = FColor::Red
protected

The documentation for this class was generated from the following files: