Added event when health is increased

This commit is contained in:
TjgL 2025-04-17 20:25:40 +02:00
parent d0e1d8cf39
commit 5b2743ab2f
4 changed files with 11 additions and 4 deletions

BIN
Content/Legumix/Player/BP_Play.uasset (Stored with Git LFS)

Binary file not shown.

View File

@ -31,6 +31,13 @@ void ULMHealthComponent::RegisterHitBoxes()
}
}
void ULMHealthComponent::AddHealth(const float AddedHealth, const bool NoLimits)
{
Health = FMath::Clamp(Health + AddedHealth, 0.0f, NoLimits ? INT_MAX : MaxHealth);
OnHealthChanged.Broadcast(Health, AddedHealth);
}
void ULMHealthComponent::TakeDamage_Implementation(const float Damage)
{
if (Damage <= 0.0f)

View File

@ -296,7 +296,7 @@ void ALMPlayer::DoLedgeGrabCheck()
if (Results)
{
FHitResult CapsuleCheck;
float HalfHeight = LegumixMovementComponent->bWantsToCrouch ? LegumixMovementComponent->CrouchedHalfHeight : GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
float HalfHeight = LegumixMovementComponent->bWantsToCrouch ? LegumixMovementComponent->GetCrouchedHalfHeight() : GetCapsuleComponent()->GetScaledCapsuleHalfHeight();
const FVector Offset = Hit.ImpactPoint + FVector(0, 0, HalfHeight + GetCapsuleComponent()->GetScaledCapsuleRadius());
const bool IsObstructed = UKismetSystemLibrary::CapsuleTraceSingleByProfile(GetWorld(), Offset, Offset,

View File

@ -71,7 +71,7 @@ public:
* @param NoLimits If sets, ignore the component's MaxHealth value.
*/
UFUNCTION(BlueprintCallable, Category=Legumix, meta=(Keywords = "Refill, Health"))
void AddHealth(const float AddedHealth, const bool NoLimits = false) { Health = FMath::Clamp(Health + AddedHealth, 0.0f, NoLimits ? INT_MAX : MaxHealth); }
void AddHealth(const float AddedHealth, const bool NoLimits = false);
/**
* Event automatically called when the character receives damages from an attack source.