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

#include <AdvancedAIPerceptionComponent.h>

Inheritance diagram for UAdvancedAIPerceptionComponent:

Public Member Functions

UAISenseConfig * GetPerceptionSenseConfig (const TSubclassOf< UAISense > SenseClass)
 
bool SetPerceptionSenseConfig (const TSubclassOf< UAISense > SenseClass, const bool DetectEnemies, const bool DetectNeutrals, const bool DetectFriendlies)
 
virtual void GetNeutralActors (TArray< AActor * > &OutActors) const
 
void GetNeutralActorsBySense (TSubclassOf< UAISense > SenseToFilterBy, TArray< AActor * > &OutActors) const
 
void GetPerceivedNeutralActors (TArray< AActor * > &OutActors) const
 
void GetPerceivedNeutralActorsBySense (const TSubclassOf< UAISense > SenseToUse, TArray< AActor * > &OutActors) const
 
virtual void GetFriendlyActors (TArray< AActor * > &OutActors) const
 
void GetFriendlyActorsBySense (TSubclassOf< UAISense > SenseToFilterBy, TArray< AActor * > &OutActors) const
 
void GetPerceivedFriendlyActors (TArray< AActor * > &OutActors) const
 
void GetPerceivedFriendlyActorsBySense (const TSubclassOf< UAISense > SenseToUse, TArray< AActor * > &OutActors) const
 
AAIController * GetOwnerController () const
 
float GetMaxAge (const TSubclassOf< UAISense > SenseClass)
 
bool SetMaxAge (const TSubclassOf< UAISense > SenseClass, const float MaxAge)
 
bool SetSightMaxAge (const float MaxAge)
 
bool SetHearingMaxAge (const float MaxAge)
 
float GetSightRange ()
 
bool SetSightRange (const float SightRange)
 
float GetLoseSightRange ()
 
bool SetLoseSightRange (const float LoseSightRange)
 
float GetVisionAngle ()
 
bool SetVisionAngle (const float VisionAngle)
 
float GetAutoSuccessRange ()
 
bool SetAutoSuccessRange (const float AutoSuccessRange)
 
float GetPOVBackwardOffset ()
 
bool SetPOVBackwardOffset (const float POVBackwardOffset)
 
float GetNearClippingRadius ()
 
bool SetNearClippingRadius (const float NearClippingRadius)
 
float GetHearingRange ()
 
bool SetHearingRange (const float HearingRange)
 
FAISenseAffiliationFilter GetDetectionByAffiliation (const TSubclassOf< UAISense > SenseClass)
 
class UAISenseConfig_Sight * GetSightConfig ()
 
class UAISenseConfig_Hearing * GetHearingConfig ()
 
class UAISenseConfig_ActionsGetActionsConfig ()
 
class UAISenseConfig_Damage * GetDamageConfig ()
 
class UAISenseConfig_Prediction * GetPredictionConfig ()
 
class UAISenseConfig_Team * GetTeamConfig ()
 
class UAISenseConfig_Touch * GetTouchConfig ()
 

Public Attributes

FOnForgottenStimulus OnForgottenStimulus
 

Protected Member Functions

virtual void HandleExpiredStimulus (FAIStimulus &StimulusStore) override
 
bool ForgetActorBP (AActor *ActorToForget)
 
bool SetDominantSenseBP (const TSubclassOf< UAISense > SenseClass)
 
TSubclassOf< UAISense > GetDominantSenseBP () const
 
const AActor * GetBodyActorBP () const
 
AActor * GetMutableBodyActorBP ()
 
void GetLocationAndDirectionBP (FVector &Location, FVector &Direction) const
 
FGenericTeamId GetTeamIdentifierBP () const
 
void UpdatePerceptionAllowListBP (const TSubclassOf< UAISense > SenseClass, const bool bNewValue)
 
float GetYoungestStimulusAgeBP (AActor *Source) const
 
bool HasAnyActiveStimulusBP (const AActor *Source) const
 
bool HasAnyCurrentStimulusBP (const AActor *Source) const
 
bool HasActiveStimulusBP (const AActor *Source, const TSubclassOf< UAISense > SenseClass) const
 

Member Function Documentation

◆ ForgetActorBP()

bool UAdvancedAIPerceptionComponent::ForgetActorBP ( AActor * ActorToForget)
protected
44{
45 if(ActorToForget == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("ActorToForget Null in ForgetActorBP, Advanced AI Perception"));return false;}
46 ForgetActor(ActorToForget);
47 return true;
48}

◆ GetActionsConfig()

UAISenseConfig_Actions * UAdvancedAIPerceptionComponent::GetActionsConfig ( )
270{
271 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Actions::StaticClass());
272 if(Config == nullptr)
273 {
274 UE_LOG(LogAIToolKit, Error, TEXT("GetActionsConfig: Config Null, Advanced AI Perception"));
275 return nullptr;
276 }
277 UAISenseConfig_Actions* ConfigActions = Cast<UAISenseConfig_Actions>(Config);
278 if(ConfigActions == nullptr)
279 {
280 UE_LOG(LogAIToolKit, Error, TEXT("GetActionsConfig: ConfigHearing Null, Advanced AI Perception"));
281 }
282 return ConfigActions;
283}
Definition AISenseConfig_Actions.h:17
UAISenseConfig * GetPerceptionSenseConfig(const TSubclassOf< UAISense > SenseClass)
Definition AdvancedAIPerceptionComponent.cpp:62

◆ GetAutoSuccessRange()

float UAdvancedAIPerceptionComponent::GetAutoSuccessRange ( )
737{
738 if(GetSightConfig() != nullptr)
739 {
740 return GetSightConfig()->AutoSuccessRangeFromLastSeenLocation;
741 }
742 UE_LOG(LogAIToolKit, Error, TEXT("GetAutoSuccessRange: Null, Advanced AI Perception"));
743 return 0.0f;
744}
class UAISenseConfig_Sight * GetSightConfig()
Definition AdvancedAIPerceptionComponent.cpp:237

◆ GetBodyActorBP()

const AActor * UAdvancedAIPerceptionComponent::GetBodyActorBP ( ) const
protected
518{
519 return GetBodyActor();
520}

◆ GetDamageConfig()

UAISenseConfig_Damage * UAdvancedAIPerceptionComponent::GetDamageConfig ( )
286{
287 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Damage::StaticClass());
288 if(Config == nullptr)
289 {
290 UE_LOG(LogAIToolKit, Error, TEXT("GetDamageConfig: Config Null, Advanced AI Perception"));
291 return nullptr;
292 }
293 UAISenseConfig_Damage* ConfigDamage = Cast<UAISenseConfig_Damage>(Config);
294 if(ConfigDamage == nullptr)
295 {
296 UE_LOG(LogAIToolKit, Error, TEXT("GetDamageConfig: ConfigHearing Null, Advanced AI Perception"));
297 }
298 return ConfigDamage;
299}

◆ GetDetectionByAffiliation()

FAISenseAffiliationFilter UAdvancedAIPerceptionComponent::GetDetectionByAffiliation ( const TSubclassOf< UAISense > SenseClass)
195{
196 const FAISenseAffiliationFilter DetectionByAffiliation = {};
197 if(SenseClass == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in GetDetectionByAffiliation, Advanced AI Perception"));return DetectionByAffiliation;}
198 UAISenseConfig* Config = GetPerceptionSenseConfig(SenseClass);
199 const UAISenseConfig_Sight* SightSenseConfig = Cast<UAISenseConfig_Sight>(Config);
200 if(SightSenseConfig)
201 {
202 return SightSenseConfig->DetectionByAffiliation;
203 }
204 const UAISenseConfig_Hearing* HearingSenseConfig = Cast<UAISenseConfig_Hearing>(Config);
205 if(HearingSenseConfig)
206 {
207 return HearingSenseConfig->DetectionByAffiliation;
208 }
209 // const UAISenseConfig_Actions* ActionsSenseConfig = Cast<UAISenseConfig_Actions>(Config);
210 // if(ActionsSenseConfig)
211 // {
212 // return ActionsSenseConfig->DetectionByAffiliation;
213 // }
214 // const UAISenseConfig_Damage* DamageSenseConfig = Cast<UAISenseConfig_Damage>(Config);
215 // if(DamageSenseConfig)
216 // {
217 // return DamageSenseConfig->DetectionByAffiliation;
218 // }
219 // const UAISenseConfig_Prediction* PredictionSenseConfig = Cast<UAISenseConfig_Prediction>(Config);
220 // if(PredictionSenseConfig)
221 // {
222 // return PredictionSenseConfig->DetectionByAffiliation;
223 // }
224 // const UAISenseConfig_Team* TeamSenseConfig = Cast<UAISenseConfig_Team>(Config);
225 // if(TeamSenseConfig)
226 // {
227 // return TeamSenseConfig->DetectionByAffiliation;
228 // }
229 // const UAISenseConfig_Touch* TouchSenseConfig = Cast<UAISenseConfig_Touch>(Config);
230 // if(TouchSenseConfig)
231 // {
232 // return TouchSenseConfig->DetectionByAffiliation;
233 // }
234 return DetectionByAffiliation;
235}

◆ GetDominantSenseBP()

TSubclassOf< UAISense > UAdvancedAIPerceptionComponent::GetDominantSenseBP ( ) const
protected
51{
52 return GetDominantSense();
53}

◆ GetFriendlyActors()

void UAdvancedAIPerceptionComponent::GetFriendlyActors ( TArray< AActor * > & OutActors) const
virtual
423{
424 if(GetOwnerController() == nullptr)
425 {
426 UE_LOG(LogAIToolKit, Warning, TEXT("UAdvancedAIPerceptionComponent::GetFriendlyActors called with an invalid or yet unregistered sense. Bailing out."));
427 return;
428 }
429 const bool bDeadDataFound = GetFilteredActors([this](const FActorPerceptionInfo& ActorPerceptionInfo) {
430 return (
431 (UAIBPLib::GetAttitudeToActor(GetOwnerController()->GetGenericTeamId(), ActorPerceptionInfo.Target.Get()) == ETeamAttitude::Friendly) &&
432 ActorPerceptionInfo.HasAnyKnownStimulus());
433 }, OutActors);
434
435 if (bDeadDataFound)
436 {
437 FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
438 FSimpleDelegateGraphTask::FDelegate::CreateUObject(const_cast<UAdvancedAIPerceptionComponent*>(this), &UAdvancedAIPerceptionComponent::RemoveDeadData),
439 GET_STATID(STAT_FSimpleDelegateGraphTask_RequestingRemovalOfDeadPerceptionData), NULL, ENamedThreads::GameThread);
440 }
441}
static ETeamAttitude::Type GetAttitudeToActor(const FGenericTeamId &OwnerID, const AActor *TargetActor, bool &bSuccess)
Definition AIBPLib.cpp:369
Definition AdvancedAIPerceptionComponent.h:15
AAIController * GetOwnerController() const
Definition AdvancedAIPerceptionComponent.h:50

◆ GetFriendlyActorsBySense()

void UAdvancedAIPerceptionComponent::GetFriendlyActorsBySense ( TSubclassOf< UAISense > SenseToFilterBy,
TArray< AActor * > & OutActors ) const
445{
446 if(GetOwnerController() == nullptr)
447 {
448 UE_LOG(LogAIToolKit, Warning, TEXT("UAdvancedAIPerceptionComponent::GetNeutralActorsBySense called with an invalid or yet unregistered sense. Bailing out."));
449 return;
450 }
451 const FAISenseID SenseIdFilter = UAISense::GetSenseID(SenseToFilterBy);
452
453 if(SenseIdFilter == FAISenseID::InvalidID())
454 {
455 UE_LOG(LogAIToolKit, Warning, TEXT("UAdvancedAIPerceptionComponent::GetNeutralActorsBySense called with an invalid or yet unregistered sense. Bailing out."));
456 return;
457 }
458
459 const bool bDeadDataFound = GetFilteredActors([SenseIdFilter, this](const FActorPerceptionInfo& ActorPerceptionInfo) {
460 return (UAIBPLib::GetAttitudeToActor(GetOwnerController()->GetGenericTeamId(), ActorPerceptionInfo.Target.Get()) == ETeamAttitude::Friendly) &&
461 ActorPerceptionInfo.HasKnownStimulusOfSense(SenseIdFilter);
462 }, OutActors);
463
464 if (bDeadDataFound)
465 {
466 FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
467 FSimpleDelegateGraphTask::FDelegate::CreateUObject(const_cast<UAdvancedAIPerceptionComponent*>(this), &UAdvancedAIPerceptionComponent::RemoveDeadData),
468 GET_STATID(STAT_FSimpleDelegateGraphTask_RequestingRemovalOfDeadPerceptionData), NULL, ENamedThreads::GameThread);
469 }
470}

◆ GetHearingConfig()

UAISenseConfig_Hearing * UAdvancedAIPerceptionComponent::GetHearingConfig ( )
254{
255 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Hearing::StaticClass());
256 if(Config == nullptr)
257 {
258 UE_LOG(LogAIToolKit, Error, TEXT("GetHearingConfig: Config Null, Advanced AI Perception"));
259 return nullptr;
260 }
261 UAISenseConfig_Hearing* ConfigHearing = Cast<UAISenseConfig_Hearing>(Config);
262 if(ConfigHearing == nullptr)
263 {
264 UE_LOG(LogAIToolKit, Error, TEXT("GetHearingConfig: ConfigHearing Null, Advanced AI Perception"));
265 }
266 return ConfigHearing;
267}

◆ GetHearingRange()

float UAdvancedAIPerceptionComponent::GetHearingRange ( )
821{
822 if(GetHearingConfig() != nullptr)
823 {
824 return GetHearingConfig()->HearingRange;
825 }
826 UE_LOG(LogAIToolKit, Error, TEXT("GetHearingConfig: Null, Advanced AI Perception"));
827 return 0.0f;
828}
class UAISenseConfig_Hearing * GetHearingConfig()
Definition AdvancedAIPerceptionComponent.cpp:253

◆ GetLocationAndDirectionBP()

void UAdvancedAIPerceptionComponent::GetLocationAndDirectionBP ( FVector & Location,
FVector & Direction ) const
protected
74{
75 GetLocationAndDirection(Location, Direction);
76}

◆ GetLoseSightRange()

float UAdvancedAIPerceptionComponent::GetLoseSightRange ( )
684{
685 if(GetSightConfig() != nullptr)
686 {
687 return GetSightConfig()->LoseSightRadius;
688 }
689 UE_LOG(LogAIToolKit, Error, TEXT("GetLoseSightRange: Null, Advanced AI Perception"));
690 return 0.0f;
691}

◆ GetMaxAge()

float UAdvancedAIPerceptionComponent::GetMaxAge ( const TSubclassOf< UAISense > SenseClass)
528{
529 if(SenseClass == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in GetMaxAge, Advanced AI Perception"));return 0.0f;}
530 UAISenseConfig* Config = GetPerceptionSenseConfig(SenseClass);
531 const UAISenseConfig_Sight* SightSenseConfig = Cast<UAISenseConfig_Sight>(Config);
532 if(SightSenseConfig)
533 {
534 return SightSenseConfig->GetMaxAge();
535 }
536 const UAISenseConfig_Hearing* HearingSenseConfig = Cast<UAISenseConfig_Hearing>(Config);
537 if(HearingSenseConfig)
538 {
539 return HearingSenseConfig->GetMaxAge();
540 }
541 const UAISenseConfig_Actions* ActionsSenseConfig = Cast<UAISenseConfig_Actions>(Config);
542 if(ActionsSenseConfig)
543 {
544 return ActionsSenseConfig->GetMaxAge();
545 }
546 const UAISenseConfig_Damage* DamageSenseConfig = Cast<UAISenseConfig_Damage>(Config);
547 if(DamageSenseConfig)
548 {
549 return DamageSenseConfig->GetMaxAge();
550 }
551 const UAISenseConfig_Prediction* PredictionSenseConfig = Cast<UAISenseConfig_Prediction>(Config);
552 if(PredictionSenseConfig)
553 {
554 return PredictionSenseConfig->GetMaxAge();
555 }
556 const UAISenseConfig_Team* TeamSenseConfig = Cast<UAISenseConfig_Team>(Config);
557 if(TeamSenseConfig)
558 {
559 return TeamSenseConfig->GetMaxAge();
560 }
561 const UAISenseConfig_Touch* TouchSenseConfig = Cast<UAISenseConfig_Touch>(Config);
562 if(TouchSenseConfig)
563 {
564 return TouchSenseConfig->GetMaxAge();
565 }
566 UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in GetMaxAge, Advanced AI Perception"));
567 return 0.0f;
568}

◆ GetMutableBodyActorBP()

AActor * UAdvancedAIPerceptionComponent::GetMutableBodyActorBP ( )
protected
523{
524 return GetMutableBodyActor();
525}

◆ GetNearClippingRadius()

float UAdvancedAIPerceptionComponent::GetNearClippingRadius ( )
790{
791#if ENGINE_MINOR_VERSION >= 27 || ENGINE_MAJOR_VERSION >= 5
792 if(GetSightConfig() != nullptr)
793 {
794 return GetSightConfig()->NearClippingRadius;
795 }
796 UE_LOG(LogAIToolKit, Error, TEXT("GetNearClippingRadius: Null, Advanced AI Perception"));
797#else
798 UE_LOG(LogTemp, Error, TEXT("GetPOVBackwardOffset: Requires UE4.27+"));
799#endif
800 return 0.0f;
801}

◆ GetNeutralActors()

void UAdvancedAIPerceptionComponent::GetNeutralActors ( TArray< AActor * > & OutActors) const
virtual
372{
373 if(GetOwnerController() == nullptr)
374 {
375 UE_LOG(LogAIToolKit, Warning, TEXT("UAdvancedAIPerceptionComponent::GetNeutralActors called with an invalid or yet unregistered sense. Bailing out."));
376 return;
377 }
378 const bool bDeadDataFound = GetFilteredActors([this](const FActorPerceptionInfo& ActorPerceptionInfo) {
379 return (
380 (UAIBPLib::GetAttitudeToActor(GetOwnerController()->GetGenericTeamId(), ActorPerceptionInfo.Target.Get()) == ETeamAttitude::Neutral) &&
381 ActorPerceptionInfo.HasAnyKnownStimulus());
382 }, OutActors);
383
384 if (bDeadDataFound)
385 {
386 FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
387 FSimpleDelegateGraphTask::FDelegate::CreateUObject(const_cast<UAdvancedAIPerceptionComponent*>(this), &UAdvancedAIPerceptionComponent::RemoveDeadData),
388 GET_STATID(STAT_FSimpleDelegateGraphTask_RequestingRemovalOfDeadPerceptionData), NULL, ENamedThreads::GameThread);
389 }
390}

◆ GetNeutralActorsBySense()

void UAdvancedAIPerceptionComponent::GetNeutralActorsBySense ( TSubclassOf< UAISense > SenseToFilterBy,
TArray< AActor * > & OutActors ) const
394{
395 if(GetOwnerController() == nullptr)
396 {
397 UE_LOG(LogAIToolKit, Warning, TEXT("UAdvancedAIPerceptionComponent::GetNeutralActorsBySense called with an invalid or yet unregistered sense. Bailing out."));
398 return;
399 }
400 const FAISenseID SenseIdFilter = UAISense::GetSenseID(SenseToFilterBy);
401
402 if(SenseIdFilter == FAISenseID::InvalidID())
403 {
404 UE_LOG(LogAIToolKit, Warning, TEXT("UAdvancedAIPerceptionComponent::GetNeutralActorsBySense called with an invalid or yet unregistered sense. Bailing out."));
405 return;
406 }
407
408 const bool bDeadDataFound = GetFilteredActors([SenseIdFilter, this](const FActorPerceptionInfo& ActorPerceptionInfo) {
409 return (UAIBPLib::GetAttitudeToActor(GetOwnerController()->GetGenericTeamId(), ActorPerceptionInfo.Target.Get()) == ETeamAttitude::Neutral) &&
410 ActorPerceptionInfo.HasKnownStimulusOfSense(SenseIdFilter);
411 }, OutActors);
412
413 if (bDeadDataFound)
414 {
415 FSimpleDelegateGraphTask::CreateAndDispatchWhenReady(
416 FSimpleDelegateGraphTask::FDelegate::CreateUObject(const_cast<UAdvancedAIPerceptionComponent*>(this), &UAdvancedAIPerceptionComponent::RemoveDeadData),
417 GET_STATID(STAT_FSimpleDelegateGraphTask_RequestingRemovalOfDeadPerceptionData), NULL, ENamedThreads::GameThread);
418 }
419}

◆ GetOwnerController()

AAIController * UAdvancedAIPerceptionComponent::GetOwnerController ( ) const
inline
50{return AIOwner;};

◆ GetPerceivedFriendlyActors()

void UAdvancedAIPerceptionComponent::GetPerceivedFriendlyActors ( TArray< AActor * > & OutActors) const
504{
505 return GetFriendlyActors(OutActors);
506}
virtual void GetFriendlyActors(TArray< AActor * > &OutActors) const
Definition AdvancedAIPerceptionComponent.cpp:422

◆ GetPerceivedFriendlyActorsBySense()

void UAdvancedAIPerceptionComponent::GetPerceivedFriendlyActorsBySense ( const TSubclassOf< UAISense > SenseToUse,
TArray< AActor * > & OutActors ) const
510{
511 return GetFriendlyActorsBySense(SenseToUse, OutActors);
512}
void GetFriendlyActorsBySense(TSubclassOf< UAISense > SenseToFilterBy, TArray< AActor * > &OutActors) const
Definition AdvancedAIPerceptionComponent.cpp:443

◆ GetPerceivedNeutralActors()

void UAdvancedAIPerceptionComponent::GetPerceivedNeutralActors ( TArray< AActor * > & OutActors) const
493{
494 return GetNeutralActors(OutActors);
495}
virtual void GetNeutralActors(TArray< AActor * > &OutActors) const
Definition AdvancedAIPerceptionComponent.cpp:371

◆ GetPerceivedNeutralActorsBySense()

void UAdvancedAIPerceptionComponent::GetPerceivedNeutralActorsBySense ( const TSubclassOf< UAISense > SenseToUse,
TArray< AActor * > & OutActors ) const
499{
500 return GetNeutralActorsBySense(SenseToUse, OutActors);
501}
void GetNeutralActorsBySense(TSubclassOf< UAISense > SenseToFilterBy, TArray< AActor * > &OutActors) const
Definition AdvancedAIPerceptionComponent.cpp:392

◆ GetPerceptionSenseConfig()

UAISenseConfig * UAdvancedAIPerceptionComponent::GetPerceptionSenseConfig ( const TSubclassOf< UAISense > SenseClass)
63{
64 const FAISenseID ID = UAISense::GetSenseID(SenseClass);
65 if(ID.IsValid())
66 {
67 return GetSenseConfig(ID);
68 }
69 UE_LOG(LogAIToolKit, Error, TEXT("GetSenseID Null in GetPerceptionSenseConfig, Advanced AI Perception"));
70 return nullptr;
71}

◆ GetPOVBackwardOffset()

float UAdvancedAIPerceptionComponent::GetPOVBackwardOffset ( )
760{
761#if ENGINE_MINOR_VERSION >= 27 || ENGINE_MAJOR_VERSION >= 5
762 if(GetSightConfig() != nullptr)
763 {
764 return GetSightConfig()->PointOfViewBackwardOffset;
765 }
766 UE_LOG(LogAIToolKit, Error, TEXT("GetAutoSuccessRange: Null, Advanced AI Perception"));
767#else
768 UE_LOG(LogTemp, Error, TEXT("GetPOVBackwardOffset: Requires UE4.27+"));
769#endif
770 return 0.0f;
771}

◆ GetPredictionConfig()

UAISenseConfig_Prediction * UAdvancedAIPerceptionComponent::GetPredictionConfig ( )
302{
303 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Prediction::StaticClass());
304 if(Config == nullptr)
305 {
306 UE_LOG(LogAIToolKit, Error, TEXT("GetPredictionConfig: Config Null, Advanced AI Perception"));
307 return nullptr;
308 }
309 UAISenseConfig_Prediction* ConfigPrediction = Cast<UAISenseConfig_Prediction>(Config);
310 if(ConfigPrediction == nullptr)
311 {
312 UE_LOG(LogAIToolKit, Error, TEXT("GetPredictionConfig: ConfigHearing Null, Advanced AI Perception"));
313 }
314 return ConfigPrediction;
315}

◆ GetSightConfig()

UAISenseConfig_Sight * UAdvancedAIPerceptionComponent::GetSightConfig ( )
238{
239 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Sight::StaticClass());
240 if(Config == nullptr)
241 {
242 UE_LOG(LogAIToolKit, Error, TEXT("GetSightConfig: Config Null, Advanced AI Perception"));
243 return nullptr;
244 }
245 UAISenseConfig_Sight* ConfigSight = Cast<UAISenseConfig_Sight>(Config);
246 if(ConfigSight == nullptr)
247 {
248 UE_LOG(LogAIToolKit, Error, TEXT("GetSightConfig: ConfigSight Null, Advanced AI Perception"));
249 }
250 return ConfigSight;
251}

◆ GetSightRange()

float UAdvancedAIPerceptionComponent::GetSightRange ( )
657{
658 if(GetSightConfig() != nullptr)
659 {
660 return GetSightConfig()->SightRadius;
661 }
662 UE_LOG(LogAIToolKit, Error, TEXT("GetSightRange: Null, Advanced AI Perception"));
663 return 0.0f;
664}

◆ GetTeamConfig()

UAISenseConfig_Team * UAdvancedAIPerceptionComponent::GetTeamConfig ( )
318{
319 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Team::StaticClass());
320 if(Config == nullptr)
321 {
322 UE_LOG(LogAIToolKit, Error, TEXT("GetTeamConfig: Config Null, Advanced AI Perception"));
323 return nullptr;
324 }
325 UAISenseConfig_Team* ConfigTeam = Cast<UAISenseConfig_Team>(Config);
326 if(ConfigTeam == nullptr)
327 {
328 UE_LOG(LogAIToolKit, Error, TEXT("GetTeamConfig: ConfigHearing Null, Advanced AI Perception"));
329 }
330 return ConfigTeam;
331}

◆ GetTeamIdentifierBP()

FGenericTeamId UAdvancedAIPerceptionComponent::GetTeamIdentifierBP ( ) const
protected
79{
80 return GetTeamIdentifier();
81}

◆ GetTouchConfig()

UAISenseConfig_Touch * UAdvancedAIPerceptionComponent::GetTouchConfig ( )
334{
335 UAISenseConfig* Config = GetPerceptionSenseConfig(UAISense_Touch::StaticClass());
336 if(Config == nullptr)
337 {
338 UE_LOG(LogAIToolKit, Error, TEXT("GetTouchConfig: Config Null, Advanced AI Perception"));
339 return nullptr;
340 }
341 UAISenseConfig_Touch* ConfigTouch = Cast<UAISenseConfig_Touch>(Config);
342 if(ConfigTouch == nullptr)
343 {
344 UE_LOG(LogAIToolKit, Error, TEXT("GetTouchConfig: ConfigHearing Null, Advanced AI Perception"));
345 }
346 return ConfigTouch;
347}

◆ GetVisionAngle()

float UAdvancedAIPerceptionComponent::GetVisionAngle ( )
713{
714 if(GetSightConfig() != nullptr)
715 {
716 return GetSightConfig()->PeripheralVisionAngleDegrees;
717 }
718 UE_LOG(LogAIToolKit, Error, TEXT("GetVisionAngle: Null, Advanced AI Perception"));
719 return 0.0f;
720}

◆ GetYoungestStimulusAgeBP()

float UAdvancedAIPerceptionComponent::GetYoungestStimulusAgeBP ( AActor * Source) const
protected
102{
103 if(Source != nullptr)
104 {
105 const AActor& ActorReference = *Source;
106 return GetYoungestStimulusAge(ActorReference);
107 }
108 UE_LOG(LogAIToolKit, Error, TEXT("Source Null in GetYoungestStimulusAgeBP, Advanced AI Perception"));
109 return 0.0f;
110}

◆ HandleExpiredStimulus()

void UAdvancedAIPerceptionComponent::HandleExpiredStimulus ( FAIStimulus & StimulusStore)
overrideprotectedvirtual
39{
40 OnForgottenStimulus.Broadcast(StimulusStore);
41}
FOnForgottenStimulus OnForgottenStimulus
Definition AdvancedAIPerceptionComponent.h:20

◆ HasActiveStimulusBP()

bool UAdvancedAIPerceptionComponent::HasActiveStimulusBP ( const AActor * Source,
const TSubclassOf< UAISense > SenseClass ) const
protected
136{
137 const FAISenseID ID = UAISense::GetSenseID(SenseClass);
138 if(ID.IsValid() && GetSenseConfig(ID) != nullptr)
139 {
140 if(Source != nullptr)
141 {
142 const AActor& ActorReference = *Source;
143 return HasActiveStimulus(ActorReference, ID);
144 }
145 UE_LOG(LogAIToolKit, Error, TEXT("Source Null in HasAnyCurrentStimulusBP, Advanced AI Perception"));
146 }
147 UE_LOG(LogAIToolKit, Error, TEXT("ID.IsValid GetSenseConfig Null in UpdatePerceptionAllowListBP, Advanced AI Perception"));
148 return false;
149}

◆ HasAnyActiveStimulusBP()

bool UAdvancedAIPerceptionComponent::HasAnyActiveStimulusBP ( const AActor * Source) const
protected
113{
114 if(Source != nullptr)
115 {
116 const AActor& ActorReference = *Source;
117 return HasAnyActiveStimulus(ActorReference);
118 }
119 UE_LOG(LogAIToolKit, Error, TEXT("Source Null in HasAnyActiveStimulusBP, Advanced AI Perception"));
120 return false;
121}

◆ HasAnyCurrentStimulusBP()

bool UAdvancedAIPerceptionComponent::HasAnyCurrentStimulusBP ( const AActor * Source) const
protected
124{
125 if(Source != nullptr)
126 {
127 const AActor& ActorReference = *Source;
128 return HasAnyCurrentStimulus(ActorReference);
129 }
130 UE_LOG(LogAIToolKit, Error, TEXT("Source Null in HasAnyCurrentStimulusBP, Advanced AI Perception"));
131 return false;
132}

◆ SetAutoSuccessRange()

bool UAdvancedAIPerceptionComponent::SetAutoSuccessRange ( const float AutoSuccessRange)
747{
748 if(GetSightConfig() != nullptr)
749 {
750 UE_LOG(LogAIToolKit, Verbose, TEXT("SetAutoSuccessRange was %f, setting to %f"), GetSightConfig()->AutoSuccessRangeFromLastSeenLocation, AutoSuccessRange);
751 GetSightConfig()->AutoSuccessRangeFromLastSeenLocation = AutoSuccessRange;
752 RequestStimuliListenerUpdate();
753 return true;
754 }
755 UE_LOG(LogAIToolKit, Error, TEXT("SetAutoSuccessRange: Null, Advanced AI Perception"));
756 return false;
757}

◆ SetDominantSenseBP()

bool UAdvancedAIPerceptionComponent::SetDominantSenseBP ( const TSubclassOf< UAISense > SenseClass)
protected
56{
57 if(SenseClass == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in SetDominantSenseBP, Advanced AI Perception"));return false;}
58 SetDominantSense(SenseClass);
59 return true;
60}

◆ SetHearingMaxAge()

bool UAdvancedAIPerceptionComponent::SetHearingMaxAge ( const float MaxAge)
642{
643 if(GetHearingConfig() != nullptr)
644 {
645 GetHearingConfig()->SetMaxAge(MaxAge);
646 // ConfigureSense();
647 RequestStimuliListenerUpdate();
648 Deactivate();
649 Activate();
650 return true;
651 }
652 UE_LOG(LogAIToolKit, Error, TEXT("SetHearingMaxAge: Null, Advanced AI Perception"));
653 return false;
654}

◆ SetHearingRange()

bool UAdvancedAIPerceptionComponent::SetHearingRange ( const float HearingRange)
831{
832 if(GetHearingConfig() != nullptr)
833 {
834 UE_LOG(LogTemp, Verbose, TEXT("SetHearingRange was %f, setting to %f"), GetHearingConfig()->HearingRange, HearingRange);
835 GetHearingConfig()->HearingRange = HearingRange;
836 RequestStimuliListenerUpdate();
837 return true;
838 }
839 UE_LOG(LogAIToolKit, Error, TEXT("SetHearingRange: Null, Advanced AI Perception"));
840 return false;
841
842}

◆ SetLoseSightRange()

bool UAdvancedAIPerceptionComponent::SetLoseSightRange ( const float LoseSightRange)
694{
695 if(GetSightConfig() != nullptr)
696 {
697 if(LoseSightRange < GetSightConfig()->SightRadius)
698 {
699 GetSightConfig()->LoseSightRadius = GetSightConfig()->SightRadius;
700 UE_LOG(LogAIToolKit, Verbose, TEXT("SetLoseSightRange was %f, setting to %f"), GetSightConfig()->LoseSightRadius, LoseSightRange);
701 return true;
702 }
703 UE_LOG(LogAIToolKit, Verbose, TEXT("SetLoseSightRange was %f, setting to %f"), GetSightConfig()->LoseSightRadius, LoseSightRange);
704 GetSightConfig()->LoseSightRadius = LoseSightRange;
705 RequestStimuliListenerUpdate();
706 return true;
707 }
708 UE_LOG(LogAIToolKit, Error, TEXT("SetLoseSightRange: Null, Advanced AI Perception"));
709 return false;
710}

◆ SetMaxAge()

bool UAdvancedAIPerceptionComponent::SetMaxAge ( const TSubclassOf< UAISense > SenseClass,
const float MaxAge )
571{
572 if(SenseClass == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in SetMaxAge, Advanced AI Perception"));return false;}
573 UAISenseConfig* Config = GetPerceptionSenseConfig(SenseClass);
574 UAISenseConfig_Sight* SightSenseConfig = Cast<UAISenseConfig_Sight>(Config);
575 if(SightSenseConfig)
576 {
577 SightSenseConfig->SetMaxAge(MaxAge);
578 RequestStimuliListenerUpdate();
579 return true;
580 }
581 UAISenseConfig_Hearing* HearingSenseConfig = Cast<UAISenseConfig_Hearing>(Config);
582 if(HearingSenseConfig)
583 {
584 HearingSenseConfig->SetMaxAge(MaxAge);
585 RequestStimuliListenerUpdate();
586 return true;
587 }
588 UAISenseConfig_Actions* ActionsSenseConfig = Cast<UAISenseConfig_Actions>(Config);
589 if(ActionsSenseConfig)
590 {
591 ActionsSenseConfig->SetMaxAge(MaxAge);
592 RequestStimuliListenerUpdate();
593 return true;
594 }
595 UAISenseConfig_Damage* DamageSenseConfig = Cast<UAISenseConfig_Damage>(Config);
596 if(DamageSenseConfig)
597 {
598 DamageSenseConfig->SetMaxAge(MaxAge);
599 RequestStimuliListenerUpdate();
600 return true;
601 }
602 UAISenseConfig_Prediction* PredictionSenseConfig = Cast<UAISenseConfig_Prediction>(Config);
603 if(PredictionSenseConfig)
604 {
605 PredictionSenseConfig->SetMaxAge(MaxAge);
606 RequestStimuliListenerUpdate();
607 return true;
608 }
609 UAISenseConfig_Team* TeamSenseConfig = Cast<UAISenseConfig_Team>(Config);
610 if(TeamSenseConfig)
611 {
612 TeamSenseConfig->SetMaxAge(MaxAge);
613 RequestStimuliListenerUpdate();
614 return true;
615 }
616 UAISenseConfig_Touch* TouchSenseConfig = Cast<UAISenseConfig_Touch>(Config);
617 if(TouchSenseConfig)
618 {
619 TouchSenseConfig->SetMaxAge(MaxAge);
620 RequestStimuliListenerUpdate();
621 return true;
622 }
623 UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in SetMaxAge, Advanced AI Perception"));
624 return false;
625}

◆ SetNearClippingRadius()

bool UAdvancedAIPerceptionComponent::SetNearClippingRadius ( const float NearClippingRadius)
804{
805#if ENGINE_MINOR_VERSION >= 27 || ENGINE_MAJOR_VERSION >= 5
806 if(GetSightConfig() != nullptr)
807 {
808 UE_LOG(LogAIToolKit, Verbose, TEXT("SetNearClippingRadius was %f, setting to %f"), GetSightConfig()->NearClippingRadius, NearClippingRadius);
809 GetSightConfig()->NearClippingRadius = NearClippingRadius;
810 RequestStimuliListenerUpdate();
811 return true;
812 }
813 UE_LOG(LogAIToolKit, Error, TEXT("SetNearClippingRadius: Null, Advanced AI Perception"));
814#else
815 UE_LOG(LogTemp, Error, TEXT("SetNearClippingRadius: Requires UE4.27+"));
816#endif
817 return false;
818}

◆ SetPerceptionSenseConfig()

bool UAdvancedAIPerceptionComponent::SetPerceptionSenseConfig ( const TSubclassOf< UAISense > SenseClass,
const bool DetectEnemies,
const bool DetectNeutrals,
const bool DetectFriendlies )
351{
352 if(SenseClass == nullptr){UE_LOG(LogAIToolKit, Error, TEXT("SenseClass Null in SetPerceptionSenseConfig, Advanced AI Perception"));return false;}
353 UAISenseConfig* Config = GetPerceptionSenseConfig(SenseClass);
354 UAISenseConfig_Sight* SightSenseConfig = Cast<UAISenseConfig_Sight>(Config);
355 UAISenseConfig_Hearing* HearingSenseConfig = Cast<UAISenseConfig_Hearing>(Config);
356 if (SightSenseConfig)
357 {
358 SightSenseConfig->DetectionByAffiliation.bDetectEnemies = DetectEnemies;
359 SightSenseConfig->DetectionByAffiliation.bDetectNeutrals = DetectNeutrals;
360 SightSenseConfig->DetectionByAffiliation.bDetectFriendlies = DetectFriendlies;
361 }
362 else
363 {
364 HearingSenseConfig->DetectionByAffiliation.bDetectEnemies = DetectEnemies;
365 HearingSenseConfig->DetectionByAffiliation.bDetectNeutrals = DetectNeutrals;
366 HearingSenseConfig->DetectionByAffiliation.bDetectFriendlies = DetectFriendlies;
367 }
368 return true;
369}

◆ SetPOVBackwardOffset()

bool UAdvancedAIPerceptionComponent::SetPOVBackwardOffset ( const float POVBackwardOffset)
774{
775#if ENGINE_MINOR_VERSION >= 27 || ENGINE_MAJOR_VERSION >= 5
776 if(GetSightConfig() != nullptr)
777 {
778 UE_LOG(LogAIToolKit, Verbose, TEXT("SetPOVBackwardOffset was %f, setting to %f"), GetSightConfig()->PointOfViewBackwardOffset, POVBackwardOffset);
779 GetSightConfig()->PointOfViewBackwardOffset = POVBackwardOffset;
780 RequestStimuliListenerUpdate();
781 return true;
782 }
783#else
784 UE_LOG(LogTemp, Error, TEXT("SetPOVBackwardOffset: Requires UE4.27+"));
785#endif
786 return false;
787}

◆ SetSightMaxAge()

bool UAdvancedAIPerceptionComponent::SetSightMaxAge ( const float MaxAge)
628{
629 if(GetSightConfig() != nullptr)
630 {
631 GetSightConfig()->SetMaxAge(MaxAge);
632 RequestStimuliListenerUpdate();
633 // Deactivate();
634 // Activate();
635 return true;
636 }
637 UE_LOG(LogAIToolKit, Error, TEXT("SetSightMaxAge: Null, Advanced AI Perception"));
638 return false;
639}

◆ SetSightRange()

bool UAdvancedAIPerceptionComponent::SetSightRange ( const float SightRange)
667{
668 if(GetSightConfig() != nullptr)
669 {
670 UE_LOG(LogAIToolKit, Verbose, TEXT("SetSightRange was %f %f, setting to %f %f"), GetSightConfig()->SightRadius, GetSightConfig()->LoseSightRadius, SightRange, (GetSightConfig()->LoseSightRadius - GetSightConfig()->SightRadius + SightRange));
671 // Save original lose range
672 const float LoseRange = GetSightConfig()->LoseSightRadius - GetSightConfig()->SightRadius;
673 GetSightConfig()->SightRadius = SightRange;
674 // Apply lose range to new radius of the sight
675 GetSightConfig()->LoseSightRadius = GetSightConfig()->SightRadius + LoseRange;
676 RequestStimuliListenerUpdate();
677 return true;
678 }
679 UE_LOG(LogAIToolKit, Error, TEXT("GetSightConfig: Null, Advanced AI Perception"));
680 return false;
681}

◆ SetVisionAngle()

bool UAdvancedAIPerceptionComponent::SetVisionAngle ( const float VisionAngle)
724{
725 if(GetSightConfig() != nullptr)
726 {
727 UE_LOG(LogTemp, Verbose, TEXT("SetVisionAngle was %f, setting to %f"), GetSightConfig()->PeripheralVisionAngleDegrees, VisionAngle);
728 GetSightConfig()->PeripheralVisionAngleDegrees = VisionAngle;
729 RequestStimuliListenerUpdate();
730 return true;
731 }
732 UE_LOG(LogAIToolKit, Error, TEXT("SetVisionAngle: Null, Advanced AI Perception"));
733 return false;
734}

◆ UpdatePerceptionAllowListBP()

void UAdvancedAIPerceptionComponent::UpdatePerceptionAllowListBP ( const TSubclassOf< UAISense > SenseClass,
const bool bNewValue )
protected

Allows toggling senses on and off

85{
86 const FAISenseID ID = UAISense::GetSenseID(SenseClass);
87 if(ID.IsValid() && GetSenseConfig(ID) != nullptr)
88 {
89 const bool bCurrentValue = PerceptionFilter.ShouldRespondToChannel(ID);
90 if(bNewValue != bCurrentValue)
91 {
92 bNewValue ? PerceptionFilter.AcceptChannel(ID) : PerceptionFilter.FilterOutChannel(ID);
93 RequestStimuliListenerUpdate();
94 return;
95 }
96 return;
97 }
98 UE_LOG(LogAIToolKit, Error, TEXT("ID.IsValid GetSenseConfig Null in UpdatePerceptionAllowListBP, Advanced AI Perception"));
99}

Member Data Documentation

◆ OnForgottenStimulus

FOnForgottenStimulus UAdvancedAIPerceptionComponent::OnForgottenStimulus

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