Protptype of a wave based, first person shooter game made in Unreal Engine 4
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
MechDefence/Public/MHealthComponent.h

63 lines
2.0 KiB

// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "MHealthComponent.generated.h"
class UMHealthComponent;
DECLARE_DYNAMIC_MULTICAST_DELEGATE_SixParams(FOnHealthChangedSignature, UMHealthComponent*, HealthComp, float, Health, float, HealthDelta, const class UDamageType*, DamageType, class AController*, InstigatedBy, AActor*, DamageCauser);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnActorDeath, UMHealthComponent*, HealthComponent, AActor*, DeadActor, AActor*, KillerActor);
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
class MECHDEFENCE_API UMHealthComponent : public UActorComponent
{
GENERATED_BODY()
public:
UMHealthComponent();
protected:
virtual void BeginPlay() override;
bool bIsDead;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "HealthComponent")
float Health;
UPROPERTY(EditDefaultsOnly, Category = "HealthComponent", meta = (ClampMin = 0.f))
float DefaultHealth;
UFUNCTION()
void HandleTakeAnyDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);
public:
UFUNCTION(BlueprintCallable)
float GetHealth() const { return Health; }
UFUNCTION(BlueprintCallable)
float GetHealthRemappedInRange(float Min = 0.f, float Max = 1.f);
UFUNCTION(BlueprintCallable)
float GetDefaultHealth() const { return DefaultHealth; }
UFUNCTION(BlueprintCallable)
bool IsAtMaxHealth() const { return Health == DefaultHealth; }
UFUNCTION(BlueprintCallable)
bool IsDead() const { return bIsDead; };
UPROPERTY(BlueprintAssignable, Category = "Events")
FOnHealthChangedSignature OnHealthChanged;
UPROPERTY(BlueprintAssignable, Category = "Events")
FOnActorDeath OnActorDeath;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "HealthComponent")
bool bIsInvincible;
UFUNCTION(BlueprintCallable, Category = "HealthComponent")
void Heal(float HealAmount);
};