Prevent inventory events from being relayed to pockets (#6074)
Co-authored-by: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com>
This commit is contained in:
@@ -86,32 +86,38 @@ public partial class InventorySystem : EntitySystem
|
||||
private readonly InventorySystem _inventorySystem;
|
||||
private readonly EntityUid _uid;
|
||||
private readonly SlotDefinition[] _slots;
|
||||
private int _nextIdx = int.MaxValue;
|
||||
private readonly SlotFlags _flags;
|
||||
private int _nextIdx = 0;
|
||||
|
||||
public ContainerSlotEnumerator(EntityUid uid, string prototypeId, IPrototypeManager prototypeManager, InventorySystem inventorySystem)
|
||||
public ContainerSlotEnumerator(EntityUid uid, string prototypeId, IPrototypeManager prototypeManager, InventorySystem inventorySystem, SlotFlags flags = SlotFlags.All)
|
||||
{
|
||||
_uid = uid;
|
||||
_inventorySystem = inventorySystem;
|
||||
_flags = flags;
|
||||
|
||||
if (prototypeManager.TryIndex<InventoryTemplatePrototype>(prototypeId, out var prototype))
|
||||
{
|
||||
_slots = prototype.Slots;
|
||||
if(_slots.Length > 0)
|
||||
_nextIdx = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_slots = Array.Empty<SlotDefinition>();
|
||||
}
|
||||
}
|
||||
|
||||
public bool MoveNext([NotNullWhen(true)] out ContainerSlot? container)
|
||||
{
|
||||
container = null;
|
||||
if (_nextIdx >= _slots.Length) return false;
|
||||
|
||||
while (_nextIdx < _slots.Length && !_inventorySystem.TryGetSlotContainer(_uid, _slots[_nextIdx++].Name, out container, out _)) { }
|
||||
while (_nextIdx < _slots.Length)
|
||||
{
|
||||
var slot = _slots[_nextIdx];
|
||||
_nextIdx++;
|
||||
|
||||
return container != null;
|
||||
if ((slot.SlotFlags & _flags) == 0)
|
||||
continue;
|
||||
|
||||
if (_inventorySystem.TryGetSlotContainer(_uid, slot.Name, out container, out _))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user