Space Plunder
Loading...
Searching...
No Matches
DefenseSystemPawn.h
Go to the documentation of this file.
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "GenericTeamAgentInterface.h"
9#include "Data/AIDataTypes.h"
12#include "DefenseSystemPawn.generated.h"
13
15class UPawnSensingComponent;
16class UHealthComponentBase;
17
26UCLASS(Abstract)
27class AITOOLKIT_API ADefenseSystemPawn : public AInteractablePawn, public IGenericTeamAgentInterface, public IDefencePawnAnim, public ICharacterInterface
28{
29 GENERATED_BODY()
30
31public:
33
34 //~ Generic Team Interface
35 virtual ETeamAttitude::Type GetTeamAttitudeTowards(const AActor& Other) const override;
36 virtual void SetGenericTeamId(const FGenericTeamId& NewTeamID) override;
37 virtual FGenericTeamId GetGenericTeamId() const override{return TeamID;};
38 //~ Generic Team Interface
39
40 virtual FRotator GetTargetRotation() const override {return TargetRotation;};
41 virtual bool GetIsUpsideDown() const override {return false;};
42
43 UFUNCTION(BlueprintCallable, Category="Defence")
44 bool GetActive() const {return bActive;};
45 UFUNCTION(BlueprintCallable, Category="Defence")
46 void SetActive(const bool bValue);
47 UFUNCTION(BlueprintNativeEvent, Category="Defence")
48 void OnActivated(const bool bValue);
49 virtual void OnActivated_Implementation(const bool bValue);
50
51protected:
52
53 virtual void BeginPlay() override;
54 virtual void GetActorEyesViewPoint(FVector& OutLocation, FRotator& OutRotation) const override;
55
56 //~ Generic Team Interface
57 UPROPERTY(EditAnywhere, BlueprintReadOnly)
58 FGenericTeamId TeamID;
59 UFUNCTION(BlueprintCallable, Category="Defence")
60 int32 GetTeamID() const{return (TeamID == FGenericTeamId::NoTeam) ? INDEX_NONE : (int32)TeamID;};
61 //~ Generic Team Interface
62
63 //~ Character Interface
64 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Defence")
66 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Defence")
68
69 UFUNCTION(BlueprintCallable, Category = "Custom ALS")
70 virtual ECharacterType GetCharacterType() const override {return CharacterType;};
71 UFUNCTION(BlueprintCallable, Category = "Custom ALS")
72 virtual EFactionType GetCharacterFaction() const override {return OwnerFaction;};
73
74 UFUNCTION(BlueprintCallable, Category = "Custom ALS")
75 virtual bool GetIsDead() const override {return bDead;};
76 // UFUNCTION(BlueprintCallable, Category = "Custom ALS")
77 // virtual USkeletalMeshComponent* GetCharacterMainMesh() const override{return nullptr;};
78
79 UFUNCTION(BlueprintCallable, Category = "Custom ALS")
80 virtual void SetCharacterVehicleMode(const EVehicleMode Mode) override;
81
82
83
84 //~ Character Interface
85
86 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence")
87 FRotator StartRotation = FRotator::ZeroRotator;
88 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence")
89 FRotator TargetRotation = FRotator::ZeroRotator;
90
92 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|Alert")
93 float AlertUpdateFrequency = 0.2f;
95 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|Alert")
96 float AlertLevelIncrease = 0.1f;
98 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|Alert")
99 float AlertLevelDecrease = 0.1f;
100
102 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|Alert")
103 float AlertLevelThreshold = 100.0f;
105 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence|Alert")
106 float AlertLevel = 0.0f;
108 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence|Alert")
109 bool bAlert = false;
110
112 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Defence|Target")
113 float VisibilityCheckFrequency = 2.0f;
115 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|Target")
116 bool bInstantResetOnLostTarget = false;
118 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|Target")
119 float LostTargetResetTime = 2.0f;
120
121 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence|Status")
122 bool bDead = false;
123 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence|State")
124 bool bAutoActivate = true;
126 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category= "Defence")
127 // bool bShouldCheckForTargetBeforeAlert = false;
128
129 // UFUNCTION(BlueprintCallable, Category="Defence")
130 // float GetVisibilityScore(AActor* Target);
131 // UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Auto Turret")
132 // float VisibilityPercentNeeded = 60.0f;
133 // UPROPERTY(EditAnywhere, BlueprintReadOnly, Category="Defence")
134 // TArray<FName> VisibilityTraceLocations = {FName("head"), FName("Pelvis"), FName("Foot_R"), FName("Foot_L"), FName("Hand_L"), FName("hand_r")};
135
136
138 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
139 void OnNewTargetSeen(APawn* Pawn);
141 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
142 void OnTargetSeen(APawn* Pawn);
143 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
144 void OnHostileSeen();
145 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
146 void OnHostileSeenUpdate();
147 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
148 void OnTargetLost();
149 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
150 void OnLostAllTargets();
151 UFUNCTION(BlueprintImplementableEvent, Category="Defence")
152 void OnAlertChange(const float CurrentAlertLevel, const float MaxAlertLevel);
153
154 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence|Visual")
155 UHealthComponentBase* HealthComponent;
156 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category= "Defence|Visual")
157 UAdvancedPawnSensingComponent* PawnSensingComponent;
158
159
160
161
162
163 virtual bool GetIsCharacter() const override {return true;};
164
165 // UFUNCTION()
166 // virtual void AnyDamageTaken(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);
167 UFUNCTION()
168 virtual void PointDamageTaken(AActor* DamagedActor, float Damage, class AController* InstigatedBy, FVector HitLocation, class UPrimitiveComponent* HitComponent, FName BoneName, FVector ShotFromDirection, const class UDamageType* DamageType, AActor* DamageCauser);
169 UFUNCTION()
170 virtual void OnDeath(AActor* OwningActor, EDeathType DeathType, AActor* DeathCauser, AController* DeathInstigator);
171
172
173 UFUNCTION(BlueprintCallable, Category="Defence")
174 bool CanStillSeePawn(APawn* Pawn) const;
175
176 UFUNCTION(BlueprintCallable, Category="Defence")
177 bool IsPawnAlive(APawn* Pawn) const;
178
179 UFUNCTION(BlueprintCallable, Category="Defence")
180 bool GetCurrentTarget(APawn*& Pawn) const;
182 UFUNCTION(BlueprintCallable, Category="Defence")
183 TArray<APawn*>& GetTargets() {return Targets;};
184
186 UFUNCTION(BlueprintCallable, Category="Defence")
187 float GetDistanceToPawn(const APawn* Pawn) const;
188
190 UFUNCTION(BlueprintCallable, Category="Defence")
191 float GetTotalDistanceScoreToAllTargets() const;
192
193 UFUNCTION(BlueprintCallable, Category="Defence")
194 virtual FRotator GetRotationToTarget(const FVector& StartLocation);
195
197 virtual void TargetSeen(APawn* Pawn);
198 virtual void NewTargetSeen(APawn* Pawn);
199
200 virtual void EnemySeen();
201 virtual void LostAllTargets();
202 virtual void RotateToTarget();
203
204private:
205 UPROPERTY(VisibleAnywhere, Category= "Defence|State")
206 bool bActive = false;
207
208 UFUNCTION()
209 virtual void OnSeePawn(APawn* Pawn);
210 UFUNCTION()
211 virtual void OnHearPawn(APawn* Pawn, const FVector& Location, float Volume);
212
213
214 void CheckVisibilityOfTargets();
215 void IncreaseAlert();
216 void DecreaseAlert();
217
218 void CheckEnemySeen();
219
220
221 int32 CurrentTarget = -1;
223 UPROPERTY()
224 TArray<APawn*> Targets;
225
226 FTimerHandle IncreaseAlertTimerHandle;
227 FTimerHandle DecreaseAlertTimerHandle;
228
229 FTimerHandle EnemySeenTimerHandle;
230 FTimerHandle CheckVisibilityTimerHandle;
231 FTimerHandle LostTargetTimerHandle;
232
233
234};
ECharacterType
Definition AIDataTypes.h:73
EFactionType
Definition AIDataTypes.h:103
EDeathType
Definition BaseData.h:53
EVehicleMode
Definition BaseData.h:124
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
Represents a defense system pawn that can interact with other actors and participate in the generic t...
Definition DefenseSystemPawn.h:28
virtual bool GetIsUpsideDown() const override
Definition DefenseSystemPawn.h:41
virtual FGenericTeamId GetGenericTeamId() const override
Definition DefenseSystemPawn.h:37
virtual FRotator GetTargetRotation() const override
Definition DefenseSystemPawn.h:40
Definition InteractablePawn.h:17
Definition CharacterInterface.h:20
Definition DefencePawnAnim.h:20
Definition AdvancedPawnSensingComponent.h:14