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

#include <BTT_GetLastKnownLocation.h>

Inheritance diagram for UBTT_GetLastKnownLocation:

Public Member Functions

 UBTT_GetLastKnownLocation ()
 

Public Attributes

float Radius = 250.0f
 
FBlackboardKeySelector TargetEnemy
 
FBlackboardKeySelector MoveTargetLocation
 
TArray< EAISenseSensesToUse = {EAISense::Sight}
 
bool bDebuggingMode = false
 
float Extent = 0.1f
 
FColor LocationColor = FColor::Green
 
FColor LocationInRadiusColor = FColor::Blue
 
float Thickness = 1.0f
 

Protected Member Functions

virtual EBTNodeResult::Type ExecuteTask (UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) override
 
virtual FString GetStaticDescription () const override
 

Constructor & Destructor Documentation

◆ UBTT_GetLastKnownLocation()

UBTT_GetLastKnownLocation::UBTT_GetLastKnownLocation ( )
17{
18 NodeName = TEXT("Get Last Known Location");
19}

Member Function Documentation

◆ ExecuteTask()

EBTNodeResult::Type UBTT_GetLastKnownLocation::ExecuteTask ( UBehaviorTreeComponent & OwnerComp,
uint8 * NodeMemory )
overrideprotectedvirtual
22{
23 TRACE_CPUPROFILER_EVENT_SCOPE(UBTT_GetLastKnownLocation::ExecuteTask);
24 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Behaviors);
25 SCOPE_CYCLE_COUNTER(STATGROUP_AIToolKit_Tasks);
26 UBlackboardComponent* BlackboardComp = OwnerComp.GetBlackboardComponent();
27 if(BlackboardComp != nullptr)
28 {
29 AActor* TargetActor = Cast<AActor>(BlackboardComp->GetValueAsObject(TargetEnemy.SelectedKeyName));
30 if(TargetActor != nullptr && OwnerComp.GetAIOwner() != nullptr)
31 {
32 IAIActionsInterface* AIActions = Cast<IAIActionsInterface>(OwnerComp.GetAIOwner());
33 if(AIActions != nullptr)
34 {
35
36 const FVector Location = AIActions->GetLastKnownLocation(TargetActor, SensesToUse);
38 {
39 DrawDebugBox(GetWorld(), Location, FVector(Extent), LocationColor, false, 1.0f, 0, Thickness);
40 }
41 const UNavigationSystemV1* NavSystem = UNavigationSystemV1::GetNavigationSystem(OwnerComp.GetAIOwner());
42 if(NavSystem != nullptr)
43 {
44 FNavLocation RandomPoint(Location);
45 const bool bFoundPoint = NavSystem->GetRandomReachablePointInRadius(Location, Radius, RandomPoint);
46 if(bFoundPoint)
47 {
49 {
50 DrawDebugBox(GetWorld(), RandomPoint, FVector(Extent), LocationInRadiusColor, false, 1.0f, 0, Thickness);
51 }
52 BlackboardComp->SetValueAsVector(MoveTargetLocation.SelectedKeyName, RandomPoint);
53 return EBTNodeResult::Succeeded;
54 }
55 BlackboardComp->SetValueAsVector(MoveTargetLocation.SelectedKeyName, Location);
56 return EBTNodeResult::Succeeded;
57 }
58 }
59 }
60 }
62 {
63 UBaseHelpersBPLib::PrintToLog(OwnerComp.GetAIOwner(), "UBTT_GetLastKnownLocation Failed");
64 }
65 return EBTNodeResult::Failed;
66}
Definition AIActionsInterface.h:20
virtual FVector GetLastKnownLocation(AActor *TargetActor, const TArray< EAISense > &Senses)=0
float Thickness
Definition BTT_GetLastKnownLocation.h:41
FColor LocationInRadiusColor
Definition BTT_GetLastKnownLocation.h:39
TArray< EAISense > SensesToUse
Definition BTT_GetLastKnownLocation.h:30
FBlackboardKeySelector MoveTargetLocation
Definition BTT_GetLastKnownLocation.h:28
FColor LocationColor
Definition BTT_GetLastKnownLocation.h:37
bool bDebuggingMode
Definition BTT_GetLastKnownLocation.h:33
float Radius
Definition BTT_GetLastKnownLocation.h:23
float Extent
Definition BTT_GetLastKnownLocation.h:35
FBlackboardKeySelector TargetEnemy
Definition BTT_GetLastKnownLocation.h:26
virtual EBTNodeResult::Type ExecuteTask(UBehaviorTreeComponent &OwnerComp, uint8 *NodeMemory) override
Definition BTT_GetLastKnownLocation.cpp:21
static void PrintToLog(const UObject *WorldContextObject, const FString &Message, const bool bWarning=false, const bool bError=false)
Definition BaseHelpersBPLib.cpp:98

◆ GetStaticDescription()

FString UBTT_GetLastKnownLocation::GetStaticDescription ( ) const
overrideprotectedvirtual
70{
71 FString Description;
72 Description += FString::Printf(TEXT("\nRadius: %i"), FMath::RoundToInt(Radius));
73 if(TargetEnemy.SelectedKeyName.IsValid())
74 {
75 Description += FString::Printf(TEXT("\nTarget Object: %s"), *TargetEnemy.SelectedKeyName.ToString());
76 }
77 else
78 {
79 Description += TEXT("\nTarget Object: None");
80 }
81 if(MoveTargetLocation.SelectedKeyName.IsValid())
82 {
83 Description += FString::Printf(TEXT("\n Move Target Location Set"));
84 }
85 else
86 {
87 Description += TEXT("\nMove Target Location NULL");
88 }
89 if(SensesToUse.IsEmpty())
90 {
91 Description += FString::Printf(TEXT("\n SENSES EMPTY"));
92 }
94 {
95 Description += FString::Printf(TEXT("\n DEBUG ACTIVE"));
96 }
97 return Description;
98}

Member Data Documentation

◆ bDebuggingMode

bool UBTT_GetLastKnownLocation::bDebuggingMode = false

◆ Extent

float UBTT_GetLastKnownLocation::Extent = 0.1f

◆ LocationColor

FColor UBTT_GetLastKnownLocation::LocationColor = FColor::Green

◆ LocationInRadiusColor

FColor UBTT_GetLastKnownLocation::LocationInRadiusColor = FColor::Blue

◆ MoveTargetLocation

FBlackboardKeySelector UBTT_GetLastKnownLocation::MoveTargetLocation

◆ Radius

float UBTT_GetLastKnownLocation::Radius = 250.0f

◆ SensesToUse

TArray<EAISense> UBTT_GetLastKnownLocation::SensesToUse = {EAISense::Sight}

◆ TargetEnemy

FBlackboardKeySelector UBTT_GetLastKnownLocation::TargetEnemy

◆ Thickness

float UBTT_GetLastKnownLocation::Thickness = 1.0f

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