diff --git a/scripts/inventory/IItemContainer.cs b/scripts/inventory/IItemContainer.cs
index e10b9bd..5adcedb 100644
--- a/scripts/inventory/IItemContainer.cs
+++ b/scripts/inventory/IItemContainer.cs
@@ -16,7 +16,7 @@ namespace ColdMint.scripts.inventory;
///Item containers can store items. Things like backpacks and Hotbars are containers with visual pages.
///物品容器可以储存物品。像背包和hotbar是具有可视化页面的容器。
///
-public interface IItemContainer
+public interface IItemContainer : IEnumerable
{
///
/// Can the specified item be added to the container?
@@ -58,7 +58,7 @@ public interface IItemContainer
///
///
ItemSlotNode? GetSelectItemSlotNode();
-
+
///
/// If present, remove an item from the slot at the currently selected location and return it.
/// 如果存在,移除当前选中位置的槽位中的一个物品并将其返回
@@ -75,7 +75,7 @@ public interface IItemContainer
/// 要取出的数量,小于0的输入代表全部物品
///
///
- IItemStack? PickItemsFromItemSlotBySelectIndex( int value);
+ IItemStack? PickItemsFromItemSlotBySelectIndex(int value);
///
/// Removes an item from the inventory at the currently selected location
@@ -110,6 +110,14 @@ public interface IItemContainer
///
ItemSlotNode? GetItemSlotNode(int index);
+ ///
+ /// Gets the item slot for the specified location, equals to
+ /// 获取指定位置的物品槽,等同于
+ ///
+ ///
+ ///
+ ItemSlotNode? this[int index] => GetItemSlotNode(index);
+
///
/// If present, remove an item from the slot in the specified location and return it.
/// 如果存在,移除指定位置的槽位中的一个物品并将其返回
@@ -128,7 +136,7 @@ public interface IItemContainer
///
///
IItemStack? PickItemsFromItemSlot(int itemSlotIndex, int value);
-
+
///
/// Removes an item from the item slot in the specified location
/// 在指定位置的物品槽内移除物品
diff --git a/scripts/inventory/UniversalItemContainer.cs b/scripts/inventory/UniversalItemContainer.cs
index 6532bac..998cda1 100644
--- a/scripts/inventory/UniversalItemContainer.cs
+++ b/scripts/inventory/UniversalItemContainer.cs
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
@@ -9,6 +10,8 @@ using ColdMint.scripts.utils;
using Godot;
+using JetBrains.Annotations;
+
namespace ColdMint.scripts.inventory;
///
@@ -348,4 +351,17 @@ public class UniversalItemContainer : IItemContainer
_selectIndex = newSelectIndex;
}
+
+
+ [MustDisposeResource]
+ public IEnumerator GetEnumerator()
+ {
+ return _itemSlotNodes?.GetEnumerator() ?? Enumerable.Empty().GetEnumerator();
+ }
+
+ [MustDisposeResource]
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return GetEnumerator();
+ }
}
\ No newline at end of file