using Content.Shared.Actions.Components; using Content.Shared.Changeling.Systems; using Content.Shared.Ghost; using Content.Shared.Ghost.Systems; using Content.Shared.Mobs; namespace Content.Shared.Actions; public abstract partial class SharedActionsSystem { private void InitializeRelay() { SubscribeLocalEvent(RefRelayActionEvent); SubscribeLocalEvent(RefRelayActionEvent); SubscribeLocalEvent(RefRelayActionEvent); } private void RefRelayActionEvent(EntityUid uid, ActionsComponent component, ref T args) where T : struct { RelayEvent((uid, component), ref args); } private void RelayActionEvent(EntityUid uid, ActionsComponent component, T args) where T : class { RelayEvent((uid, component), args); } public void RelayEvent(Entity ent, ref T args) where T : struct { // this copies the by-ref event if it is a struct var ev = new ActionRelayedEvent(args); foreach (var action in ent.Comp.Actions) { RaiseLocalEvent(action, ref ev); } // and now we copy it back args = ev.Args; } public void RelayEvent(Entity ent, T args) where T : class { // this copies the by-ref event if it is a struct var ev = new ActionRelayedEvent(args); foreach (var action in ent.Comp.Actions) { RaiseLocalEvent(action, ref ev); } } } /// /// Event wrapper for relayed events. /// [ByRefEvent] public record struct ActionRelayedEvent(TEvent Args) { public TEvent Args = Args; }