コード例 #1
0
        private void ProcessDamage(DamageInfo damageInfo)
        {
            if (!_unit.InZone || _unit.IsAttackable != ErrorCodes.NoError || _unit.States.Dead || _unit.IsInvulnerable)
            {
                return;
            }

            var totalDamage         = 0.0;
            var totalKers           = 0.0;
            var totalAbsorbedDamage = 0.0;

            foreach (var damage in damageInfo.CalculateDamages(_unit))
            {
                var partialDamage = CalculateAbsorbedDamage(damage.value, ref totalAbsorbedDamage);
                if (partialDamage <= 0.0)
                {
                    continue;
                }

                var resist = _unit.GetResistByDamageType(damage.type);
                partialDamage -= (partialDamage * resist);

                var kers = CalculateKersValue(damage.type, partialDamage);
                if (kers > 0.0)
                {
                    _unit.Core += kers;
                    totalKers  += kers;
                }

                totalDamage += partialDamage;
            }

            var h = DamageTaken;

            if (h == null)
            {
                return;
            }

            var e = new DamageTakenEventArgs
            {
                TotalDamage     = totalDamage,
                TotalCoreDamage = totalAbsorbedDamage,
                TotalKers       = totalKers,
                IsCritical      = damageInfo.IsCritical,
                IsKillingBlow   = false
            };

            h(damageInfo.attacker, e);
        }