Revert "Fix unintentional inventory relayed event handling " (#12182)
This commit is contained in:
@@ -23,38 +23,15 @@ public partial class InventorySystem
|
||||
|
||||
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : EntityEventArgs, IInventoryRelayEvent
|
||||
{
|
||||
if (args.TargetSlots == SlotFlags.NONE)
|
||||
return;
|
||||
|
||||
var containerEnumerator = new ContainerSlotEnumerator(uid, component.TemplateId, _prototypeManager, this, args.TargetSlots);
|
||||
var ev = new InventoryRelayedEvent<T>(args);
|
||||
while (containerEnumerator.MoveNext(out var container))
|
||||
while(containerEnumerator.MoveNext(out var container))
|
||||
{
|
||||
if (!container.ContainedEntity.HasValue) continue;
|
||||
RaiseLocalEvent(container.ContainedEntity.Value, ev, false);
|
||||
if(!container.ContainedEntity.HasValue) continue;
|
||||
RaiseLocalEvent(container.ContainedEntity.Value, args, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event wrapper for relayed events.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This avoids nested inventory relays, and makes it easy to have certain events only handled by the initial
|
||||
/// target entity. E.g. health based movement speed modifiers should not be handled by a hat, even if that hat
|
||||
/// happens to be a dead mouse. Clothing that wishes to modify movement speed must subscribe to
|
||||
/// InventoryRelayedEvent<RefreshMovementSpeedModifiersEvent>
|
||||
/// </remarks>
|
||||
public sealed class InventoryRelayedEvent<TEvent> : EntityEventArgs where TEvent : EntityEventArgs, IInventoryRelayEvent
|
||||
{
|
||||
public readonly TEvent Args;
|
||||
|
||||
public InventoryRelayedEvent(TEvent args)
|
||||
{
|
||||
Args = args;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events that should be relayed to inventory slots should implement this interface.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user