using Content.Shared.Alert; using Content.Shared.Chemistry.Reagent; using Robust.Shared.Prototypes; using Robust.Shared.Timing; namespace Content.Server.Chemistry.ReagentEffects; public sealed partial class AdjustAlert : ReagentEffect { /// /// The specific Alert that will be adjusted /// [DataField("alertType", required: true)] public AlertType Type; /// /// 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(ReagentEffectArgs args) { var alertSys = args.EntityManager.EntitySysManager.GetEntitySystem(); if (!args.EntityManager.HasComponent(args.SolutionEntity)) return; if (Clear && Time <= 0) { alertSys.ClearAlert(args.SolutionEntity, Type); } 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.SolutionEntity, Type, cooldown: cooldown, autoRemove: Clear, showCooldown: ShowCooldown); } } }