- #pragma once
- #include "CoreMinimal.h"
- #include "Components/ActorComponent.h"
- #include "HealthSystem.generated.h"
- DECLARE_EVENT_OneParam(UCPP_HealthComponent, DamageTakenEvent, float )
- DECLARE_EVENT_OneParam(UCPP_HealthComponent, HealDamageEvent, float )
- DECLARE_EVENT_OneParam(UCPP_HealthComponent, ShieldReceiveEvent, float )
- UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
- class SKYFRONTIER_API UHealthSystem : public UActorComponent
- {
- GENERATED_BODY()
- public:
-
- UHealthSystem();
-
- UFUNCTION(BlueprintPure)
- float GetHealth() const;
- UFUNCTION(BlueprintPure)
- float GetMaxHealth() const;
- UFUNCTION(BlueprintPure)
- float GetHealthAsPercentage() const;
- UFUNCTION(BlueprintPure)
- float GetShield() const;
- UFUNCTION(BlueprintCallable)
- void ModifyHealth(float Amount);
- UFUNCTION(BlueprintCallable)
- void TakeDamage(float Amount);
- UFUNCTION(BlueprintCallable)
- void RecoverHealth(float Amount);
- UFUNCTION(BlueprintCallable)
- void ReceiveShield(float Amount);
- UFUNCTION(BlueprintCallable)
- void RemoveShield(float Amount);
- protected:
- virtual void BeginPlay() override;
-
- public:
- DamageTakenEvent OnDamageTakenEvent;
- HealDamageEvent OnDamageHealedEvent;
- ShieldReceiveEvent OnShieldReceiveEvent;
- private:
- UPROPERTY(VisibleAnywhere)
- float Health;
- UPROPERTY(EditAnywhere)
- float MaxHealth;
- UPROPERTY(VisibleAnywhere)
- float Shield;
- };