Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8064a47c2c
BIN
Content/Legumix/Ennemy/BP_HealthComponent.uasset
(Stored with Git LFS)
BIN
Content/Legumix/Ennemy/BP_HealthComponent.uasset
(Stored with Git LFS)
Binary file not shown.
@ -36,14 +36,14 @@ void ULMHealthComponent::TakeDamage_Implementation(const float Damage)
|
||||
if (Damage <= 0.0f)
|
||||
return;
|
||||
|
||||
OnHit(Damage);
|
||||
OnDamageReceived(Damage);
|
||||
OnHealthChanged.Broadcast(Health, Damage);
|
||||
|
||||
if (Health <= 0.0f)
|
||||
Kill();
|
||||
}
|
||||
|
||||
void ULMHealthComponent::OnHit_Implementation(const float Damage)
|
||||
void ULMHealthComponent::OnDamageReceived_Implementation(const float Damage)
|
||||
{
|
||||
Health = FMath::Clamp(Health - Damage, 0.0f, MaxHealth);
|
||||
}
|
||||
@ -55,9 +55,10 @@ void ULMHealthComponent::Kill()
|
||||
OnDeath.Broadcast();
|
||||
}
|
||||
|
||||
void ULMHealthComponent::HitBoxHit(ULMHitBox* HitBox, float Damage)
|
||||
void ULMHealthComponent::HitBoxHit(ULMHitBox* HitBox, const float Damage, const FVector& Origin, const FHitResult& HitInfo)
|
||||
{
|
||||
TakeDamage(Damage);
|
||||
OnHit(Damage, Origin, HitInfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,13 +12,13 @@ ULMHitBox::ULMHitBox()
|
||||
PrimaryComponentTick.bCanEverTick = true;
|
||||
}
|
||||
|
||||
void ULMHitBox::OnHit(const FLMBulletInfo& BulletInfo)
|
||||
void ULMHitBox::OnHit(const FLMBulletInfo& BulletInfo, const FHitResult& Hit)
|
||||
{
|
||||
const float Damage = BulletInfo.Damage;
|
||||
const double Distance = FVector::Distance(BulletInfo.Origin, GetComponentLocation());
|
||||
|
||||
const float TotalDamage = CalculateDamage(Damage, Distance, BulletInfo.Falloff, BulletInfo.MaxDistance);
|
||||
OnHitBoxHit.Broadcast(this, TotalDamage);
|
||||
OnHitBoxHit.Broadcast(this, TotalDamage, BulletInfo.Origin, Hit);
|
||||
}
|
||||
|
||||
bool ULMHitBox::CanBeHitByTeam(const ETeam Team) const
|
||||
|
@ -170,7 +170,7 @@ void ALMPlayer::FireBullets(const FLMBulletInfo Settings)
|
||||
continue;
|
||||
|
||||
HitSomething = true;
|
||||
HitBox->OnHit(Settings);
|
||||
HitBox->OnHit(Settings, OutHit);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -49,9 +49,11 @@ public:
|
||||
* Called automatically when a hitbox is hit.
|
||||
* @param HitBox The hitbox that was hit.
|
||||
* @param Damage The damage received by the hitbox.
|
||||
* @param Origin The origin of the damage.
|
||||
* @param HitInfo Information about the ray that hit the hitbox.
|
||||
*/
|
||||
UFUNCTION()
|
||||
void HitBoxHit(ULMHitBox* HitBox, float Damage);
|
||||
void HitBoxHit(ULMHitBox* HitBox, float Damage, const FVector& Origin, const FHitResult& HitInfo);
|
||||
|
||||
/**
|
||||
* Applies the amount of damage received to the component.
|
||||
@ -60,7 +62,7 @@ public:
|
||||
* @param Damage The damage received.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category=Legumix)
|
||||
void OnHit(float Damage);
|
||||
void OnDamageReceived(float Damage);
|
||||
|
||||
/**
|
||||
* Adds an amount of health to the character.
|
||||
@ -70,6 +72,15 @@ public:
|
||||
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); }
|
||||
|
||||
/**
|
||||
* Event automatically called when the character receives damages from an attack source.
|
||||
* @param Damage The damage received.
|
||||
* @param Origin The origin of the damage.
|
||||
* @param HitInfo The collisions informations.
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Legumix, meta=(Keywords = "Refill"))
|
||||
void OnHit(float Damage, const FVector& Origin, const FHitResult& HitInfo);
|
||||
|
||||
/**
|
||||
* Completely refill the health of the component.
|
||||
*/
|
||||
|
@ -16,11 +16,11 @@ class LEGUMEMIX_API ULMHitBox : public UCapsuleComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FHitBoxHitSignature, ULMHitBox*, HitBox, float, Damage);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_FourParams(FHitBoxHitSignature, ULMHitBox*, HitBox, float, Damage, const FVector&, Origin, const FHitResult&, HitInfo);
|
||||
|
||||
public:
|
||||
ULMHitBox();
|
||||
void OnHit(const FLMBulletInfo& BulletInfo);
|
||||
void OnHit(const FLMBulletInfo& BulletInfo, const FHitResult& Hit);
|
||||
void SetHealthComponent(ULMHealthComponent* NewHealthComponent) { HealthComponent = NewHealthComponent; }
|
||||
bool CanBeHitByTeam(ETeam Team) const;
|
||||
|
||||
|
Reference in New Issue
Block a user