CatStation/Content.Shared/EntityEffects/Effects/StatusEffects/JitterEntityEffectSystem.cs
Pieter-Jan Briers 5168b5f3d4
IoC source gen compatibility (#43863)
* IoC source gen compatibility

Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter.

* Missed a spot
2026-05-09 03:29:58 +00:00

45 lines
1.5 KiB
C#

using Content.Shared.Jittering;
using Content.Shared.StatusEffect;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityEffects.Effects.StatusEffects;
// TODO: When Jittering is moved to new Status, make this use StatusEffectsContainerComponent.
/// <summary>
/// Applies the Jittering Status Effect to this entity.
/// The amount of time the Jittering is applied is modified by scale.
/// </summary>
/// <inheritdoc cref="EntityEffectSystem{T,TEffect}"/>
public sealed partial class JitterEntityEffectSystem : EntityEffectSystem<StatusEffectsComponent, Jitter>
{
[Dependency] private SharedJitteringSystem _jittering = default!;
protected override void Effect(Entity<StatusEffectsComponent> entity, ref EntityEffectEvent<Jitter> args)
{
var time = args.Effect.Time * args.Scale;
_jittering.DoJitter(entity, TimeSpan.FromSeconds(time), args.Effect.Refresh, args.Effect.Amplitude, args.Effect.Frequency);
}
}
/// <inheritdoc cref="EntityEffect"/>
public sealed partial class Jitter : EntityEffectBase<Jitter>
{
[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 string EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) =>
Loc.GetString("entity-effect-guidebook-jittering", ("chance", Probability));
}