Inventory slot enumerator rejig (#21788)

This commit is contained in:
Leon Friedrich
2023-12-07 16:20:51 -05:00
committed by GitHub
parent 445c474c2c
commit 287d22cc49
18 changed files with 238 additions and 342 deletions

View File

@@ -202,17 +202,15 @@ public sealed class ClientClothingSystem : ClothingSystem
revealedLayers.Clear();
}
public void InitClothing(EntityUid uid, InventoryComponent? component = null, SpriteComponent? sprite = null)
public void InitClothing(EntityUid uid, InventoryComponent component)
{
if (!Resolve(uid, ref sprite, ref component) || !_inventorySystem.TryGetSlots(uid, out var slots, component))
if (!TryComp(uid, out SpriteComponent? sprite))
return;
foreach (var slot in slots)
var enumerator = _inventorySystem.GetSlotEnumerator((uid, component));
while (enumerator.NextItem(out var item, out var slot))
{
if (!_inventorySystem.TryGetSlotContainer(uid, slot.Name, out var containerSlot, out _, component) ||
!containerSlot.ContainedEntity.HasValue) continue;
RenderEquipment(uid, containerSlot.ContainedEntity.Value, slot.Name, component, sprite);
RenderEquipment(uid, item, slot.Name, component, sprite);
}
}