using Content.Shared.Alert; using Content.Shared.EntityEffects; using Robust.Shared.Prototypes; using Robust.Shared.Timing; namespace Content.Server.EntityEffects.Effects; public sealed partial class AdjustAlert : EntityEffect { /// /// The specific Alert that will be adjusted /// [DataField(required: true)] public ProtoId AlertType; /// /// If true, the alert is removed after Time seconds. If Time was not specified the alert is removed immediately. /// [DataField] public bool Clear; /// /// Visually display cooldown progress over the alert icon. /// [DataField] public bool ShowCooldown; /// /// The length of the cooldown or delay before removing the alert (in seconds). /// [DataField] public float Time; //JUSTIFICATION: This just changes some visuals, doesn't need to be documented. protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => null; public override void Effect(EntityEffectBaseArgs args) { var alertSys = args.EntityManager.EntitySysManager.GetEntitySystem(); if (!args.EntityManager.HasComponent(args.TargetEntity)) return; if (Clear && Time <= 0) { alertSys.ClearAlert(args.TargetEntity, AlertType); } else { var timing = IoCManager.Resolve(); (TimeSpan, TimeSpan)? cooldown = null; if ((ShowCooldown || Clear) && Time > 0) cooldown = (timing.CurTime, timing.CurTime + TimeSpan.FromSeconds(Time)); alertSys.ShowAlert(args.TargetEntity, AlertType, cooldown: cooldown, autoRemove: Clear, showCooldown: ShowCooldown); } } }