using Content.Shared.Interaction.Events; using Content.Shared.Mech.Components; namespace Content.Shared.Mech.EntitySystems; public abstract partial class SharedMechSystem { private void InitializeRelay() { SubscribeLocalEvent(RelayRefToPilot); } private void RelayToPilot(Entity uid, T args) where T : class { if (uid.Comp.PilotSlot.ContainedEntity is not { } pilot) return; var ev = new MechPilotRelayedEvent(args); RaiseLocalEvent(pilot, ref ev); } private void RelayRefToPilot(Entity uid, ref T args) where T :struct { if (uid.Comp.PilotSlot.ContainedEntity is not { } pilot) return; var ev = new MechPilotRelayedEvent(args); RaiseLocalEvent(pilot, ref ev); args = ev.Args; } } [ByRefEvent] public record struct MechPilotRelayedEvent(TEvent Args) { public TEvent Args = Args; }