using Content.Shared.Stunnable; using JetBrains.Annotations; using Robust.Shared.Prototypes; namespace Content.Shared.EntityEffects.Effects.StatusEffects; /// /// Changes the knockdown timer on an entity or causes knockdown. /// [UsedImplicitly] public sealed partial class ModifyKnockdown : EntityEffect { /// /// Should we only affect those with crawler component? Note if this is false, it will paralyze non-crawler's instead. /// [DataField] public bool Crawling; /// /// Should we drop items when we fall? /// [DataField] public bool Drop; /// /// Time for which knockdown should be applied. Behaviour changes according to . /// [DataField] public TimeSpan Time = TimeSpan.FromSeconds(0.5); /// /// Should this effect add the status effect, remove time from it, or set its cooldown? /// [DataField] public StatusEffectMetabolismType Type = StatusEffectMetabolismType.Add; /// /// Should this effect add knockdown?, remove time from it?, or set its cooldown? /// [DataField] public bool Refresh = true; /// public override void Effect(EntityEffectBaseArgs args) { var stunSys = args.EntityManager.EntitySysManager.GetEntitySystem(); var time = Time; if (args is EntityEffectReagentArgs reagentArgs) time *= reagentArgs.Scale.Float(); switch (Type) { case StatusEffectMetabolismType.Update: if (Crawling) { stunSys.TryCrawling(args.TargetEntity, time, drop: Drop); } else { stunSys.TryKnockdown(args.TargetEntity, time, drop: Drop); } break; case StatusEffectMetabolismType.Add: if (Crawling) { stunSys.TryCrawling(args.TargetEntity, time, false, drop: Drop); } else { stunSys.TryKnockdown(args.TargetEntity, time, false, drop: Drop); } break; case StatusEffectMetabolismType.Remove: stunSys.AddKnockdownTime(args.TargetEntity, -time); break; case StatusEffectMetabolismType.Set: if (Crawling) { stunSys.TryCrawling(args.TargetEntity, time, drop: Drop); } else { stunSys.TryKnockdown(args.TargetEntity, time, drop: Drop); } stunSys.SetKnockdownTime(args.TargetEntity, time); break; } } /// protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString( "reagent-effect-guidebook-knockdown", ("chance", Probability), ("type", Type), ("time", Time.TotalSeconds) ); }