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

#include <PatrolPathPoint.h>

Inheritance diagram for APatrolPathPoint:
IPatrolInterface IBaseInterface

Public Member Functions

 APatrolPathPoint ()
 
APatrolPathPointGetNextPatrolPoint (bool &bIsBridgeAvailable) const
 
APatrolPathPointGetPreviousPatrolPoint (bool &bIsBridgeAvailable) const
 
APatrolPathPointGetNextBridgePatrolPoint () const
 
virtual bool GetTimeToWait (float &WaitMin, float &WaitMax) const override
 
virtual AActor * GetNextPatrolPointActor (bool &bIsBridgeAvailable) const override
 
virtual AActor * GetNextBridgePatrolPointActor () const override
 
virtual AActor * GetPreviousPatrolPointActor (bool &bIsBridgeAvailable) const override
 
virtual float GetRadius () const override
 
virtual bool GetIsDeadEnd () const override
 
virtual void SetGravityEnabled (const bool bValue) override
 
virtual FString GetObjectDisplayName () const override
 
virtual FInteractionData GetInteractionData () const override
 
virtual bool GetIsCharacter () const override
 
virtual void OnFinishSpawning () override
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void OnConstruction (const FTransform &Transform) override
 
virtual bool SetInteractionHidden (const EInteractionType Interaction, const bool bValue) override
 
virtual void SetOnlyInteractionVisible (const EInteractionType Interaction) override
 
virtual bool SetInteractionAvailable (const EInteractionType Interaction, const bool bValue) override
 
virtual bool SetInteractionHold (const EInteractionType Interaction, const bool bValue) override
 
virtual TArray< FInteractionTypeGetVisibleInteractions () const override
 
virtual bool GetInteraction (FInteractionType &Type, const EInteractionType Interaction) const override
 
virtual bool GetDefaultInteraction (FInteractionType &Type) const override
 

Protected Attributes

class USceneComponent * SceneRoot
 
class UAIPerceptionStimuliSourceComponent * AIStimuliComponent
 
class UBillboardComponent * PreviewIcon
 
class UArrowComponent * ArrowComponent
 
class UCableComponent * PathCableComponent
 
class UCableComponent * BridgePathCableComponent
 
class USphereComponent * SphereRadiusComponent
 
FInteractionData InteractionData = FInteractionData(EInteractionType::None, EAIStimuliType::PatrolPoint)
 
int32 PathNumber = 0
 
int32 PathStartNumber = 0
 
bool bFinalPoint = false
 
bool bDeadEnd = false
 
bool bUseDirection = false
 
FLinearColor PathColor = FLinearColor::Blue
 
UMaterial * Material
 
int32 PathGroup = 1
 
float Radius = 50.0f
 
bool bCanBridge = false
 
bool bBridgeEnd = false
 
int32 BridgeToPathGroup = 0
 
int32 BridgeToPathNumber = 0
 
FLinearColor BridgePathColor = FLinearColor::Red
 
bool bWaitRandomTime = true
 
float TimeToWaitMin = 0.0f
 
float TimeToWaitMax = 1.0f
 
bool bDebuggingMode = false
 
bool bUpdate = false
 
bool bMoveAllNumbersUp1 = false
 

Private Member Functions

void RemoveVisualizers () const
 
void UpdateVisualizers ()
 
void UpdateAllNumbers ()
 
TArray< APatrolPathPoint * > GetAllPathPoints () const
 
TArray< APatrolPathPoint * > GetAllPathPointsInGroup (const int32 GroupNumber) const
 

Private Attributes

APatrolPathPointNextPathPoint
 
APatrolPathPointNextBridgePathPoint
 
APatrolPathPointPreviousPathPoint
 

Constructor & Destructor Documentation

◆ APatrolPathPoint()

APatrolPathPoint::APatrolPathPoint ( )
17{
18 PrimaryActorTick.bCanEverTick = false;
19
20 SceneRoot = CreateDefaultSubobject<USceneComponent>("Root");
21 RootComponent = SceneRoot;
22 AIStimuliComponent = CreateDefaultSubobject<UAIPerceptionStimuliSourceComponent>("AI Stimuli Source");
23 AIStimuliComponent->RegisterForSense(UAISenseConfig_Sight::StaticClass());
24
25
26 PreviewIcon = CreateDefaultSubobject<UBillboardComponent>("Icon");
27 PreviewIcon->SetupAttachment(SceneRoot);
28 PathCableComponent = CreateDefaultSubobject<UCableComponent>("Path Cable");
29 PathCableComponent->SetupAttachment(SceneRoot);
30 ArrowComponent = CreateDefaultSubobject<UArrowComponent>("Arrow");
31 ArrowComponent->SetupAttachment(SceneRoot);
32 BridgePathCableComponent= CreateDefaultSubobject<UCableComponent>("Path Bridge Cable");
33 BridgePathCableComponent->SetupAttachment(SceneRoot);
34 SphereRadiusComponent = CreateDefaultSubobject<USphereComponent>("Sphere Radius");
35 SphereRadiusComponent->SetupAttachment(SceneRoot);
36 SphereRadiusComponent->InitSphereRadius(Radius);
37 SphereRadiusComponent->ShapeColor = PathColor.ToFColor(true);
38 bDebuggingMode = true;
39
40}
class USphereComponent * SphereRadiusComponent
Definition PatrolPathPoint.h:66
FLinearColor PathColor
Definition PatrolPathPoint.h:84
class UCableComponent * BridgePathCableComponent
Definition PatrolPathPoint.h:64
class UArrowComponent * ArrowComponent
Definition PatrolPathPoint.h:60
class UAIPerceptionStimuliSourceComponent * AIStimuliComponent
Definition PatrolPathPoint.h:54
class UBillboardComponent * PreviewIcon
Definition PatrolPathPoint.h:58
class UCableComponent * PathCableComponent
Definition PatrolPathPoint.h:62
bool bDebuggingMode
Definition PatrolPathPoint.h:112
class USceneComponent * SceneRoot
Definition PatrolPathPoint.h:52
float Radius
Definition PatrolPathPoint.h:90

Member Function Documentation

◆ BeginPlay()

void APatrolPathPoint::BeginPlay ( )
overrideprotectedvirtual
97{
98 Super::BeginPlay();
99 AIStimuliComponent->RegisterWithPerceptionSystem();
101}
void RemoveVisualizers() const
Definition PatrolPathPoint.cpp:130

◆ GetAllPathPoints()

TArray< APatrolPathPoint * > APatrolPathPoint::GetAllPathPoints ( ) const
private
248{
249 TArray<APatrolPathPoint*> PatrolPathPoints;
250 TArray<AActor*> PatrolPathActors;
251 UGameplayStatics::GetAllActorsOfClass(this, GetClass(), PatrolPathActors);
252 if(PatrolPathActors.Num() == 0){return PatrolPathPoints;}
253 for(AActor* PathPointActor : PatrolPathActors)
254 {
255 APatrolPathPoint* PatrolPoint = Cast<APatrolPathPoint>(PathPointActor);
256 if(PatrolPoint != nullptr)
257 {
258 PatrolPathPoints.Add(PatrolPoint);
259 }
260 }
261 return PatrolPathPoints;
262}
Definition PatrolPathPoint.h:13

◆ GetAllPathPointsInGroup()

TArray< APatrolPathPoint * > APatrolPathPoint::GetAllPathPointsInGroup ( const int32 GroupNumber) const
private
265{
266 TArray<APatrolPathPoint*> PatrolPathPointsInGroup;
267 TArray<APatrolPathPoint*> PathPoints = GetAllPathPoints();
268 for(APatrolPathPoint* PathPoint : PathPoints)
269 {
270 if(PathPoint->PathGroup == GroupNumber)
271 {
272 PatrolPathPointsInGroup.Add(PathPoint);
273 }
274 }
275 return PatrolPathPointsInGroup;
276}
TArray< APatrolPathPoint * > GetAllPathPoints() const
Definition PatrolPathPoint.cpp:247

◆ GetDefaultInteraction()

virtual bool APatrolPathPoint::GetDefaultInteraction ( FInteractionType & Type) const
inlineoverrideprotectedvirtual
FInteractionData InteractionData
Definition PatrolPathPoint.h:70
bool GetDefaultInteraction(FInteractionType &Default) const
Definition BaseData.h:473

◆ GetInteraction()

virtual bool APatrolPathPoint::GetInteraction ( FInteractionType & Type,
const EInteractionType Interaction ) const
inlineoverrideprotectedvirtual
Definition Interaction.Build.cs:6
bool GetInteraction(FInteractionType &Type, const EInteractionType Interaction) const
Definition BaseData.h:483

◆ GetInteractionData()

virtual FInteractionData APatrolPathPoint::GetInteractionData ( ) const
inlineoverridevirtual
39{ return InteractionData;};

◆ GetIsCharacter()

virtual bool APatrolPathPoint::GetIsCharacter ( ) const
inlineoverridevirtual
41{return false;};

◆ GetIsDeadEnd()

bool APatrolPathPoint::GetIsDeadEnd ( ) const
overridevirtual

Implements IPatrolInterface.

88{
89 return bDeadEnd;
90}
bool bDeadEnd
Definition PatrolPathPoint.h:80

◆ GetNextBridgePatrolPoint()

APatrolPathPoint * APatrolPathPoint::GetNextBridgePatrolPoint ( ) const
59{
61}
APatrolPathPoint * NextBridgePathPoint
Definition PatrolPathPoint.h:153

◆ GetNextBridgePatrolPointActor()

AActor * APatrolPathPoint::GetNextBridgePatrolPointActor ( ) const
overridevirtual

Implements IPatrolInterface.

77{
79}

◆ GetNextPatrolPoint()

APatrolPathPoint * APatrolPathPoint::GetNextPatrolPoint ( bool & bIsBridgeAvailable) const
43{
44 bIsBridgeAvailable = (NextBridgePathPoint != nullptr);
45 // if(bDeadEnd)
46 // {
47 // return PreviousPathPoint;
48 // }
49 return NextPathPoint;
50}
APatrolPathPoint * NextPathPoint
Definition PatrolPathPoint.h:151

◆ GetNextPatrolPointActor()

AActor * APatrolPathPoint::GetNextPatrolPointActor ( bool & bIsBridgeAvailable) const
overridevirtual

Implements IPatrolInterface.

71{
72 bIsBridgeAvailable = (NextBridgePathPoint != nullptr);
73 return NextPathPoint;
74}

◆ GetObjectDisplayName()

virtual FString APatrolPathPoint::GetObjectDisplayName ( ) const
inlineoverridevirtual
37{return "Patrol Point";};

◆ GetPreviousPatrolPoint()

APatrolPathPoint * APatrolPathPoint::GetPreviousPatrolPoint ( bool & bIsBridgeAvailable) const
53{
54 bIsBridgeAvailable = (NextBridgePathPoint != nullptr);
55 return PreviousPathPoint;
56}
APatrolPathPoint * PreviousPathPoint
Definition PatrolPathPoint.h:155

◆ GetPreviousPatrolPointActor()

AActor * APatrolPathPoint::GetPreviousPatrolPointActor ( bool & bIsBridgeAvailable) const
overridevirtual

Implements IPatrolInterface.

82{
83 bIsBridgeAvailable = (NextBridgePathPoint != nullptr);
84 return PreviousPathPoint;
85}

◆ GetRadius()

virtual float APatrolPathPoint::GetRadius ( ) const
inlineoverridevirtual

Reimplemented from IPatrolInterface.

31{return Radius;};

◆ GetTimeToWait()

bool APatrolPathPoint::GetTimeToWait ( float & WaitMin,
float & WaitMax ) const
overridevirtual

Implements IPatrolInterface.

64{
65 WaitMin = TimeToWaitMin;
66 WaitMax = TimeToWaitMax;
67 return bWaitRandomTime;
68}
bool bWaitRandomTime
Definition PatrolPathPoint.h:105
float TimeToWaitMin
Definition PatrolPathPoint.h:107
float TimeToWaitMax
Definition PatrolPathPoint.h:109

◆ GetVisibleInteractions()

virtual TArray< FInteractionType > APatrolPathPoint::GetVisibleInteractions ( ) const
inlineoverrideprotectedvirtual
TArray< FInteractionType > GetVisibleInteractions() const
Definition BaseData.h:556

◆ OnConstruction()

void APatrolPathPoint::OnConstruction ( const FTransform & Transform)
overrideprotectedvirtual
104{
105 Super::OnConstruction(Transform);
106 ArrowComponent->SetVisibility(bUseDirection);
107 if(bUpdate)
108 {
109 bUpdate = false;
110 UE_LOG(LogAIToolKit,Warning,TEXT("Patrol Points Updated"));
111 }
114 if(Material != nullptr)
115 {
116 UMaterialInstanceDynamic* MatInst = PathCableComponent->CreateDynamicMaterialInstance(0, Material);
117 MatInst->SetVectorParameterValue(FName("Color"), PathColor);
118 UMaterialInstanceDynamic* BridgeMatInst = BridgePathCableComponent->CreateDynamicMaterialInstance(0, Material);
119 BridgeMatInst->SetVectorParameterValue(FName("Color"), BridgePathColor);
120 }
122 {
123 BridgePathCableComponent->SetVisibility(bCanBridge);
124 BridgePathCableComponent->bHiddenInGame = !bCanBridge;
125 }
126 SphereRadiusComponent->SetSphereRadius(Radius);
127 SphereRadiusComponent->ShapeColor = PathColor.ToFColor(true);
128}
FLinearColor BridgePathColor
Definition PatrolPathPoint.h:101
void UpdateAllNumbers()
Definition PatrolPathPoint.cpp:225
UMaterial * Material
Definition PatrolPathPoint.h:86
bool bUpdate
Definition PatrolPathPoint.h:115
bool bCanBridge
Definition PatrolPathPoint.h:93
bool bUseDirection
Definition PatrolPathPoint.h:82
void UpdateVisualizers()
Definition PatrolPathPoint.cpp:159

◆ OnFinishSpawning()

void APatrolPathPoint::OnFinishSpawning ( )
overridevirtual
93{
94}

◆ RemoveVisualizers()

void APatrolPathPoint::RemoveVisualizers ( ) const
private
131{
132 BridgePathCableComponent->SetVisibility(false);
133 BridgePathCableComponent->bHiddenInGame = true;
135 {
136 PreviewIcon->bHiddenInGame = false;
137 PreviewIcon->SetVisibility(true);
138 PathCableComponent->SetVisibility(true);
139 PathCableComponent->bHiddenInGame = false;
140 SphereRadiusComponent->SetVisibility(true);
141 SphereRadiusComponent->bHiddenInGame = false;
142 if(bUseDirection)
143 {
144 ArrowComponent->SetVisibility(true);
145 ArrowComponent->bHiddenInGame = false;
146 }
147 if(bCanBridge && BridgePathCableComponent != nullptr)
148 {
149 BridgePathCableComponent->SetVisibility(true);
150 BridgePathCableComponent->bHiddenInGame = false;
151 }
152 return;
153 }
154 PreviewIcon->DestroyComponent();
155 PathCableComponent->DestroyComponent();
156 ArrowComponent->DestroyComponent();
157}

◆ SetGravityEnabled()

virtual void APatrolPathPoint::SetGravityEnabled ( const bool bValue)
inlineoverridevirtual
35{return;};

◆ SetInteractionAvailable()

virtual bool APatrolPathPoint::SetInteractionAvailable ( const EInteractionType Interaction,
const bool bValue )
inlineoverrideprotectedvirtual
bool SetInteractionAvailable(const EInteractionType Interaction, const bool bValue)
Definition BaseData.h:531

◆ SetInteractionHidden()

virtual bool APatrolPathPoint::SetInteractionHidden ( const EInteractionType Interaction,
const bool bValue )
inlineoverrideprotectedvirtual

Interaction Data Manipulation, so Actors can change there Interaction Data struct from BP

bool SetInteractionHidden(const EInteractionType Interaction, const bool bValue)
Definition BaseData.h:496

◆ SetInteractionHold()

virtual bool APatrolPathPoint::SetInteractionHold ( const EInteractionType Interaction,
const bool bValue )
inlineoverrideprotectedvirtual
bool SetInteractionHold(const EInteractionType Interaction, const bool bValue)
Definition BaseData.h:543

◆ SetOnlyInteractionVisible()

virtual void APatrolPathPoint::SetOnlyInteractionVisible ( const EInteractionType Interaction)
inlineoverrideprotectedvirtual
void SetOnlyInteractionVisible(const EInteractionType Interaction)
Definition BaseData.h:508

◆ UpdateAllNumbers()

void APatrolPathPoint::UpdateAllNumbers ( )
private
226{
228 {
229 const int32 OwnStartPoint = PathStartNumber;
230 TArray<APatrolPathPoint*> PathPoints = GetAllPathPointsInGroup(PathGroup);
231 if(PathPoints.Num() == 0){return;}
232 for(APatrolPathPoint* PathPoint : PathPoints)
233 {
234 if(PathPoint->PathNumber > PathNumber)
235 {
236 if(PathPoint->PathStartNumber > OwnStartPoint || PathPoint->PathStartNumber == PathPoint->PathNumber)
237 {
238 PathPoint->PathStartNumber++;
239 }
240 PathPoint->PathNumber++;
241 }
242 }
243 bMoveAllNumbersUp1 = false;
244 }
245}
int32 PathStartNumber
Definition PatrolPathPoint.h:75
int32 PathNumber
Definition PatrolPathPoint.h:73
bool bMoveAllNumbersUp1
Definition PatrolPathPoint.h:117
int32 PathGroup
Definition PatrolPathPoint.h:88
TArray< APatrolPathPoint * > GetAllPathPointsInGroup(const int32 GroupNumber) const
Definition PatrolPathPoint.cpp:264

◆ UpdateVisualizers()

void APatrolPathPoint::UpdateVisualizers ( )
private
160{
161 TArray<APatrolPathPoint*> PathPoints = GetAllPathPointsInGroup(PathGroup);
162 if(PathPoints.Num() == 0){return;}
163 if(PathCableComponent == nullptr){return;}
164 NextPathPoint = nullptr;
165 NextBridgePathPoint = nullptr;
166 PathCableComponent->SetAttachEndTo(nullptr, FName(""));
167 for(APatrolPathPoint* PathPoint : PathPoints)
168 {
169 if(bFinalPoint)
170 {
171 if(PathPoint->PathNumber == PathStartNumber)
172 {
173 NextPathPoint = PathPoint;
174 PathPoint->PreviousPathPoint = this;
175 PathCableComponent->SetAttachEndTo(PathPoint, FName("PathCableComponent"),FName("Center"));
176 }
177 }
178 else
179 {
180 if(PathPoint->PathNumber == (PathNumber + 1))
181 {
182 NextPathPoint = PathPoint;
183 PathPoint->PreviousPathPoint = this;
184 PathCableComponent->SetAttachEndTo(PathPoint, FName("PathCableComponent"),FName("Center"));
185 }
186 }
187 }
188 if(bCanBridge)
189 {
190 TArray<APatrolPathPoint*> OtherGroupPathPoints = GetAllPathPointsInGroup(BridgeToPathGroup);
191 if(OtherGroupPathPoints.Num() == 0){return;}
192 if(BridgePathCableComponent == nullptr){return;}
193 BridgePathCableComponent->SetAttachEndTo(nullptr, FName(""));
194 for(APatrolPathPoint* OtherGroupPath : OtherGroupPathPoints)
195 {
196 if(OtherGroupPath->PathNumber == BridgeToPathNumber)
197 {
198 NextBridgePathPoint = OtherGroupPath;
199 BridgePathCableComponent->SetAttachEndTo(OtherGroupPath, FName("PathCableComponent"),FName("Center"));
200 //- Set the End of the bridge to be able to go back //
201 OtherGroupPath->bBridgeEnd = true;
202 OtherGroupPath->BridgeToPathGroup = PathGroup;
203 OtherGroupPath->BridgeToPathNumber = PathNumber;
204 // OtherGroupPath->NextBridgePathPoint = this;
205 }
206 }
207 }
208 if(bBridgeEnd)
209 {
210 TArray<APatrolPathPoint*> OtherGroupPathPoints = GetAllPathPointsInGroup(BridgeToPathGroup);
211 if(OtherGroupPathPoints.Num() == 0){return;}
212 if(BridgePathCableComponent == nullptr){return;}
213 BridgePathCableComponent->SetAttachEndTo(nullptr, FName(""));
214 for(APatrolPathPoint* OtherGroupPath : OtherGroupPathPoints)
215 {
216 if(OtherGroupPath->PathNumber == BridgeToPathNumber)
217 {
218 NextBridgePathPoint = OtherGroupPath;
219 BridgePathCableComponent->SetAttachEndTo(OtherGroupPath, FName("PathCableComponent"),FName("Center"));
220 }
221 }
222 }
223}
bool bFinalPoint
Definition PatrolPathPoint.h:77
bool bBridgeEnd
Definition PatrolPathPoint.h:95
int32 BridgeToPathNumber
Definition PatrolPathPoint.h:99
int32 BridgeToPathGroup
Definition PatrolPathPoint.h:97

Member Data Documentation

◆ AIStimuliComponent

class UAIPerceptionStimuliSourceComponent* APatrolPathPoint::AIStimuliComponent
protected

◆ ArrowComponent

class UArrowComponent* APatrolPathPoint::ArrowComponent
protected

◆ bBridgeEnd

bool APatrolPathPoint::bBridgeEnd = false
protected

◆ bCanBridge

bool APatrolPathPoint::bCanBridge = false
protected

◆ bDeadEnd

bool APatrolPathPoint::bDeadEnd = false
protected

◆ bDebuggingMode

bool APatrolPathPoint::bDebuggingMode = false
protected

◆ bFinalPoint

bool APatrolPathPoint::bFinalPoint = false
protected

◆ bMoveAllNumbersUp1

bool APatrolPathPoint::bMoveAllNumbersUp1 = false
protected

◆ BridgePathCableComponent

class UCableComponent* APatrolPathPoint::BridgePathCableComponent
protected

◆ BridgePathColor

FLinearColor APatrolPathPoint::BridgePathColor = FLinearColor::Red
protected

◆ BridgeToPathGroup

int32 APatrolPathPoint::BridgeToPathGroup = 0
protected

◆ BridgeToPathNumber

int32 APatrolPathPoint::BridgeToPathNumber = 0
protected

◆ bUpdate

bool APatrolPathPoint::bUpdate = false
protected

◆ bUseDirection

bool APatrolPathPoint::bUseDirection = false
protected

◆ bWaitRandomTime

bool APatrolPathPoint::bWaitRandomTime = true
protected

◆ InteractionData

◆ Material

UMaterial* APatrolPathPoint::Material
protected

◆ NextBridgePathPoint

APatrolPathPoint* APatrolPathPoint::NextBridgePathPoint
private

◆ NextPathPoint

APatrolPathPoint* APatrolPathPoint::NextPathPoint
private

◆ PathCableComponent

class UCableComponent* APatrolPathPoint::PathCableComponent
protected

◆ PathColor

FLinearColor APatrolPathPoint::PathColor = FLinearColor::Blue
protected

◆ PathGroup

int32 APatrolPathPoint::PathGroup = 1
protected

◆ PathNumber

int32 APatrolPathPoint::PathNumber = 0
protected

◆ PathStartNumber

int32 APatrolPathPoint::PathStartNumber = 0
protected

◆ PreviewIcon

class UBillboardComponent* APatrolPathPoint::PreviewIcon
protected

◆ PreviousPathPoint

APatrolPathPoint* APatrolPathPoint::PreviousPathPoint
private

◆ Radius

float APatrolPathPoint::Radius = 50.0f
protected

◆ SceneRoot

class USceneComponent* APatrolPathPoint::SceneRoot
protected

◆ SphereRadiusComponent

class USphereComponent* APatrolPathPoint::SphereRadiusComponent
protected

◆ TimeToWaitMax

float APatrolPathPoint::TimeToWaitMax = 1.0f
protected

◆ TimeToWaitMin

float APatrolPathPoint::TimeToWaitMin = 0.0f
protected

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