示例#1
0
 /// <summary>
 ///     If the damage in a DamageableComponent was changed, this function should be called.
 /// </summary>
 /// <remarks>
 ///     This updates cached damage information, flags the component as dirty, and raises a damage changed event.
 ///     The damage changed event is used by other systems, such as damage thresholds.
 /// </remarks>
 public void DamageChanged(DamageableComponent component, DamageSpecifier?damageDelta = null)
 {
     component.DamagePerGroup = component.Damage.GetDamagePerGroup();
     component.TotalDamage    = component.Damage.Total;
     component.Dirty();
     RaiseLocalEvent(component.Owner.Uid, new DamageChangedEvent(component, damageDelta), false);
 }
        /// <summary>
        ///     If the damage in a DamageableComponent was changed, this function should be called.
        /// </summary>
        /// <remarks>
        ///     This updates cached damage information, flags the component as dirty, and raises a damage changed event.
        ///     The damage changed event is used by other systems, such as damage thresholds.
        /// </remarks>
        public void DamageChanged(DamageableComponent component, DamageSpecifier?damageDelta = null,
                                  bool interruptsDoAfters = true)
        {
            component.DamagePerGroup = component.Damage.GetDamagePerGroup();
            component.TotalDamage    = component.Damage.Total;
            component.Dirty();

            if (EntityManager.TryGetComponent <AppearanceComponent>(component.Owner, out var appearance) && damageDelta != null)
            {
                appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, damageDelta.GetDamagePerGroup().Keys.ToList());
            }
            RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
        }