Download LyraStarterGame/Source/LyraGame/Character/LyraHealthComponent.h from Alexhas2/unitysamples: direct link, hf CLI and curl.
- Browser
- Download file 4.72 kB
-
https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Character/LyraHealthComponent.h
- Command line
-
hf download hf://datasets/Alexhas2/unitysamples/LyraStarterGame/Source/LyraGame/Character/LyraHealthComponent.h
-
curl -L -o LyraHealthComponent.h https://huggingface.co/datasets/Alexhas2/unitysamples/resolve/main/LyraStarterGame/Source/LyraGame/Character/LyraHealthComponent.h
4.72 kB
| // Copyright Epic Games, Inc. All Rights Reserved. | |
| class ULyraHealthComponent; | |
| class ULyraAbilitySystemComponent; | |
| class ULyraHealthSet; | |
| class UObject; | |
| struct FFrame; | |
| struct FGameplayEffectSpec; | |
| DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FLyraHealth_DeathEvent, AActor*, OwningActor); | |
| DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FLyraHealth_AttributeChanged, ULyraHealthComponent*, HealthComponent, float, OldValue, float, NewValue, AActor*, Instigator); | |
| /** | |
| * ELyraDeathState | |
| * | |
| * Defines current state of death. | |
| */ | |
| UENUM(BlueprintType) | |
| enum class ELyraDeathState : uint8 | |
| { | |
| NotDead = 0, | |
| DeathStarted, | |
| DeathFinished | |
| }; | |
| /** | |
| * ULyraHealthComponent | |
| * | |
| * An actor component used to handle anything related to health. | |
| */ | |
| UCLASS(MinimalAPI, Blueprintable, Meta=(BlueprintSpawnableComponent)) | |
| class ULyraHealthComponent : public UGameFrameworkComponent | |
| { | |
| GENERATED_BODY() | |
| public: | |
| UE_API ULyraHealthComponent(const FObjectInitializer& ObjectInitializer); | |
| // Returns the health component if one exists on the specified actor. | |
| UFUNCTION(BlueprintPure, Category = "Lyra|Health") | |
| static ULyraHealthComponent* FindHealthComponent(const AActor* Actor) { return (Actor ? Actor->FindComponentByClass<ULyraHealthComponent>() : nullptr); } | |
| // Initialize the component using an ability system component. | |
| UFUNCTION(BlueprintCallable, Category = "Lyra|Health") | |
| UE_API void InitializeWithAbilitySystem(ULyraAbilitySystemComponent* InASC); | |
| // Uninitialize the component, clearing any references to the ability system. | |
| UFUNCTION(BlueprintCallable, Category = "Lyra|Health") | |
| UE_API void UninitializeFromAbilitySystem(); | |
| // Returns the current health value. | |
| UFUNCTION(BlueprintCallable, Category = "Lyra|Health") | |
| UE_API float GetHealth() const; | |
| // Returns the current maximum health value. | |
| UFUNCTION(BlueprintCallable, Category = "Lyra|Health") | |
| UE_API float GetMaxHealth() const; | |
| // Returns the current health in the range [0.0, 1.0]. | |
| UFUNCTION(BlueprintCallable, Category = "Lyra|Health") | |
| UE_API float GetHealthNormalized() const; | |
| UFUNCTION(BlueprintCallable, Category = "Lyra|Health") | |
| ELyraDeathState GetDeathState() const { return DeathState; } | |
| UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "Lyra|Health", Meta = (ExpandBoolAsExecs = "ReturnValue")) | |
| bool IsDeadOrDying() const { return (DeathState > ELyraDeathState::NotDead); } | |
| // Begins the death sequence for the owner. | |
| UE_API virtual void StartDeath(); | |
| // Ends the death sequence for the owner. | |
| UE_API virtual void FinishDeath(); | |
| // Applies enough damage to kill the owner. | |
| UE_API virtual void DamageSelfDestruct(bool bFellOutOfWorld = false); | |
| public: | |
| // Delegate fired when the health value has changed. This is called on the client but the instigator may not be valid | |
| UPROPERTY(BlueprintAssignable) | |
| FLyraHealth_AttributeChanged OnHealthChanged; | |
| // Delegate fired when the max health value has changed. This is called on the client but the instigator may not be valid | |
| UPROPERTY(BlueprintAssignable) | |
| FLyraHealth_AttributeChanged OnMaxHealthChanged; | |
| // Delegate fired when the death sequence has started. | |
| UPROPERTY(BlueprintAssignable) | |
| FLyraHealth_DeathEvent OnDeathStarted; | |
| // Delegate fired when the death sequence has finished. | |
| UPROPERTY(BlueprintAssignable) | |
| FLyraHealth_DeathEvent OnDeathFinished; | |
| protected: | |
| UE_API virtual void OnUnregister() override; | |
| UE_API void ClearGameplayTags(); | |
| UE_API virtual void HandleHealthChanged(AActor* DamageInstigator, AActor* DamageCauser, const FGameplayEffectSpec* DamageEffectSpec, float DamageMagnitude, float OldValue, float NewValue); | |
| UE_API virtual void HandleMaxHealthChanged(AActor* DamageInstigator, AActor* DamageCauser, const FGameplayEffectSpec* DamageEffectSpec, float DamageMagnitude, float OldValue, float NewValue); | |
| UE_API virtual void HandleOutOfHealth(AActor* DamageInstigator, AActor* DamageCauser, const FGameplayEffectSpec* DamageEffectSpec, float DamageMagnitude, float OldValue, float NewValue); | |
| UFUNCTION() | |
| UE_API virtual void OnRep_DeathState(ELyraDeathState OldDeathState); | |
| protected: | |
| // Ability system used by this component. | |
| UPROPERTY() | |
| TObjectPtr<ULyraAbilitySystemComponent> AbilitySystemComponent; | |
| // Health set used by this component. | |
| UPROPERTY() | |
| TObjectPtr<const ULyraHealthSet> HealthSet; | |
| // Replicated state used to handle dying. | |
| UPROPERTY(ReplicatedUsing = OnRep_DeathState) | |
| ELyraDeathState DeathState; | |
| }; | |