SubscribeLocalEvent<InventoryComponent, ElectrocutionAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, SlipAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, BeforeStripEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, SeeIdentityAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, ModifyChangedTemperatureEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, GetDefaultRadioChannelEvent>(RelayInventoryEvent);
+ // by-ref events
+ SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
+
// Eye/vision events
SubscribeLocalEvent<InventoryComponent, CanSeeAttemptEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, GetEyeProtectionEvent>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowHungerIconsComponent>>(RelayInventoryEvent);
SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowThirstIconsComponent>>(RelayInventoryEvent);
- SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetStrippingVerbs);
+ SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetEquipmentVerbs);
}
protected void RefRelayInventoryEvent<T>(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<T>(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<T>(EntityUid uid, InventoryComponent component, T args) where T : IInventoryRelayEvent
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<EquipmentVerb> args)
+ private void OnGetEquipmentVerbs(EntityUid uid, InventoryComponent component, GetVerbsEvent<EquipmentVerb> args)
{
// Automatically relay stripping related verbs to all equipped clothing.
/// </remarks>
public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs
{
- public readonly TEvent Args;
+ public TEvent Args;
public InventoryRelayedEvent(TEvent args)
{
using Content.Shared.Database;
using Content.Shared.Interaction.Events;
+using Content.Shared.Inventory;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;
}
/// <summary>
- /// 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 <see cref="GetVerbsEvent{EquipmentVerb}"/> event to all equipped items via a
+ /// <see cref="InventoryRelayedEvent{T}"/>.
/// </summary>
[Serializable, NetSerializable]
public sealed class EquipmentVerb : Verb