CatStation/Content.Server/Damage/Systems/DamageRandomPopupSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

28 lines
916 B
C#

using Content.Server.Damage.Components;
using Content.Server.Popups;
using Content.Shared.Damage;
using Content.Shared.Damage.Systems;
using Robust.Shared.Player;
using Robust.Shared.Random;
namespace Content.Server.Damage.Systems;
/// <summary>
/// Outputs a random pop-up from the strings list when an object receives damage
/// </summary>
public sealed partial class DamageRandomPopupSystem : EntitySystem
{
[Dependency] private PopupSystem _popupSystem = default!;
[Dependency] private IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DamageRandomPopupComponent, DamageChangedEvent>(OnDamageChange);
}
private void OnDamageChange(EntityUid uid, DamageRandomPopupComponent component, DamageChangedEvent args)
{
_popupSystem.PopupEntity(Loc.GetString(_random.Pick(component.Popups)), uid);
}
}