using Content.Shared.Body.Events; using Content.Shared.Atmos; using Content.Shared.Chat; using Content.Shared.Chemistry.Events; using Content.Shared.Climbing.Events; using Content.Shared.Cuffs; using Content.Shared.Damage.Events; using Content.Shared.Damage.Systems; using Content.Shared.Examine; using Content.Shared.Eye.Blinding.Systems; using Content.Shared.Flash; using Content.Shared.Hands; using Content.Shared.Medical; using Content.Shared.Mobs; using Content.Shared.Mobs.Events; using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.NightVision; using Content.Shared.Overlays; using Content.Shared.Rejuvenate; using Content.Shared.Speech; using Content.Shared.Speech.EntitySystems; using Content.Shared.StatusEffectNew.Components; using Content.Shared.Stunnable; using Content.Shared.Throwing; using Content.Shared.Weapons.Ranged.Events; using Robust.Shared.Collections; 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(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); // By Ref Events SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent, before: new[] { typeof(VocalSystem) }); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent, before: new[] { typeof(VocalSystem), typeof(MumbleAccentSystem) }); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); SubscribeLocalEvent(RefRelayStatusEffectEvent); } 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 { if(statusEffect.Comp.ActiveStatusEffects?.ContainedEntities is not {} originalCollection || originalCollection.Count == 0) return; // this copies the by-ref event if it is a struct var ev = new StatusEffectRelayedEvent(args, statusEffect); // Prevent a collection modified enumeration error by copying the list in case a status adds another status var list = new ValueList(originalCollection); foreach (var activeEffect in list) { RaiseLocalEvent(activeEffect, ref ev); } // and now we copy it back args = ev.Args; } public void RelayEvent(Entity statusEffect, T args) where T : class { if (statusEffect.Comp.ActiveStatusEffects?.ContainedEntities is not { } originalCollection || originalCollection.Count == 0) return; // this copies the by-ref event if it is a struct var ev = new StatusEffectRelayedEvent(args, statusEffect); // Prevent a collection modified enumeration error by copying the list in case a status adds another status var list = new ValueList(originalCollection); foreach (var activeEffect in list) { RaiseLocalEvent(activeEffect, ref ev); } } } /// /// Event wrapper for relayed events. /// [ByRefEvent] public record struct StatusEffectRelayedEvent(TEvent Args, EntityUid AppliedTo);