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

#include <AIControllerBase.h>

Inheritance diagram for AAIControllerBase:
IControllerInterface ISaveLoad AAIControllerCore AShipBrainController

Public Member Functions

 AAIControllerBase ()
 
virtual FVector GetPawnLocation () const override
 
virtual void GetControllerViewPoint (FVector &out_Location, FRotator &out_Rotation) const override
 
virtual bool SaveGame () override
 
virtual bool LoadGame () override
 
virtual ETeamAttitude::Type GetTeamAttitudeTowards (const AActor &Other) const override
 
virtual void SetGenericTeamId (const FGenericTeamId &NewTeamID) override
 
virtual FGenericTeamId GetGenericTeamId () const override
 

Protected Member Functions

virtual void BeginPlay () override
 
virtual void OnPossess (APawn *InPawn) override
 
int32 GetTeamID () const
 
void LogDebugError (const FString &Message) const
 
void LogDebugError (const FString &Message, const int32 Value) const
 
void LogDebugError (const FString &Message, const float Value) const
 
void LogDebugWarning (const FString &Message) const
 
void LogDebugWarning (const FString &Message, const int32 Value) const
 
void LogDebugWarning (const FString &Message, const float Value) const
 
void LogDebugMessage (const FString &Message, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const int32 Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const float Value, const bool bWarning=false, const bool bError=false) const
 
void LogDebugMessage (const FString &Message, const bool bValue, const bool bWarning, const bool bError) const
 
void LogOnScreenMessage (const int32 Key, const FString &Message, FColor Color=FColor::Green) const
 
void SetCategoryName (const FLogCategoryBase &Category)
 

Protected Attributes

FGenericTeamId TeamID
 
TObjectPtr< UBehaviorTree > Behaviour = nullptr
 
bool bDebuggingMode = false
 

Private Attributes

FLogCategoryName CategoryName = LogAIControllerBase.GetCategoryName()
 

Constructor & Destructor Documentation

◆ AAIControllerBase()

AAIControllerBase::AAIControllerBase ( )
10{
11 PrimaryActorTick.bCanEverTick = true;
12}

Member Function Documentation

◆ BeginPlay()

void AAIControllerBase::BeginPlay ( )
overrideprotectedvirtual

Reimplemented in AAIControllerCore, and AShipBrainController.

15{
16 Super::BeginPlay();
17
18}

◆ GetControllerViewPoint()

void AAIControllerBase::GetControllerViewPoint ( FVector & out_Location,
FRotator & out_Rotation ) const
overridevirtual

Implements IControllerInterface.

32{
33 GetPlayerViewPoint(out_Location, out_Rotation);
34}

◆ GetGenericTeamId()

virtual FGenericTeamId AAIControllerBase::GetGenericTeamId ( ) const
inlineoverridevirtual
35{return TeamID;};
FGenericTeamId TeamID
Definition AIControllerBase.h:44

◆ GetPawnLocation()

FVector AAIControllerBase::GetPawnLocation ( ) const
overridevirtual

Implements IControllerInterface.

26{
27 return GetPawn()->GetActorLocation();
28
29}

◆ GetTeamAttitudeTowards()

ETeamAttitude::Type AAIControllerBase::GetTeamAttitudeTowards ( const AActor & Other) const
overridevirtual

Reimplemented in AAIControllerCore.

57{
58 if(const APawn* OtherPawn = Cast<APawn>(&Other))
59 {
60 if(const IGenericTeamAgentInterface* TeamAgent = Cast<IGenericTeamAgentInterface>(OtherPawn->GetController()))
61 {
62 // const FGenericTeamId OtherTeamID = TeamAgent->GetGenericTeamId();
63 // const EFactionType OtherPawnFaction = UAIBPLib::GetFactionFromTeamID(OtherTeamID);
64 // bool bSuccess = false;
65 // //- @TODO this should store on Begin, then not have to use the BPLib each time to update //
66 // //- Game State should update any Characters of Relationship Changes
67 //
68 // const FFactionRelationship Relationship = UAIBPLib::GetFactionRelationship(this, Faction, OtherPawnFaction, bSuccess);
69 // if(bSuccess)
70 // {
71 // switch (Relationship.RelationshipStatus)
72 // {
73 // case ERelationshipStatus::Friendly:
74 // case ERelationshipStatus::Allied:
75 // return ETeamAttitude::Friendly;
76 // case ERelationshipStatus::Default:
77 // case ERelationshipStatus::Neutral:
78 // case ERelationshipStatus::UnFriendly:
79 // return ETeamAttitude::Neutral;
80 // case ERelationshipStatus::Hostile:
81 // case ERelationshipStatus::Enemy:
82 // return ETeamAttitude::Hostile;
83 // }
84 // }
85 }
86 }
87 return ETeamAttitude::Neutral;
88}

◆ GetTeamID()

int32 AAIControllerBase::GetTeamID ( ) const
inlineprotected
46{return (TeamID == FGenericTeamId::NoTeam) ? INDEX_NONE : (int32)TeamID;};

◆ LoadGame()

bool AAIControllerBase::LoadGame ( )
overridevirtual

Implements ISaveLoad.

47{
48 const bool bComponentsLoaded = USaveLoadBPLib::LoadAllComponents(this);
49 if(bComponentsLoaded == false)
50 {
51 LogDebugError("Load components Failed");
52 }
53 return true;
54}
void LogDebugError(const FString &Message) const
Definition AIControllerBase.cpp:108
static bool LoadAllComponents(AActor *Actor)
Definition SaveLoadBPLib.cpp:112

◆ LogDebugError() [1/3]

void AAIControllerBase::LogDebugError ( const FString & Message) const
protected
109{
110 TRACE_CPUPROFILER_EVENT_SCOPE(AAIControllerBase::LogDebugError);
111 LogDebugMessage(Message, true, true);
112}
void LogDebugMessage(const FString &Message, const bool bWarning=false, const bool bError=false) const
Definition AIControllerBase.cpp:142

◆ LogDebugError() [2/3]

void AAIControllerBase::LogDebugError ( const FString & Message,
const float Value ) const
protected
120{
121 LogDebugMessage(Message, Value, true, true);
122}

◆ LogDebugError() [3/3]

void AAIControllerBase::LogDebugError ( const FString & Message,
const int32 Value ) const
protected
115{
116 LogDebugMessage(Message, Value, true, true);
117}

◆ LogDebugMessage() [1/4]

void AAIControllerBase::LogDebugMessage ( const FString & Message,
const bool bValue,
const bool bWarning,
const bool bError ) const
protected
194{
195 LogDebugMessage(FString::Printf(TEXT("%s: %s"), *Message, bValue ? *FString("true") : *FString("false")), bWarning, bError);
196}

◆ LogDebugMessage() [2/4]

void AAIControllerBase::LogDebugMessage ( const FString & Message,
const bool bWarning = false,
const bool bError = false ) const
protected
143{
144 TRACE_CPUPROFILER_EVENT_SCOPE(AAIControllerBase::LogDebugMessage);
145 if(bDebuggingMode == false && bError == false){return;}
146 FOutputDevice* OutputDevice = GWarn;
147 if(OutputDevice == nullptr){return;}
148 FString NetModeString;
149 switch(GetWorld()->GetNetMode())
150 {
151 case NM_Standalone:
152 NetModeString = FString("SDL");
153 break;
154 case NM_DedicatedServer:
155 NetModeString = FString("DServer");
156 break;
157 case NM_ListenServer:
158 NetModeString = FString("LServer");
159 break;
160 case NM_Client:
161 NetModeString = FString("Client");
162 break;
163 default:
164 NetModeString = FString("Unknown");
165 break;
166 }
167 const FString FullMessage = FString::Printf(TEXT("%s: %s::%s"), *NetModeString, *GetName(), *Message);
168 if(bError)
169 {
170 OutputDevice->Log(CategoryName, ELogVerbosity::Error, FullMessage);
171 }
172 else if(bWarning)
173 {
174 OutputDevice->Log(CategoryName, ELogVerbosity::Warning, FullMessage);
175 }
176 else
177 {
178 OutputDevice->Log(CategoryName, ELogVerbosity::Log, FullMessage);
179 }
180
181}
bool bDebuggingMode
Definition AIControllerBase.h:53
FLogCategoryName CategoryName
Definition AIControllerBase.h:71

◆ LogDebugMessage() [3/4]

void AAIControllerBase::LogDebugMessage ( const FString & Message,
const float Value,
const bool bWarning = false,
const bool bError = false ) const
protected
189{
190 LogDebugMessage(FString::Printf(TEXT("%s: %f"), *Message, Value), bWarning, bError);
191}

◆ LogDebugMessage() [4/4]

void AAIControllerBase::LogDebugMessage ( const FString & Message,
const int32 Value,
const bool bWarning = false,
const bool bError = false ) const
protected
184{
185 LogDebugMessage(FString::Printf(TEXT("%s: %i"), *Message, Value), bWarning, bError);
186}

◆ LogDebugWarning() [1/3]

void AAIControllerBase::LogDebugWarning ( const FString & Message) const
protected
125{
126 TRACE_CPUPROFILER_EVENT_SCOPE(AAIControllerBase::LogDebugWarning);
127 LogDebugMessage(Message, true);
128}
void LogDebugWarning(const FString &Message) const
Definition AIControllerBase.cpp:124

◆ LogDebugWarning() [2/3]

void AAIControllerBase::LogDebugWarning ( const FString & Message,
const float Value ) const
protected
137{
138 TRACE_CPUPROFILER_EVENT_SCOPE(AAIControllerBase::LogDebugWarning);
139 LogDebugMessage(Message, Value, true);
140}

◆ LogDebugWarning() [3/3]

void AAIControllerBase::LogDebugWarning ( const FString & Message,
const int32 Value ) const
protected
131{
132 TRACE_CPUPROFILER_EVENT_SCOPE(AAIControllerBase::LogDebugWarning);
133 LogDebugMessage(Message, Value, true);
134}

◆ LogOnScreenMessage()

void AAIControllerBase::LogOnScreenMessage ( const int32 Key,
const FString & Message,
FColor Color = FColor::Green ) const
protected
199{
200 TRACE_CPUPROFILER_EVENT_SCOPE(AAIControllerBase::LogOnScreenMessage);
202 {
203 GEngine->AddOnScreenDebugMessage(Key, 2.0f, Color,
204 FString::Printf(TEXT(" %s - in %s of %s"), ToCStr(Message), ToCStr(GetName()), ToCStr(GetOwner()->GetName())));
205 }
206}
void LogOnScreenMessage(const int32 Key, const FString &Message, FColor Color=FColor::Green) const
Definition AIControllerBase.cpp:198

◆ OnPossess()

void AAIControllerBase::OnPossess ( APawn * InPawn)
overrideprotectedvirtual

Reimplemented in AAIControllerCore, and AShipBrainController.

21{
22 Super::OnPossess(InPawn);
23}

◆ SaveGame()

bool AAIControllerBase::SaveGame ( )
overridevirtual

Implements ISaveLoad.

37{
38 const bool bComponentsSaved = USaveLoadBPLib::SaveAllComponents(this);
39 if(bComponentsSaved == false)
40 {
41 LogDebugError("Save components Failed");
42 }
43 return true;
44}
static bool SaveAllComponents(AActor *Actor)
Definition SaveLoadBPLib.cpp:107

◆ SetCategoryName()

void AAIControllerBase::SetCategoryName ( const FLogCategoryBase & Category)
inlineprotected
68{CategoryName = Category.GetCategoryName();};

◆ SetGenericTeamId()

void AAIControllerBase::SetGenericTeamId ( const FGenericTeamId & NewTeamID)
overridevirtual
91{
92 if(HasAuthority())
93 {
94 const FGenericTeamId OldTeamID = TeamID;
95
96 // MARK_PROPERTY_DIRTY_FROM_NAME(ThisClass, MyTeamID, this);
97 TeamID = NewTeamID;
98 if(bDebuggingMode){ UE_LOG(LogTemp, Error, TEXT("team %i"), NewTeamID.GetId());}
99
100 // ConditionalBroadcastTeamChanged(this, OldTeamID, NewTeamID);
101 }
102 else
103 {
104 if(bDebuggingMode){UE_LOG(LogTemp, Error, TEXT("Cannot set team for %s on non-authority"), *GetPathName(this));}
105 }
106}

Member Data Documentation

◆ bDebuggingMode

bool AAIControllerBase::bDebuggingMode = false
protected

◆ Behaviour

TObjectPtr<UBehaviorTree> AAIControllerBase::Behaviour = nullptr
protected

◆ CategoryName

FLogCategoryName AAIControllerBase::CategoryName = LogAIControllerBase.GetCategoryName()
private

◆ TeamID

FGenericTeamId AAIControllerBase::TeamID
protected

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