6#include "Components/ActorComponent.h"
7#include "SpottingComponent.generated.h"
11class UAfflictionInstance;
16UCLASS( ClassGroup=(
Custom), meta=(BlueprintSpawnableComponent), Blueprintable)
17class PROJECTX_API USpottingComponent :
public UActorComponent
23 virtual
void TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
24 bool IsEnabled()
const {
return bSpottingComponentEnabled; }
25 float GetCachedSpottingRange()
const {
return CachedSpottingDistance; }
27 UFUNCTION(BlueprintCallable)
28 void SetDotMultiplier(
float NewMultipler) { MaxDotMultiplier = NewMultipler;}
29 UFUNCTION(BlueprintCallable, Category =
"Spotting Component")
30 void SetOwningCharacter(ACharacter* const InOwningCharacter);
31 UFUNCTION(BlueprintCallable, Category = "Spotting Component")
32 void PerformRadialScan(
float ScanRange,
bool bIgnoreObstacles = false,
bool bRevealStealthTargets = false);
33 UFUNCTION(BlueprintCallable, Category = "Spotting Component")
34 void UpdateSpottingRange(
float NewRange) { SpottingRange = NewRange; }
35 UFUNCTION(BlueprintCallable, Category =
"Spotting Component")
36 void UpdateUseDotProductCheck(
bool bNewCheckDotProduct) { bCheckDotProduct = bNewCheckDotProduct;}
38 FEnemySpottedSignature OnEnemySpotted;
39 FEnemyUniqueEnemySpottedSignature OnUniqueEnemySpotted;
42 UFUNCTION(BlueprintPure, Category =
"Spotting Component")
43 virtual ACharacter* GetOwningCharacter() const;
44 UFUNCTION(BlueprintPure, Category = "Spotting Component")
45 AController* GetOwningController() const;
48 virtual
void BeginPlay() override;
50 bool bSpottingComponentEnabled = true;
52 UPROPERTY(EditDefaultsOnly, Category =
Radar)
53 TSubclassOf<UAfflictionInstance> SpottedAffliction = NULL;
55 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
56 float SpottingRequiredTime = 3.f;
58 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
59 float SpottingRange = 1000000.f;
61 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
62 UCurveFloat* MaxDotPerDistanceCurve =
nullptr;
64 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
65 float MaxDotMultiplier = 1.f;
67 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
68 bool bTickTargetFinderOnServer = false;
70 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
71 bool bRevealInvisibleTargets = false;
74 UPROPERTY(EditDefaultsOnly, Category = "Spotting Component")
75 bool bCanMultispot = false;
77 TWeakObjectPtr<AActor> SpottingTarget = NULL;
79 ACharacter* OwningCharacter = NULL;
81 void TickTargetFinder(
float DeltaTime);
82 void TickTargetMaintain(
float DeltaTime);
83 void SpotTarget(AActor* SpottedActor,
int& UniqueSpots);
85 UFUNCTION(
Server, Reliable, WithValidation)
86 void Server_SpotTarget(AActor* SpottedActor);
88 UFUNCTION(BlueprintNativeEvent, Category = "Spotting Component")
89 void GetSpottingViewPoint(FVector& OutLocation, FRotator& OutRotation) const;
92 float SpottingTime = 0.f;
94 bool bCheckDotProduct = true;
95 float CachedSpottingDistance = 0.0f;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FEnemySpottedSignature, AActor *, EnemySpotted)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FEnemyUniqueEnemySpottedSignature)