LEAP Documentation 40220
Documentation for the LEAP project
Deployable.h
Go to the documentation of this file.
1// Copyright Blue Isle Studios Inc 2018. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "HealthInterface.h"
10#include "TrackableInterface.h"
11#include "ReactsToMatchEvents.h"
12#include "ObjectInfoInterface.h"
13#include "Deployable.generated.h"
14
15class APlayerState;
16class AContainer;
17class UWeaponInstance;
18class UAfflictionComponent;
19
20UENUM(BlueprintType)
21enum class EDeployableState : uint8
22{
23 None,
27};
28
29/* Categories might be used for querying deployables that belong to the same category but don't share the same classes */
30UENUM(BlueprintType)
31enum class EDeployableCategory : uint8
32{
33 None,
38};
39
40DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDeploymentBeginSignature, ADeployable*, Deployable);
41DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDeploymentCompleteSignature, ADeployable*, Deployable);
42DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDeployableCompleteSignature, ADeployable*, Deployable);
43DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnDeployableLifeTimeStartSignature, float, LifeTime);
44
45UCLASS(Blueprintable)
47{
48 GENERATED_UCLASS_BODY()
49
50public:
51 virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
52 UFUNCTION(BlueprintCallable)
53 virtual void Init();
54 virtual void MatchEnded() override;
55 virtual bool CanOwningWeaponInstanceFire() const { return false; }
56
57 UFUNCTION(BlueprintCallable, Category = Deployable)
58 bool IsDeployed() const { return DeployState == EDeployableState::Activated || DeployState == EDeployableState::Deactivated; }
59 UFUNCTION(BlueprintCallable, Category = Deployable)
60 bool IsDeploying() const { return !IsDeployed(); }
61 UFUNCTION()
62 FORCEINLINE EDeployableCategory GetDeployableCategory() const { return DeployableCategory; }
63
64 virtual float GetHealth() const override;
65 virtual float GetMaxHealth() const override;
66 virtual bool BlocksExplosions() const override { return bBlocksExplosionDamage; }
67
68 virtual float GetTimeSinceLastDamage() const override;
69 virtual bool IsArmored() const override { return bArmored; }
70 virtual bool IsDead() const override;
71 virtual void SetMaxHealth(const float NewMaxHealth) override;
72 virtual void SetHealth(const float NewHealth) override;
73 virtual bool CanBeLockedOn(const AActor* LockInstigator) const override;
74 virtual bool CanBeRepaired(const AActor* RepairInstigator) const override;
75 virtual float GetLockOnMaxDistance() override { return MaxLockOnRange; }
76 virtual FVector2D GetLockOnScreenPercentage() override { return LockOnScreenPercentage; }
77 void SetHealthRegenRate(float NewRate) override { HealthRegenRate = NewRate; }
78 virtual ESpotReply CanBeSpotted(const AActor* SpotInstigator, ESpotType SpotType) const override;
79 virtual AActor* GetTrackableInterfaceActor() override { return this; }
80 virtual TSoftObjectPtr<UTexture2D> GetMapIcon() const override { return DeployableMapIcon; }
81 virtual TSoftObjectPtr<UTexture2D> GetRadarIcon() const override { return DeployableRadarIcon; }
82 virtual TSoftObjectPtr<UTexture2D> GetHudIcon() const override { return DeployableHudIcon; }
83 virtual float GetRadarIconSize() const override { return 750.0f; }
84 virtual float GetRadarIconOpacity() const override { return 0.6f; }
85 virtual const FText& GetObjectName() const { return GetDeployableName(); };
86 virtual const FString GetOwnerName() const;
87 virtual const FText& GetObjectDescription() const;
88
89 UFUNCTION(BlueprintCallable, Category = Deployable)
90 const FText& GetDeployableName() const { return DeployableName; }
91
92 UFUNCTION(BlueprintCallable, Category = Deployable)
93 TAssetPtr<UTexture2D> GetDeployableIcon() const { return DeployableIcon; }
94 UFUNCTION(BlueprintCallable, Category = Deployable)
95 EDeployableState GetDeployableState() const { return DeployState; }
96 UFUNCTION(BlueprintCallable, Category = Deployable)
97 float GetLifeTimeDurationStartTime() const {return LifeTimeDurationStartTime;}
98 UFUNCTION(BlueprintCallable,BlueprintPure, Category = Deployable)
99 float GetTimeUntilDeploy() const { return FMath::Max(0.f, GetWorld()->GetTimerManager().GetTimerRemaining(DeployTimer)); }
100
101 FVector GetSpottingTraceOffset() const override { return FVector(GetActorLocation().X, GetActorLocation().Y, GetActorLocation().Z + SpottingZOffset); }
102
103 void SetDeployableLifeTime(const float NewLifeTime);
104
105 virtual void OnOwnerLeave() override;
106 virtual void OnOwnerDied() override {}
107
108 //Returns a list of deployables owned by provided a pawn/controller/player state (anything implementing IPlayerOwnedInterface). If a Category is provided, it will only search for the ones that belong to that category and if a filter is provided, will only return actors matching the class specified.
109 UFUNCTION(BlueprintCallable, Category = Deployable)
110 static TArray<ADeployable*> GetAllDeployablesForActor(AActor* Actor, EDeployableCategory CategoryFilter = EDeployableCategory::None, TSubclassOf<ADeployable> DeployableFilter = NULL);
111
112 UFUNCTION(BlueprintCallable)
113 virtual void DeployStart(bool bForce = false);
114 UFUNCTION(BlueprintCallable)
115 virtual void DeactivateDeployable();
116 UFUNCTION(BlueprintCallable)
117 virtual void ActivateDeployable();
118 UFUNCTION(BlueprintCallable)
119 virtual void ClearDeployable();
120
121 virtual void DeployComplete();
122 virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) override;
123 virtual bool ShouldTakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) const;
124 virtual float InternalTakeRadialDamage(float Damage, FRadialDamageEvent const& RadialDamageEvent, class AController* EventInstigator, class AActor* DamageCauser) override;
125 virtual void Died(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser, APlayerState* InstigatorPlayerState);
126 virtual UAfflictionComponent* GetAfflictionComponent() const override { return AfflictionComponent; }
127
128 UPROPERTY(BlueprintAssignable)
129 FDeploymentBeginSignature OnDeploymentBegin;
130 UPROPERTY(BlueprintAssignable)
131 FDeploymentCompleteSignature OnDeploymentComplete;
132 UPROPERTY(BlueprintAssignable)
133 FDeployableCompleteSignature OnDeployableComplete;
134 UPROPERTY(BlueprintAssignable)
135 FOnDeployableLifeTimeStartSignature OnDeployableLifeTimeStarted;
136
137 UFUNCTION(NetMulticast, Reliable)
138 void Multicast_Reliable_Died(float Damage, FDamageEvent const& DamageEvent, AActor* DamageCauser, APlayerState* InstigatorPlayerState);
139
140 UFUNCTION(BlueprintImplementableEvent, Category = Deployable)
141 void InitializeForTeam(int32 Team);
142
143 UFUNCTION(BlueprintImplementableEvent, Category = Deployable)
144 void OnDeployableDied();
145 UFUNCTION(BlueprintImplementableEvent, Category = Deployable)
146 void OnDeployStart();
147 UFUNCTION(BlueprintImplementableEvent, Category = Deployable)
148 void OnDeployDeactivated();
149 UFUNCTION(BlueprintImplementableEvent, Category = Deployable)
150 void OnDeployReActivated();
151 UFUNCTION(BlueprintImplementableEvent, Category = Deployable)
152 void OnDeployComplete();
153 UFUNCTION(BlueprintCallable)
154 void SetDeployTransform(const FTransform& Transform);
155 UFUNCTION(BlueprintCallable)
156 void UpdateState(EDeployableState NewDeployState);
157
158 UFUNCTION()
159 void OnRep_StateChanged();
160 UFUNCTION()
161 void OnRep_LifeTimeDurationStart();
162 UFUNCTION()
163 virtual void OnRep_Health(float PreviousHealth);
164 UFUNCTION()
165 virtual void OnRep_DeployTransform();
166
167 UFUNCTION()
168 virtual void OnTeamsChanged(class AProjectXPlayerState* PlayerState, uint8 Team);
169
170 virtual void BeginPlay() override;
171 UPROPERTY(ReplicatedUsing = OnRep_StateChanged)
173 UPROPERTY(EditDefaultsOnly, Category = Afflictions)
174 UAfflictionComponent* AfflictionComponent = NULL;
175 /* Can this deployable be targeted by AI systems? */
176 UPROPERTY(EditDefaultsOnly, Category = Deployable)
177 bool bTargetable = true;
178 /* Should we treat this as an armored target? Affects HUD, hitmarkers etc */
179 UPROPERTY(EditDefaultsOnly, Category = Deployable)
180 bool bArmored = true;
181 /* Maximum Health of the deployable*/
182 UPROPERTY(Replicated, EditDefaultsOnly, Category = Deployable)
183 float MaxHealth = 100.f;
184 /* Current Health of the deployable*/
185 UPROPERTY(ReplicatedUsing = OnRep_Health)
186 float Health = 0.f;
187 UPROPERTY(ReplicatedUsing = OnRep_LifeTimeDurationStart)
188 float LifeTimeDurationStartTime = 0.0f;
189 /* does the deployable block Explosion Damage*/
190 UPROPERTY(EditDefaultsOnly, Category = Deployable)
191 bool bBlocksExplosionDamage = false;
192 /* This deployable's category */
193 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Deployable)
195 /* does the deployable deploy automatically*/
196 UPROPERTY(EditDefaultsOnly, Category = Deployable)
197 bool bAutoDeploy = false;
198 /* time to finish deploying*/
199 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Deployable)
200 float DeployTime = 2.5f;
201 /* life time of the deployable after finished deployment*/
202 UPROPERTY(Replicated, EditDefaultsOnly, BlueprintReadOnly, Category = Deployable)
203 float DeployableLifeTime = 0.0f;
204 UPROPERTY(ReplicatedUsing = OnRep_DeployTransform)
205 FTransform DeployTransform;
206 /* Should health charge up over the duration of the deploy? */
207 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Deployable)
208 bool bHealthDuringDeploy = true;
209 /* Starting health of the deployable if health charges up on deploy */
210 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = Deployable, meta = (EditCondition = "bHealthDuringDeploy"))
211 float DeployableStartingHealth = 1.0f;
212 UPROPERTY(Replicated)
213 float LastDamageTime = -MAX_FLT;
214 /* Widget that will be added to the deployed list widget when this deployable is spawned */
215 UPROPERTY(EditDefaultsOnly, Category = Deployable)
216 TAssetPtr<UTexture2D> DeployableIcon = NULL;
217 UPROPERTY()
218 bool bIsDead = false;
219 /* How Long will it take for the deployable to finish its death effects*/
220 UPROPERTY(EditDefaultsOnly, Category = Deployable)
221 float DiedEffectDuration = 2.0f;
222 /* Name of the deployable*/
223 UPROPERTY(EditDefaultsOnly, Category = Deployable)
224 FText DeployableName;
225 /* does it destory automaticly on death*/
226 UPROPERTY(EditDefaultsOnly, Category = Deployable)
227 bool bDestroyImmediatelyOnDeath = true;
228 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Deployable|LockOn")
229 bool bCanBeLockedOn = false;
230 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Deployable|Repair")
231 bool bCanBeRepaired = false;
232 /*Returns the max distance this deployable can be to be considered for locking-into. This means that if
233 we scan for 20km targets but this actor has a MaxLockOnRange of 100m and this actor is further away than
234 100m it won't be considered as a candidate during the target-finding.
235 A returned value of 0 is by default ignored by target-finding systems */
236 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Deployable|LockOn", meta = (EditCondition = "bCanBeLockedOn"))
237 float MaxLockOnRange = 15000.f;
238 /* Returns the Screen percentage that this deployable is required to have to be considered for Locking-onto (In both vertical and horizontal axis of the viewport).
239 A value of FVector2D(0,0) will by default be ignored by weapons when deciding locking-into candidates. For example, when scanning for a 20km range, if this deployable
240 has a screen percentage bigger than GetLockOnScreenPercentage() (in any axis) it is going to be considered as a candidate to be locked into. This is useful as
241 deployable that are really far away can still look big on the screen and feels like they should be locked into */
242 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Deployable|LockOn", meta = (EditCondition = "bCanBeLockedOn"))
243 FVector2D LockOnScreenPercentage = FVector2D::ZeroVector;
244
245 /*This is used for offsetting the Z location from a deployable for a more favorable spotting location on the deployable*/
246 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Deployable")
247 float SpottingZOffset = 0.0f;
248
249 /* This Deployable's icon that is to be displayed on the map*/
250 UPROPERTY(EditDefaultsOnly, Category = "UI")
251 TSoftObjectPtr<UTexture2D> DeployableMapIcon = NULL;
252 /* This Deployable's icon that is to be displayed on enemies' huds when spotted*/
253 UPROPERTY(EditDefaultsOnly, Category = "UI")
254 TSoftObjectPtr<UTexture2D> DeployableHudIcon = NULL;
255 /* This Deployable's icon that is to be displayed on enemies' radars when spotted*/
256 UPROPERTY(EditDefaultsOnly, Category = "UI")
257 TSoftObjectPtr<UTexture2D> DeployableRadarIcon = NULL;
258
259 FTimerHandle DeployTimer;
260 FTimerHandle LifeTimerHandle;
261
262 int32 HealthInterpolatorID = INDEX_NONE;
263 float LastHealthInterpolatorValue = 0.f;
264 float HealthRegenRate = 0.0f;
265 //This is only used by non-authoritative proxies
267
268 FString AllyDeployableDestoryed = "VO_EquipementDestroyed_Ally";
269};
EDeployableCategory
Definition: Deployable.h:32
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FDeploymentBeginSignature, ADeployable *, Deployable)
EDeployableState
Definition: Deployable.h:22
ESpotType
Definition: SpottableInterface.h:18
ESpotReply
Definition: SpottableInterface.h:27
Definition: Deployable.h:47
virtual bool CanOwningWeaponInstanceFire() const
Definition: Deployable.h:55
virtual float GetLockOnMaxDistance() override
Definition: Deployable.h:75
virtual UAfflictionComponent * GetAfflictionComponent() const override
Definition: Deployable.h:126
virtual TSoftObjectPtr< UTexture2D > GetRadarIcon() const override
Definition: Deployable.h:81
FVector GetSpottingTraceOffset() const override
Definition: Deployable.h:101
virtual bool BlocksExplosions() const override
Definition: Deployable.h:66
virtual float GetRadarIconSize() const override
Definition: Deployable.h:83
virtual FVector2D GetLockOnScreenPercentage() override
Definition: Deployable.h:76
void SetHealthRegenRate(float NewRate) override
Definition: Deployable.h:77
virtual void OnOwnerDied() override
Definition: Deployable.h:106
virtual TSoftObjectPtr< UTexture2D > GetHudIcon() const override
Definition: Deployable.h:82
virtual TSoftObjectPtr< UTexture2D > GetMapIcon() const override
Definition: Deployable.h:80
virtual bool IsArmored() const override
Definition: Deployable.h:69
virtual float GetRadarIconOpacity() const override
Definition: Deployable.h:84
virtual AActor * GetTrackableInterfaceActor() override
Definition: Deployable.h:79
virtual const FText & GetObjectName() const
Definition: Deployable.h:85
Definition: ProjectXPlayerState.h:238
Definition: WeaponInstanceActor.h:16
Definition: HealthInterface.h:28
Definition: LockOnTargetInterface.h:27
Definition: ObjectInfoInterface.h:16
Definition: ReactsToMatchEvents.h:16
Definition: SpottableInterface.h:40
Definition: TrackableInterface.h:22
Definition: WeaponInstance.h:220