private void OnDamageChanged(EntityUid uid, BloodstreamComponent component, DamageChangedEvent args) { if (args.DamageDelta is null) { return; } // TODO probably cache this or something. humans get hurt a lot if (!_prototypeManager.TryIndex <DamageModifierSetPrototype>(component.DamageBleedModifiers, out var modifiers)) { return; } var bloodloss = DamageSpecifier.ApplyModifierSet(args.DamageDelta, modifiers); if (bloodloss.Empty) { return; } var oldBleedAmount = component.BleedAmount; var total = bloodloss.Total; var totalFloat = total.Float(); TryModifyBleedAmount(uid, totalFloat, component); var prob = Math.Clamp(totalFloat / 50, 0, 1); var healPopupProb = Math.Clamp(Math.Abs(totalFloat) / 25, 0, 1); if (totalFloat > 0 && _robustRandom.Prob(prob)) { TryModifyBloodLevel(uid, (-total) / 5, component); SoundSystem.Play(Filter.Pvs(uid), component.InstantBloodSound.GetSound(), uid, AudioParams.Default); } else if (totalFloat < 0 && oldBleedAmount > 0 && _robustRandom.Prob(healPopupProb)) { // Magically, this damage has healed some bleeding, likely // because it's burn damage that cauterized their wounds. // We'll play a special sound and popup for feedback. SoundSystem.Play(Filter.Pvs(uid), component.BloodHealedSound.GetSound(), uid, AudioParams.Default); _popupSystem.PopupEntity(Loc.GetString("bloodstream-component-wounds-cauterized"), uid, Filter.Entities(uid)); ; } }
/// <summary> /// Check if any thresholds were reached. if they were, execute them. /// </summary> public void Execute(EntityUid uid, DestructibleComponent component, DamageChangedEvent args) { foreach (var threshold in component.Thresholds) { if (threshold.Reached(args.Damageable, this)) { RaiseLocalEvent(uid, new DamageThresholdReached(component, threshold)); threshold.Execute(uid, this, EntityManager); } // if destruction behavior (or some other deletion effect) occurred, don't run other triggers. if (EntityManager.IsQueuedForDeletion(uid) || Deleted(uid)) { return; } } }
/// <summary> /// Destroy the light bulb if the light took any damage. /// </summary> public void HandleLightDamaged(EntityUid uid, PoweredLightComponent component, DamageChangedEvent args) { // Was it being repaired, or did it take damage? if (args.DamageIncreased) { // Eventually, this logic should all be done by this (or some other) system, not a component. TryDestroyBulb(uid, component); } }
public void UpdateState(EntityUid _, MobStateComponent component, DamageChangedEvent args) { component.UpdateState(args.Damageable.TotalDamage); }
public void DamageChangedListener(EntityUid _, DamageableComponent comp, DamageChangedEvent args) { DamageChanged = true; }
private void OnHealthChanged(DamageChangedEvent _) { RunDelayedCheck(); }
public void UpdateVisuals(EntityUid _, WindowComponent component, DamageChangedEvent args) { component.UpdateVisuals(args.Damageable.TotalDamage); }