diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index aa007c61c0..5e5af03c17 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -116,8 +116,7 @@ public sealed partial class ExplosionSystem : EntitySystem private void RelayedResistance(EntityUid uid, ExplosionResistanceComponent component, InventoryRelayedEvent args) { - var a = args.Args; - OnGetResistance(uid, component, ref a); + OnGetResistance(uid, component, ref args.Args); } private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, ref GetExplosionResistanceEvent args) diff --git a/Content.Shared/Inventory/InventorySystem.Relay.cs b/Content.Shared/Inventory/InventorySystem.Relay.cs index 83b47542e2..fbe744911f 100644 --- a/Content.Shared/Inventory/InventorySystem.Relay.cs +++ b/Content.Shared/Inventory/InventorySystem.Relay.cs @@ -24,12 +24,14 @@ public partial class InventorySystem SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); - SubscribeLocalEvent(RefRelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); + // by-ref events + SubscribeLocalEvent(RefRelayInventoryEvent); + // Eye/vision events SubscribeLocalEvent(RelayInventoryEvent); SubscribeLocalEvent(RelayInventoryEvent); @@ -41,22 +43,24 @@ public partial class InventorySystem SubscribeLocalEvent>(RelayInventoryEvent); SubscribeLocalEvent>(RelayInventoryEvent); - SubscribeLocalEvent>(OnGetStrippingVerbs); + SubscribeLocalEvent>(OnGetEquipmentVerbs); } protected void RefRelayInventoryEvent(EntityUid uid, InventoryComponent component, ref T args) where T : IInventoryRelayEvent { - // Just so I don't have to update 20 morbillion events at once. - if (args.TargetSlots == SlotFlags.NONE) - return; - var containerEnumerator = new ContainerSlotEnumerator(uid, component.TemplateId, _prototypeManager, this, args.TargetSlots); + + // this copies the by-ref event var ev = new InventoryRelayedEvent(args); + while (containerEnumerator.MoveNext(out var container)) { if (!container.ContainedEntity.HasValue) continue; - RaiseLocalEvent(container.ContainedEntity.Value, ev, broadcast: false); + RaiseLocalEvent(container.ContainedEntity.Value, ev); } + + // and now we copy it back + args = ev.Args; } protected void RelayInventoryEvent(EntityUid uid, InventoryComponent component, T args) where T : IInventoryRelayEvent @@ -69,11 +73,11 @@ public partial class InventorySystem while (containerEnumerator.MoveNext(out var container)) { if (!container.ContainedEntity.HasValue) continue; - RaiseLocalEvent(container.ContainedEntity.Value, ev, broadcast: false); + RaiseLocalEvent(container.ContainedEntity.Value, ev); } } - private void OnGetStrippingVerbs(EntityUid uid, InventoryComponent component, GetVerbsEvent args) + private void OnGetEquipmentVerbs(EntityUid uid, InventoryComponent component, GetVerbsEvent args) { // Automatically relay stripping related verbs to all equipped clothing. @@ -112,7 +116,7 @@ public partial class InventorySystem /// public sealed class InventoryRelayedEvent : EntityEventArgs { - public readonly TEvent Args; + public TEvent Args; public InventoryRelayedEvent(TEvent args) { diff --git a/Content.Shared/Verbs/Verb.cs b/Content.Shared/Verbs/Verb.cs index 76ed207307..660a3bdf94 100644 --- a/Content.Shared/Verbs/Verb.cs +++ b/Content.Shared/Verbs/Verb.cs @@ -1,5 +1,6 @@ using Content.Shared.Database; using Content.Shared.Interaction.Events; +using Content.Shared.Inventory; using Robust.Shared.Serialization; using Robust.Shared.Utility; @@ -349,9 +350,10 @@ namespace Content.Shared.Verbs } /// - /// Verbs specifically for interactions that occur with equipped entities. These verbs should be accessible via - /// the stripping UI, and may optionally also be accessible via a verb on the equipee if the via inventory relay - /// events.get-verbs event. + /// Verbs specifically for interactions that occur with equipped entities. These verbs are unique in that they + /// can be used via the stripping UI. Additionally, when getting verbs on an entity with an inventory it will + /// these automatically relay the event to all equipped items via a + /// . /// [Serializable, NetSerializable] public sealed class EquipmentVerb : Verb