Move entity effects definitions to shared (#35614)
* Move entity effects to shared * relocate spawning to server * Generic version of EntityEffect for just raising event. * genericise everything * oops forgot to push you * some condensation * finish rebas * unwhite the space * oops forgot nuke * bad rebase fix * useless annotations begone --------- Co-authored-by: EmoGarbage404 <retron404@gmail.com>
This commit is contained in:
committed by
GitHub
parent
7ba81173bd
commit
bf41de18aa
58
Content.Shared/EntityEffects/Effects/AdjustAlert.cs
Normal file
58
Content.Shared/EntityEffects/Effects/AdjustAlert.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Content.Shared.Alert;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Shared.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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user