4#include "CoreMinimal.h"
5#include "UObject/ObjectMacros.h"
7#include "AIModule/Classes/GenericTeamAgentInterface.h"
8#include "AIModule/Classes/Perception/AISense.h"
9#include "AIModule/Classes/Perception/AISenseConfig.h"
11#include "VRAIPerceptionOverrides.generated.h"
13class IAISightTargetInterface;
16class FGameplayDebuggerCategory;
17class UAIPerceptionComponent;
24 GENERATED_UCLASS_BODY()
27 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", NoClear, config)
31 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0.0, ClampMin = 0.0))
35 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0.0, ClampMin = 0.0))
36 float LoseSightRadius;
40 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0.0, ClampMin = 0.0, UIMax = 180.0, ClampMax = 180.0,
DisplayName = "PeripheralVisionHalfAngleDegrees"))
41 float PeripheralVisionAngleDegrees;
44 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config)
45 FAISenseAffiliationFilter DetectionByAffiliation;
48 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config)
49 float AutoSuccessRangeFromLastSeenLocation;
51 virtual TSubclassOf<
UAISense> GetSenseImplementation() const override;
54 virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent)
override;
57#if WITH_GAMEPLAY_DEBUGGER
58 virtual void DescribeSelfToGameplayDebugger(
const UAIPerceptionComponent* PerceptionComponent, FGameplayDebuggerCategory* DebuggerCategory)
const;
77 GENERATED_USTRUCT_BODY()
93 : Age(0.f), EventType(InEventType), SeenActor(InSeenActor), Observer(InObserver)
103 TWeakObjectPtr<AActor>
Target;
175UCLASS(ClassGroup = AI, config = Game)
178 GENERATED_UCLASS_BODY()
181 struct FDigestedSightProperties
183 float PeripheralVisionAngleCos;
185 float AutoSuccessRangeSqFromLastSeenLocation;
186 float LoseSightRadiusSq;
187 uint8 AffiliationFlags;
189 FDigestedSightProperties();
193 typedef TMap<FAISightTargetVR::FTargetId, FAISightTargetVR> FTargetsContainer;
194 FTargetsContainer ObservedTargets;
195 TMap<FPerceptionListenerID, FDigestedSightProperties> DigestedProperties;
200 int32 NextOutOfRangeIndex = 0;
201 bool bSightQueriesOutOfRangeDirty =
true;
202 TArray<FAISightQueryVR> SightQueriesOutOfRange;
203 TArray<FAISightQueryVR> SightQueriesInRange;
206 UPROPERTY(EditDefaultsOnly, Category =
"AI Perception", config)
207 int32 MaxTracesPerTick;
209 UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
210 int32 MinQueriesPerTimeSliceCheck;
212 UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
213 double MaxTimeSlicePerTick;
215 UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
216 float HighImportanceQueryDistanceThreshold;
218 float HighImportanceDistanceSquare;
220 UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
221 float MaxQueryImportance;
223 UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
224 float SightLimitQueryImportance;
226 ECollisionChannel DefaultSightCollisionChannel;
230 virtual
void PostInitProperties() override;
234 virtual
void RegisterSource(
AActor& SourceActors) override;
235 virtual
void UnregisterSource(
AActor& SourceActor) override;
237 virtual
void OnListenerForgetsActor(const FPerceptionListener& Listener,
AActor& ActorToForget) override;
238 virtual
void OnListenerForgetsAll(const FPerceptionListener& Listener) override;
241 virtual
float Update() override;
245 void OnNewListenerImpl(const FPerceptionListener& NewListener);
246 void OnListenerUpdateImpl(const FPerceptionListener& UpdatedListener);
247 void OnListenerRemovedImpl(const FPerceptionListener& RemovedListener);
248 virtual
void OnListenerConfigUpdated(const FPerceptionListener& UpdatedListener) override;
253 void RemoveAllQueriesByListener(const FPerceptionListener& Listener, const TFunction<
void(const
FAISightQueryVR&)>& OnRemoveFunc =
nullptr);
257 bool RegisterTarget(
AActor& TargetActor, const TFunction<
void(
FAISightQueryVR&)>& OnAddedFunc =
nullptr);
259 float CalcQueryImportance(const FPerceptionListener& Listener, const FVector& TargetLocation, const
float SightRadiusSq) const;
263 UE_DEPRECATED(4.25, "Not needed anymore done automatically at the beginning of each update.")
264 FORCEINLINE
void SortQueries() {}
271 UE_DEPRECATED(4.25,
"Use RemoveAllQueriesByListener without unneeded PostProcess parameter.")
272 void RemoveAllQueriesByListener(const FPerceptionListener& Listener, FQueriesOperationPostProcess PostProcess) { RemoveAllQueriesByListener(Listener); }
273 UE_DEPRECATED(4.25,
"Use RemoveAllQueriesByListener without unneeded PostProcess parameter.")
275 UE_DEPRECATED(4.25,
"Use RemoveAllQueriesToTarget without unneeded PostProcess parameter.")
277 UE_DEPRECATED(4.25,
"Use RemoveAllQueriesToTarget without unneeded PostProcess parameter.")
278 void RemoveAllQueriesToTarget(const
FAISightTargetVR::FTargetId& TargetId, FQueriesOperationPostProcess PostProcess, TFunctionRef<
void(const
FAISightQueryVR&)> OnRemoveFunc) { RemoveAllQueriesToTarget(TargetId, [&](
const FAISightQueryVR& query) { OnRemoveFunc(query); }); }
281 UE_DEPRECATED(4.25,
"Use RegisterTarget without unneeded PostProcess parameter.")
283 UE_DEPRECATED(4.25,
"Use RegisterTarget without unneeded PostProcess parameter.")
284 bool RegisterTarget(
AActor& TargetActor, FQueriesOperationPostProcess PostProcess, TFunctionRef<
void(
FAISightQueryVR&)> OnAddedFunc) {
return RegisterTarget(TargetActor, [&](
FAISightQueryVR& query) { OnAddedFunc(query); }); }
DECLARE_LOG_CATEGORY_EXTERN(LogAIPerceptionVR, Warning, All)
FVector GetVRLocation_Inline() const
bool operator()(const FAISightQueryVR &A, const FAISightQueryVR &B) const
UCLASS(ClassGroup = AI, config = Game)
void RemoveAllQueriesByListener(const FPerceptionListener &Listener, FQueriesOperationPostProcess PostProcess, TFunctionRef< void(const FAISightQueryVR &)> OnRemoveFunc)
TArray< FAISightQueryVR > SightQueriesInRange
float HighImportanceQueryDistanceThreshold
UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
int32 MaxTracesPerTick
UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
void RemoveAllQueriesToTarget(const FAISightTargetVR::FTargetId &TargetId, FQueriesOperationPostProcess PostProcess, TFunctionRef< void(const FAISightQueryVR &)> OnRemoveFunc)
TMap< FPerceptionListenerID, FDigestedSightProperties > DigestedProperties
bool RegisterTarget(AActor &TargetActor, FQueriesOperationPostProcess PostProcess)
void RemoveAllQueriesToTarget(const FAISightTargetVR::FTargetId &TargetId, FQueriesOperationPostProcess PostProcess)
bool RegisterTarget(AActor &TargetActor, FQueriesOperationPostProcess PostProcess, TFunctionRef< void(FAISightQueryVR &)> OnAddedFunc)
float MaxQueryImportance
UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
void RemoveAllQueriesByListener(const FPerceptionListener &Listener, FQueriesOperationPostProcess PostProcess)
TArray< FAISightQueryVR > SightQueriesOutOfRange
float SightLimitQueryImportance
UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
double MaxTimeSlicePerTick
UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
TMap< FAISightTargetVR::FTargetId, FAISightTargetVR > FTargetsContainer
ECollisionChannel DefaultSightCollisionChannel
FTargetsContainer ObservedTargets
float HighImportanceDistanceSquare
FQueriesOperationPostProcess
int32 MinQueriesPerTimeSliceCheck
UPROPERTY(EditDefaultsOnly, Category = "AI Perception", config)
UCLASS(meta = (DisplayName = "AI Sight VR config"))
float PeripheralVisionAngleDegrees
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0....
FAISenseAffiliationFilter DetectionByAffiliation
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config)
float LoseSightRadius
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0....
TSubclassOf< UAISense_Sight_VR > Implementation
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", NoClear, config)
float AutoSuccessRangeFromLastSeenLocation
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config)
float SightRadius
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0....
UAISense_Sight_VR FSenseClass
FAISightEventVR(AActor *InSeenActor, AActor *InObserver, ESightPerceptionEventNameVR::Type InEventType)
ESightPerceptionEventNameVR::Type EventType
AActor * Observer
UPROPERTY()
AActor * SeenActor
UPROPERTY()
FAISightTargetVR::FTargetId TargetId
FPerceptionListenerID ObserverId
void ForgetPreviousResult()
uint64 LastProcessedFrameNumber
FAISightQueryVR(FPerceptionListenerID ListenerId=FPerceptionListenerID::InvalidID(), FAISightTargetVR::FTargetId Target=FAISightTargetVR::InvalidTargetId)
static const FTargetId InvalidTargetId
IAISightTargetInterface * SightTargetInterface
FORCEINLINE FVector GetLocationSimple() const
TWeakObjectPtr< AActor > Target
FORCEINLINE const AActor * GetTargetActor() const
FAISightTargetVR(AActor *InTarget=NULL, FGenericTeamId InTeamId=FGenericTeamId::NoTeam)
float PeripheralVisionAngleCos
float AutoSuccessRangeSqFromLastSeenLocation