mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-11 19:31:12 +03:00
* part 1 * second pass * final fix * last fix i swear * an even bigger genius * regex missed this * should be all of em? * oops * yeah * Revert "should be all of em?" This reverts commit 4dd54d1b9a76977b4cf8d6008358e4dacdee6eb1. --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
41 lines
1.6 KiB
C#
41 lines
1.6 KiB
C#
using Content.Shared.Alert;
|
|
using Content.Shared.StatusEffectNew.Components;
|
|
|
|
namespace Content.Shared.StatusEffectNew;
|
|
|
|
/// <summary>
|
|
/// Handles displaying status effects that should show an alert, optionally with a duration.
|
|
/// </summary>
|
|
public sealed class StatusEffectAlertSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly AlertsSystem _alerts = default!;
|
|
|
|
[Dependency] private readonly EntityQuery<StatusEffectComponent> _effectQuery = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<StatusEffectAlertComponent, StatusEffectAppliedEvent>(OnStatusEffectApplied);
|
|
SubscribeLocalEvent<StatusEffectAlertComponent, StatusEffectRemovedEvent>(OnStatusEffectRemoved);
|
|
SubscribeLocalEvent<StatusEffectAlertComponent, StatusEffectEndTimeUpdatedEvent>(OnEndTimeUpdated);
|
|
}
|
|
|
|
private void OnStatusEffectApplied(Entity<StatusEffectAlertComponent> 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<StatusEffectAlertComponent> ent, ref StatusEffectRemovedEvent args)
|
|
{
|
|
_alerts.ClearAlert(args.Target, ent.Comp.Alert);
|
|
}
|
|
|
|
private void OnEndTimeUpdated(Entity<StatusEffectAlertComponent> ent, ref StatusEffectEndTimeUpdatedEvent args)
|
|
{
|
|
_alerts.UpdateAlert(args.Target, ent.Comp.Alert, cooldown: ent.Comp.ShowDuration ? args.EndTime : null);
|
|
}
|
|
}
|