-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerHealthComponent.h
62 lines (42 loc) · 1.97 KB
/
PlayerHealthComponent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "PlayerHealthComponent.generated.h"
//On Health changed event
DECLARE_DYNAMIC_MULTICAST_DELEGATE_SevenParams(FOnHealthChangedSignature, UPlayerHealthComponent*, HealthComp, float, Armor, float, Health, float, HealthDelta, const class UDamageType*, DamageType, class AController*, InstigatedBy, AActor*,DamageCauser);
UCLASS( ClassGroup=(FPS), meta=(BlueprintSpawnableComponent) )
class SILENTRED2_API UPlayerHealthComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UPlayerHealthComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
bool bIsDead;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HealthComponent")
float DefaultArmor;
UPROPERTY(Replicated, BlueprintReadOnly, Category = "HealthComponent")
float Armor;
UPROPERTY(Replicated, BlueprintReadOnly, Category = "HealthComponent")
float Health;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HealthComponent")
float DefaultHealth;
UFUNCTION()
void HandleTakeAnyDamage(AActor* DamageActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);
UPROPERTY(BlueprintReadOnly, Category = "HealthComponent")
bool hasArmor;
UPROPERTY(Replicated, BlueprintReadOnly, Category = "HealthComponent")
float HealthToAdd = 100.0f;
UPROPERTY(Replicated, BlueprintReadOnly, Category = "HealthComponent")
float ArmourToAdd = 100.0f;
public:
UPROPERTY(BlueprintAssignable, Category = "Events")
FOnHealthChangedSignature OnHealthChanged;
UFUNCTION(BlueprintCallable, Category = "HealthComponent")
void AddHealth(float HealAmount);
UFUNCTION(BlueprintCallable, Category = "HealthComponent")
void AddArmor(float ArmorAdded);
};