using Content.Shared.Botany.Components; using Content.Shared.Interaction; namespace Content.Shared.Botany.Systems; public sealed partial class PlantHolderSystem { [Dependency] private PlantSystem _plant = default!; private void InitializeRelay() { SubscribeLocalEvent(RelayPlantHolderEvent); } private void RefRelayPlantHolderEvent(EntityUid uid, PlantHolderComponent component, ref T args) where T : struct { RelayEvent((uid, component), ref args); } private void RelayPlantHolderEvent(EntityUid uid, PlantHolderComponent component, T args) where T : class { RelayEvent((uid, component), args); } /// /// Relays the given event to the tray holding the plant. /// /// The plant which is receiving the event /// The event to relay /// The type of the event public void RelayEvent(Entity ent, ref T args) where T : struct { if (!_plant.TryGetTray(ent.Owner, out var tray)) return; var ev = new PlantHolderRelayedEvent(args, ent); RaiseLocalEvent(tray, ref ev); args = ev.Args; } /// /// Relays the given event to the tray holding the plant. /// /// The plant which is receiving the event /// The event to relay /// The type of the event public void RelayEvent(Entity ent, T args) where T : class { if (!_plant.TryGetTray(ent.Owner, out var tray)) return; var ev = new PlantHolderRelayedEvent(args, ent); RaiseLocalEvent(tray, ref ev); } } /// /// Event wrapper for events being relayed to plant trays holding a plant. /// [ByRefEvent] public record struct PlantHolderRelayedEvent(TEvent Args, EntityUid AppliedTo);