Files
OldThink/Content.Server/Damage/Systems/DamagePopupSystem.cs
ThereDrD0 3f005b158b Ремув попапа сна (#146)
* remove: remove ZZZ popup

* fix: client popup for target doll
2024-03-11 02:07:37 +03:00

42 lines
1.3 KiB
C#

using Content.Server.Damage.Components;
using Content.Server.Popups;
using Content.Shared.Damage;
using Robust.Shared.Player;
namespace Content.Server.Damage.Systems;
public sealed class DamagePopupSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DamagePopupComponent, DamageChangedEvent>(OnDamageChange);
}
private void OnDamageChange(EntityUid uid, DamagePopupComponent component, DamageChangedEvent args)
{
if (args.DamageDelta != null)
{
var damageTotal = args.Damageable.TotalDamage;
var damageDelta = args.DamageDelta.GetTotal();
var msg = component.Type switch
{
DamagePopupType.Delta => damageDelta.ToString(),
DamagePopupType.Total => damageTotal.ToString(),
DamagePopupType.Combined => damageDelta + " | " + damageTotal,
DamagePopupType.Hit => "!",
_ => "Invalid type",
};
if (args.Origin.HasValue)
_popupSystem.PopupEntity(msg, uid, args.Origin.Value);
else
_popupSystem.PopupEntity(msg, uid);
}
}
}