Add DamagePopup, Target Entities, And Practice Laser Gun (#12317)

This commit is contained in:
ZeroDayDaemon
2022-11-05 11:32:00 -04:00
committed by GitHub
parent 364adb1b2c
commit 325ccc1c17
13 changed files with 288 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
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.Total;
var msg = component.Type switch
{
DamagePopupType.Delta => damageDelta.ToString(),
DamagePopupType.Total => damageTotal.ToString(),
DamagePopupType.Combined => damageDelta + " | " + damageTotal,
DamagePopupType.Hit => "!",
_ => "Invalid type",
};
_popupSystem.PopupEntity(msg, uid, Filter.Pvs(uid, 2F, EntityManager));
}
}
}