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)
This commit is contained in:
SlamBamActionman
2024-06-30 05:43:43 +02:00
committed by GitHub
parent 250109f0b4
commit b9fa941ca6
127 changed files with 2199 additions and 1978 deletions

View File

@@ -0,0 +1,59 @@
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);
}
}
}