mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* 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
28 lines
916 B
C#
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);
|
|
}
|
|
}
|