Files
tbd-station-14/Content.Server/EntityEffects/Effects/AdjustAlert.cs
SlamBamActionman b9fa941ca6 Turn ReagentEffects into generic EntityEffects (#28168)
* Oh the possibilities

* Merge fixes

* Forgot to remote LavaSystem oops

* Changed EntityEffectArgs to EntityEffectBaseArgs and EntityEffectReagentArgs

* Throw exception for unimplemented effectargs

* Remove Json and overrideable datafields

* Fix test issues

* Actually fix the compiling issue

* Fix comments and remove EntityEffectArgs (no longer used, replaced with EntityEffectBaseArgs)
2024-06-30 13:43:43 +10:00

60 lines
1.9 KiB
C#

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
{
/// <summary>
/// The specific Alert that will be adjusted
/// </summary>
[DataField(required: true)]
public ProtoId<AlertPrototype> AlertType;
/// <summary>
/// If true, the alert is removed after Time seconds. If Time was not specified the alert is removed immediately.
/// </summary>
[DataField]
public bool Clear;
/// <summary>
/// Visually display cooldown progress over the alert icon.
/// </summary>
[DataField]
public bool ShowCooldown;
/// <summary>
/// The length of the cooldown or delay before removing the alert (in seconds).
/// </summary>
[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<AlertsSystem>();
if (!args.EntityManager.HasComponent<AlertsComponent>(args.TargetEntity))
return;
if (Clear && Time <= 0)
{
alertSys.ClearAlert(args.TargetEntity, AlertType);
}
else
{
var timing = IoCManager.Resolve<IGameTiming>();
(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);
}
}
}