引入属性、伤害管线
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using SepCore.Components;
|
||||
using SepCore.Battle;
|
||||
using SepCore.Components;
|
||||
using SepCore.Definition;
|
||||
using SepCore.CustomUtility;
|
||||
using UnityEngine;
|
||||
@@ -18,22 +19,54 @@ namespace SepCore.Entity
|
||||
|
||||
public abstract ImpactData GetImpactData();
|
||||
|
||||
public void ApplyDamage(EntityBase attacker, int damageHP)
|
||||
public void ApplyDamage(EntityBase attacker, in DamageResult damageResult, Vector3? hitPosition = null)
|
||||
{
|
||||
if (damageResult.IsDodge)
|
||||
{
|
||||
_healthComponent.TakeDamage(0, false, true, hitPosition);
|
||||
return;
|
||||
}
|
||||
|
||||
float fromHPRatio = _healthComponent.HealthRatio;
|
||||
_healthComponent.TakeDamage(damageHP);
|
||||
_healthComponent.TakeDamage(damageResult.Damage, damageResult.IsCrit, false, hitPosition);
|
||||
float toHPRatio = _healthComponent.HealthRatio;
|
||||
if (fromHPRatio > toHPRatio)
|
||||
{
|
||||
GameEntry.HPBar.ShowHPBar(this, fromHPRatio, toHPRatio);
|
||||
}
|
||||
|
||||
if (damageResult.IsLifeSteal && attacker != null)
|
||||
{
|
||||
HealthComponent attackerHealth = attacker.GetComponent<HealthComponent>();
|
||||
if (attackerHealth == null && attacker is WeaponBase weapon)
|
||||
{
|
||||
attackerHealth = weapon.GetComponentInParent<HealthComponent>();
|
||||
}
|
||||
|
||||
if (attackerHealth != null)
|
||||
{
|
||||
attackerHealth.TryTriggerLifeSteal(damageResult.LifeStealAmount);
|
||||
}
|
||||
}
|
||||
|
||||
if (_healthComponent.CurrentHealth <= 0)
|
||||
{
|
||||
OnDead(attacker);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyDamage(EntityBase attacker, int damageHP)
|
||||
{
|
||||
ApplyDamage(attacker, new DamageResult
|
||||
{
|
||||
Damage = damageHP,
|
||||
IsDodge = false,
|
||||
IsCrit = false,
|
||||
IsLifeSteal = false,
|
||||
LifeStealAmount = 0
|
||||
});
|
||||
}
|
||||
|
||||
protected override void OnInit(object userData)
|
||||
{
|
||||
base.OnInit(userData);
|
||||
|
||||
Reference in New Issue
Block a user