public void ApplyDamage(DamageInfo info) { damageModifiers.RemoveAll((p) => { return p == null; }); info.amount = DamageModifier.ApplyDamageModifiers(info.amount, info.type, damageModifiers); currentHealth = Mathf.Clamp(currentHealth - info.amount, 0, maximumHealth); if (info.amount > 0) { changeHistory.Add(info); damageHistory.Add(info); InvokeOnDamage(info); } if (info.amount < 0) { changeHistory.Add(info); healHistory.Add(info); InvokeOnHeal(info); } if (currentHealth == 0) { InvokeOnDeath(info); if (info.responsibleAgent != null && responsibleAgent != null) Console.PrintText(info.responsibleAgent.GetName() + "(ID: " + info.responsibleAgent.GetID() + ") killed " + responsibleAgent.GetName() + "(ID: " + responsibleAgent.GetID() + ") with " + info.damageIdentifier); } }
void IHealthEvent.OnHealReceived(DamageInfo info) { if ((triggerOn & HealthEventFlags.OnHealReceived) > 0) Trigger(); }
void IHealthEvent.OnDeath(DamageInfo info) { if ((triggerOn & HealthEventFlags.OnDeath) > 0) Trigger(); }
private void InvokeOnHeal(DamageInfo info) { Refresh(); if (list != null) foreach (IHE t in list) { t.OnHealReceived(info); } }
private void InvokeOnDeath(DamageInfo info) { Refresh(); if (list != null) foreach (IHE t in list) { t.OnDeath(info); } }
private void AttemptDamage(Collider target) { interimDamageInfo = BuildDamageInfo(target); IEnumerable<DamageReceiver> list = target.GetPhysicsRoot().GetComponents<DamageReceiver>(); foreach (DamageReceiver c in list) { c.RequestHandshake(this); } }
void IDamageEvent.OnHealSent(DamageInfo info) { if ((triggerOn & DamageEventFlags.OnHealSent) > 0) Trigger(); }