update 1.2.0
This commit is contained in:
@@ -16,6 +16,7 @@ namespace EmeraldAI
|
||||
public int CurrentHealth = 50;
|
||||
public int StartingHealth = 50;
|
||||
public int HealRate = 0;
|
||||
public bool AttachHitEffects = false;
|
||||
public bool Immortal = false;
|
||||
public List<string> CurrentActiveEffects;
|
||||
public bool HitEffectFoldout;
|
||||
@@ -37,6 +38,8 @@ namespace EmeraldAI
|
||||
public event DeathHandler OnDeath;
|
||||
public delegate void HealRateTickHandler();
|
||||
public event HealRateTickHandler OnHealRateTick;
|
||||
public delegate void OnHealingReceivedHandler();
|
||||
public event OnHealingReceivedHandler OnHealingReceived;
|
||||
public delegate void HealthChangeHandler();
|
||||
public event HealthChangeHandler OnHealthChange;
|
||||
EmeraldSystem EmeraldComponent;
|
||||
@@ -55,7 +58,7 @@ namespace EmeraldAI
|
||||
{
|
||||
CurrentHealth = StartingHealth;
|
||||
EmeraldComponent = GetComponent<EmeraldSystem>();
|
||||
EmeraldComponent.CombatComponent.OnExitCombat += StartHealing; //Subscribe to the OnExitCombat event for StartHealing
|
||||
EmeraldComponent.CombatComponent.OnExitCombat += RecoverHealth; //Subscribe to the OnExitCombat event for RecoverHealth
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -182,21 +185,23 @@ namespace EmeraldAI
|
||||
/// </summary>
|
||||
public void KillAI()
|
||||
{
|
||||
EmeraldAPI.Combat.KillAI(EmeraldComponent);
|
||||
EmeraldComponent.CombatComponent.ReceivedRagdollForceAmount = 1;
|
||||
Health = 0;
|
||||
Death();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called through the OnExitCombat callback when an AI exits combat. This heals the AI over time according to its HealRate.
|
||||
/// </summary>
|
||||
void StartHealing ()
|
||||
void RecoverHealth ()
|
||||
{
|
||||
StartCoroutine(StartHealingInternal());
|
||||
StartCoroutine(RecoverHealthInternal());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called through the StartHealing function which increases the AI's health each HealRate. This gets canceled if the target enters combat.
|
||||
/// </summary>
|
||||
IEnumerator StartHealingInternal ()
|
||||
IEnumerator RecoverHealthInternal()
|
||||
{
|
||||
float t = 0;
|
||||
|
||||
@@ -219,6 +224,16 @@ namespace EmeraldAI
|
||||
CurrentHealth = StartingHealth;
|
||||
}
|
||||
|
||||
public void UpdateHealTick ()
|
||||
{
|
||||
OnHealRateTick?.Invoke();
|
||||
}
|
||||
|
||||
public void UpdateHealingReceived()
|
||||
{
|
||||
OnHealingReceived?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the AI's Max Health and Current Health.
|
||||
/// </summary>
|
||||
@@ -240,7 +255,7 @@ namespace EmeraldAI
|
||||
if (RandomBloodEffect != null)
|
||||
{
|
||||
GameObject SpawnedBlood = EmeraldObjectPool.SpawnEffect(RandomBloodEffect, Vector3.zero, EmeraldComponent.transform.rotation, EmeraldComponent.HealthComponent.HitEffectTimeoutSeconds) as GameObject;
|
||||
SpawnedBlood.transform.SetParent(EmeraldComponent.transform);
|
||||
if (AttachHitEffects) SpawnedBlood.transform.SetParent(EmeraldComponent.transform);
|
||||
SpawnedBlood.transform.position = EmeraldComponent.CombatComponent.DamagePosition() + EmeraldComponent.HealthComponent.HitEffectPosOffset;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user