using Content.Shared.Flash; using Robust.Shared.Audio; using Robust.Shared.Prototypes; namespace Content.Shared.EntityEffects.Effects.Transform; /// /// Creates a Flash at this entity's coordinates. /// Range is modified by scale. /// /// public sealed partial class FlashEntityEffectSystem : EntityEffectSystem { [Dependency] private readonly SharedFlashSystem _flash = default!; [Dependency] private readonly SharedTransformSystem _xform = default!; [Dependency] private readonly SharedPointLightSystem _pointLight = default!; protected override void Effect(Entity entity, ref EntityEffectEvent args) { var range = MathF.Min(args.Scale * args.Effect.RangePerUnit, args.Effect.MaxRange); _flash.FlashArea( entity, null, range, args.Effect.Duration, slowTo: args.Effect.SlowTo, sound: args.Effect.Sound); if (args.Effect.FlashEffectPrototype == null) return; var uid = PredictedSpawnAtPosition(args.Effect.FlashEffectPrototype, _xform.GetMoverCoordinates(entity)); _pointLight.SetRadius(uid, MathF.Max(1.1f, range)); } } /// public sealed partial class Flash : EntityEffectBase { /// /// Flash range per unit of reagent. /// [DataField] public float RangePerUnit = 0.2f; /// /// Maximum flash range. /// [DataField] public float MaxRange = 10f; /// /// How much to entities are slowed down. /// [DataField] public float SlowTo = 0.5f; /// /// The time entities will be flashed. /// The default is chosen to be better than the hand flash so it is worth using it for grenades etc. /// [DataField] public TimeSpan Duration = TimeSpan.FromSeconds(4); /// /// The prototype ID used for the visual effect. /// [DataField] public EntProtoId? FlashEffectPrototype = "ReactionFlash"; /// /// The sound the flash creates. /// [DataField] public SoundSpecifier? Sound = new SoundPathSpecifier("/Audio/Weapons/flash.ogg"); public override string EntityEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys) => Loc.GetString("entity-effect-guidebook-flash-reaction-effect", ("chance", Probability)); }