using Content.Shared.Alert;
using Content.Shared.StatusEffectNew.Components;
namespace Content.Shared.StatusEffectNew;
///
/// Handles displaying status effects that should show an alert, optionally with a duration.
///
public sealed partial class StatusEffectAlertSystem : EntitySystem
{
[Dependency] private AlertsSystem _alerts = default!;
[Dependency] private EntityQuery _effectQuery = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnStatusEffectApplied);
SubscribeLocalEvent(OnStatusEffectRemoved);
SubscribeLocalEvent(OnEndTimeUpdated);
}
private void OnStatusEffectApplied(Entity ent, ref StatusEffectAppliedEvent args)
{
if (!_effectQuery.TryComp(ent, out var effectComp))
return;
_alerts.UpdateAlert(args.Target, ent.Comp.Alert, cooldown: ent.Comp.ShowDuration ? effectComp.EndEffectTime : null);
}
private void OnStatusEffectRemoved(Entity ent, ref StatusEffectRemovedEvent args)
{
_alerts.ClearAlert(args.Target, ent.Comp.Alert);
}
private void OnEndTimeUpdated(Entity ent, ref StatusEffectEndTimeUpdatedEvent args)
{
_alerts.UpdateAlert(args.Target, ent.Comp.Alert, cooldown: ent.Comp.ShowDuration ? args.EndTime : null);
}
}