Files
tbd-station-14/Content.Server/EntityEffects/Effects/StatusEffects/Jitter.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

43 lines
1.3 KiB
C#

using Content.Shared.Chemistry.Reagent;
using Content.Shared.EntityEffects;
using Content.Shared.Jittering;
using Robust.Shared.Prototypes;
namespace Content.Server.EntityEffects.Effects.StatusEffects;
/// <summary>
/// Adds the jitter status effect to a mob.
/// This doesn't use generic status effects because it needs to
/// take in some parameters that JitterSystem needs.
/// </summary>
public sealed partial class Jitter : EntityEffect
{
[DataField]
public float Amplitude = 10.0f;
[DataField]
public float Frequency = 4.0f;
[DataField]
public float Time = 2.0f;
/// <remarks>
/// true - refresh jitter time, false - accumulate jitter time
/// </remarks>
[DataField]
public bool Refresh = true;
public override void Effect(EntityEffectBaseArgs args)
{
var time = Time;
if (args is EntityEffectReagentArgs reagentArgs)
time *= reagentArgs.Scale.Float();
args.EntityManager.EntitySysManager.GetEntitySystem<SharedJitteringSystem>()
.DoJitter(args.TargetEntity, TimeSpan.FromSeconds(time), Refresh, Amplitude, Frequency);
}
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Loc.GetString("reagent-effect-guidebook-jittering", ("chance", Probability));
}