Prevent inventory events from being relayed to pockets (#6074)
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
@@ -16,9 +16,9 @@ public partial class InventorySystem
|
||||
SubscribeLocalEvent<InventoryComponent, RefreshMovementSpeedModifiersEvent>(RelayInventoryEvent);
|
||||
}
|
||||
|
||||
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : EntityEventArgs
|
||||
protected void RelayInventoryEvent<T>(EntityUid uid, InventoryComponent component, T args) where T : EntityEventArgs, IInventoryRelayEvent
|
||||
{
|
||||
var containerEnumerator = new ContainerSlotEnumerator(uid, component.TemplateId, _prototypeManager, this);
|
||||
var containerEnumerator = new ContainerSlotEnumerator(uid, component.TemplateId, _prototypeManager, this, args.TargetSlots);
|
||||
while(containerEnumerator.MoveNext(out var container))
|
||||
{
|
||||
if(!container.ContainedEntity.HasValue) continue;
|
||||
@@ -26,3 +26,18 @@ public partial class InventorySystem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Events that should be relayed to inventory slots should implement this interface.
|
||||
/// </summary>
|
||||
public interface IInventoryRelayEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// What inventory slots should this event be relayed to, if any?
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// In general you may want to exclude <see cref="SlotFlags.POCKET"/>, given that those items are not truly
|
||||
/// "equipped" by the user.
|
||||
/// </remarks>
|
||||
public SlotFlags TargetSlots { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user