/// <summary>
        ///     Applies damage specified via a <see cref="DamageSpecifier"/>.
        /// </summary>
        /// <remarks>
        ///     <see cref="DamageSpecifier"/> is effectively just a dictionary of damage types and damage values. This
        ///     function just applies the container's resistances (unless otherwise specified) and then changes the
        ///     stored damage data. Division of group damage into types is managed by <see cref="DamageSpecifier"/>.
        /// </remarks>
        /// <returns>
        ///     Returns a <see cref="DamageSpecifier"/> with information about the actual damage changes. This will be
        ///     null if the user had no applicable components that can take damage.
        /// </returns>
        public DamageSpecifier?TryChangeDamage(EntityUid?uid, DamageSpecifier damage, bool ignoreResistances = false,
                                               bool interruptsDoAfters = true)
        {
            if (!EntityManager.TryGetComponent <DamageableComponent>(uid, out var damageable))
            {
                // TODO BODY SYSTEM pass damage onto body system
                return(null);
            }

            if (damage == null)
            {
                Logger.Error("Null DamageSpecifier. Probably because a required yaml field was not given.");
                return(null);
            }

            if (damage.Empty)
            {
                return(damage);
            }

            // Apply resistances
            if (!ignoreResistances)
            {
                if (damageable.DamageModifierSetId != null &&
                    _prototypeManager.TryIndex <DamageModifierSetPrototype>(damageable.DamageModifierSetId, out var modifierSet))
                {
                    damage = DamageSpecifier.ApplyModifierSet(damage, modifierSet);
                }

                var ev = new DamageModifyEvent(damage);
                RaiseLocalEvent(uid.Value, ev, false);
                damage = ev.Damage;

                if (damage.Empty)
                {
                    return(damage);
                }
            }

            // Copy the current damage, for calculating the difference
            DamageSpecifier oldDamage = new(damageable.Damage);

            damageable.Damage.ExclusiveAdd(damage);
            damageable.Damage.ClampMin(FixedPoint2.Zero);

            var delta = damageable.Damage - oldDamage;

            delta.TrimZeros();

            if (!delta.Empty)
            {
                DamageChanged(damageable, delta, interruptsDoAfters);
            }

            return(delta);
        }
 /// <summary>
 ///     Directly sets the damage specifier of a damageable component.
 /// </summary>
 /// <remarks>
 ///     Useful for some unfriendly folk. Also ensures that cached values are updated and that a damage changed
 ///     event is raised.
 /// </remarks>
 public void SetDamage(DamageableComponent damageable, DamageSpecifier damage)
 {
     damageable.Damage = damage;
     DamageChanged(damageable);
 }
 public DamageModifyEvent(DamageSpecifier damage)
 {
     Damage = damage;
 }