using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.Rejuvenate; using Content.Shared.Speech; using Content.Shared.StatusEffectNew.Components; using Content.Shared.Stunnable; using Robust.Shared.Player; namespace Content.Shared.StatusEffectNew; public sealed partial class StatusEffectsSystem { private void InitializeRelay() { SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); } private void RefRelayStatusEffectEvent(EntityUid uid, StatusEffectContainerComponent component, ref T args) where T : struct { RelayEvent((uid, component), ref args); } private void RelayStatusEffectEvent(EntityUid uid, StatusEffectContainerComponent component, T args) where T : class { RelayEvent((uid, component), args); } public void RelayEvent(Entity statusEffect, ref T args) where T : struct { // this copies the by-ref event if it is a struct var ev = new StatusEffectRelayedEvent(args); foreach (var activeEffect in statusEffect.Comp.ActiveStatusEffects?.ContainedEntities ?? []) { RaiseLocalEvent(activeEffect, ref ev); } // and now we copy it back args = ev.Args; } public void RelayEvent(Entity statusEffect, T args) where T : class { // this copies the by-ref event if it is a struct var ev = new StatusEffectRelayedEvent(args); foreach (var activeEffect in statusEffect.Comp.ActiveStatusEffects?.ContainedEntities ?? []) { RaiseLocalEvent(activeEffect, ref ev); } } } /// /// Event wrapper for relayed events. /// [ByRefEvent] public record struct StatusEffectRelayedEvent(TEvent Args);