5#include "CoreMinimal.h"
6#include "GameFramework/Actor.h"
10#include "DestroyableObjective.generated.h"
12DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams(FObjectiveDamagedSignature,
class ADestroyableObjective*, Objective,
const float, Damage,
struct FDamageEvent
const&, DamageEvent,
class AController*, EventInstigator,
class AActor*, DamageCauser,
class APlayerState*, InstigatorPlayerState);
16class UAfflictionComponent;
17class UAfflictionInstance;
19#define NOT_INITIALIZED_HEALTH -MAX_FLT
30 virtual void ToggleActivation(
bool bToggle);
32 virtual void Tick(
float DeltaTime)
override;
33 virtual float TakeDamage(
float DamageAmount,
struct FDamageEvent
const& DamageEvent,
class AController* EventInstigator, AActor* DamageCauser)
override;
35 UFUNCTION(BlueprintPure, Category =
"Destroyable Objective")
36 FORCEINLINE
bool IsObjectiveActive()
const {
return bIsActive; }
37 UFUNCTION(BlueprintPure, Category =
"Destroyable Objective")
38 FORCEINLINE
bool IsObjectiveProperlyInitialized()
const {
return bHasTeamProperlyInitialized && bHasHealthProperlyInitialized; }
40 virtual int32 GetTeam()
const override;
41 virtual int32 SetTeam(int32 NewTeam)
override;
47 virtual void SetHealth(
const float NewHealth)
override;
49 virtual float GetTimeSinceLastDamage()
const override;
52 UPROPERTY(BlueprintAssignable, Category =
"Destroyable Objective|Events")
53 FObjectiveDamagedSignature OnObjectiveDamaged;
54 UPROPERTY(BlueprintAssignable, Category = "Destroyable Objective|Events")
55 FObjectiveDamagedSignature OnObjectiveDestroyed;
56 UPROPERTY(BlueprintAssignable, Category = "Destroyable Objective|Events")
57 FObjectiveEventSignature OnObjectiveOwnerChanged;
58 UPROPERTY(BlueprintAssignable, Category = "Destroyable Objective|Events")
59 FObjectiveEventSignature OnObjectiveActivationChanged;
60 UPROPERTY(BlueprintAssignable, Category = "Destroyable Objective|Events")
61 FObjectiveEventSignature OnObjectiveProperlyInitialized;
62 UPROPERTY(BlueprintAssignable, Category = "Destroyable Objective|Events")
63 FObjectivePointTeamChangedSignature OnTeamChangedEvent;
66 virtual
void BeginPlay() override;
67 virtual
void EndPlay(const EEndPlayReason::Type EndplayReason) override;
68 virtual
void OnRep_Owner() override;
69 virtual
void Die(
float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser, const FHitResult& HitResult, APlayerState* InstigatorPlayerState);
72 virtual
void StartPassiveRegenDelay();
74 virtual
void BeginPassiveRegen();
75 virtual
void StopPassiveRegen();
76 virtual
void CheckForInitialization();
78 UFUNCTION(BlueprintImplementableEvent)
79 void OnObjectiveInitialized();
82 virtual
void OnRep_Health(
float PreviousHealth);
84 virtual
void OnRep_Activation();
86 virtual
void OnRep_Team();
87 UFUNCTION(Reliable, NetMulticast)
88 void Multicast_Die(
float Damage, struct FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser, const FHitResult&
Hit, APlayerState* InstigatorPlayerState);
90 UPROPERTY(EditAnywhere, Category = "Destroyable Objective|
Health", meta = (AllowPrivateAccess = true))
91 float MaxHealth = 1000.f;
93 UPROPERTY(GlobalConfig, EditDefaultsOnly, BlueprintReadOnly, Category = "Destroyable Objective|
Health|Regen")
94 bool bUsePassiveHealthRegen = true;
96 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Destroyable Objective|
Health|Regen", meta = (EditCondition = "bUsePassiveHealthRegen"))
97 float PassiveHealthRegenDelay = 5.f;
99 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Destroyable Objective|
Health|Regen", meta = (EditCondition = "bUsePassiveHealthRegen"))
100 float PassiveHealthRegenRate = 10.f;
102 UPROPERTY(EditAnywhere, Category = "Destroyable Objective|
Health", meta = (AllowPrivateAccess = true))
103 bool bUserOwnerTeam = true;
104 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Destroyable Objective|XP")
106 UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Destroyable Objective|XP")
109 UPROPERTY(EditDefaultsOnly)
110 bool bRegisterTargetOnBeginPlay = true;
113 float HealthRegenRate = 0.f;
114 float LastDamageTime = -MAX_FLT;
115 UAfflictionComponent* AfflictionComponent =
nullptr;
116 TWeakObjectPtr<UAfflictionInstance> PassiveRegenAffliction =
nullptr;
117 FTimerHandle PassiveHealthRegenTimer;
119 UPROPERTY(ReplicatedUsing = OnRep_Health)
121 UPROPERTY(ReplicatedUsing = OnRep_Team)
122 int Team = UINT8_MAX;
123 UPROPERTY(ReplicatedUsing = OnRep_Activation)
124 bool bIsActive = false;
125 bool bIsProperlyInitialized = false;
126 bool bHasTeamProperlyInitialized = false;
127 bool bHasHealthProperlyInitialized = false;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams(FObjectiveDamagedSignature, class ADestroyableObjective *, Objective, const float, Damage, struct FDamageEvent const &, DamageEvent, class AController *, EventInstigator, class AActor *, DamageCauser, class APlayerState *, InstigatorPlayerState)
#define NOT_INITIALIZED_HEALTH
Definition: DestroyableObjective.h:19
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FObjectiveEventSignature, class ADestroyableObjective *, Objective)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FObjectivePointTeamChangedSignature, int32, TeamOwner, ADestroyableObjective *, Objective)
EXPEventType
Definition: PlayerStats.h:13
Definition: DestroyableObjective.h:23
virtual bool IsDead() const override
Definition: DestroyableObjective.h:44
virtual float GetHealth() const override
Definition: DestroyableObjective.h:45
virtual void SetHealthRegenRate(float NewRate) override
Definition: DestroyableObjective.h:48
virtual float GetMaxHealth() const override
Definition: DestroyableObjective.h:46
virtual UAfflictionComponent * GetAfflictionComponent() const override
Definition: DestroyableObjective.h:50
Definition: HealthInterface.h:28
Definition: TeamInterface.h:26