Space Plunder
Loading...
Searching...
No Matches
HealthComponentBase.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"
7#include "HealthComponentBase.generated.h"
8
9// On Death sets off blueprint event
10DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnDeathEvent, AActor*, OwningActor, EDeathType, DeathType, AActor*, DeathCauser, AController*, DeathInstigator);
11// // On Shield Break sets off blueprint event
12// DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnShieldBreak);
13//On Health Changed event, Sets off a Blueprint event when health is changed
14//@TODO Remove Health Component as a var, Doesn't need to be sent everytime, just clogs up things
15DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnHealthChanged, float, Health, float, MaxHealth,const class UDamageType*, DamageType);
16
17// DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnInjuredBodyPart, EInjuredState, InjuredState);
18
19UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent) )
20class HEALTH_API UHealthComponentBase : public UActorComponent
21{
22 GENERATED_BODY()
23
24public:
25 UHealthComponentBase();
26
27 // Delegate fired when the health value has changed, Not for use on shielded Characters
28 UPROPERTY(BlueprintAssignable, Category = "Health")
29 FOnHealthChanged OnHealthChanged;
30 UPROPERTY(BlueprintAssignable, Category = "Health")
31 FOnDeathEvent OnDeath;
32
33 UFUNCTION(BlueprintCallable, Category = "Health")
34 FORCEINLINE float GetHealth() const { return Health;}
35 UFUNCTION(BlueprintCallable, Category= "Health")
36 FORCEINLINE float GetMaxHealth() const { return MaxHealth;};
37 UFUNCTION(BlueprintCallable, Category = "Health")
38 FORCEINLINE bool GetIsDead() const { return bDead;}
39
40 //- Save Load Game //
41 UFUNCTION(BlueprintCallable, Category= "Health")
42 void LoadHealthFromSave(const float LoadedHealth);
43 virtual bool LoadComponentData(const FString& SlotName);
44 virtual bool SaveComponentData(const FString& SlotName);
45
46 UFUNCTION(BlueprintCallable, Category = "Health")
47 void SetMaxHealth(const float Value){ MaxHealth = Value;};
48
49
50protected:
51 virtual void BeginPlay() override;
52
53 virtual void Death(AActor* Causer, AController* DeathInstigator, const UDamageType* DamageType);
54
55 UFUNCTION()
56 virtual void TakeDamage(AActor* DamagedActor, float Damage, const UDamageType* DamageType, AController* InstigatedBy, AActor* DamageCauser);
57 UFUNCTION()
58 void OnRep_Health();
59 UFUNCTION()
60 virtual void OnDeathReplicated();
61
62
63 UPROPERTY(ReplicatedUsing=OnRep_Health, EditAnywhere, BlueprintReadWrite, Category = "Health|General")
64 float MaxHealth = 100.0f;
65
66 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health|Debugging")
67 bool bDebuggingMode = false;
68 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health|Debugging", meta=(EditCondition="bDebuggingMode"))
69 bool bInfiniteHealth = false;
70
71
72private:
73 virtual void HealthDamage(const float Damage);
74
75 UPROPERTY(ReplicatedUsing=OnRep_Health)
76 float Health;
77 UPROPERTY(ReplicatedUsing=OnDeathReplicated)
78 bool bDead = false;
79
80 FTimerHandle HealthTimerHandle;
81
82};
83
84
EDeathType
Definition BaseData.h:53
UCLASS(Blueprintable, BlueprintType, ClassGroup=(BucciGames), meta=(BlueprintSpawnableComponent)) class CHATSYSTEM_API UChatSystemComponent
Definition ChatSystemComponent.h:13
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FOnDeathEvent, AActor *, OwningActor, EDeathType, DeathType, AActor *, DeathCauser, AController *, DeathInstigator)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnHealthChanged, float, Health, float, MaxHealth, const class UDamageType *, DamageType)
Definition Health.Build.cs:6