Implements IEnumerable<ItemSlotNode> for IItemContainer.
This commit is contained in:
parent
d12ddc566b
commit
c1aecf21d7
|
@ -16,7 +16,7 @@ namespace ColdMint.scripts.inventory;
|
||||||
///<para>Item containers can store items. Things like backpacks and Hotbars are containers with visual pages.</para>
|
///<para>Item containers can store items. Things like backpacks and Hotbars are containers with visual pages.</para>
|
||||||
///<para>物品容器可以储存物品。像背包和hotbar是具有可视化页面的容器。</para>
|
///<para>物品容器可以储存物品。像背包和hotbar是具有可视化页面的容器。</para>
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
public interface IItemContainer
|
public interface IItemContainer : IEnumerable<ItemSlotNode>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>Can the specified item be added to the container?</para>
|
/// <para>Can the specified item be added to the container?</para>
|
||||||
|
@ -110,6 +110,14 @@ public interface IItemContainer
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
ItemSlotNode? GetItemSlotNode(int index);
|
ItemSlotNode? GetItemSlotNode(int index);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// <para>Gets the item slot for the specified location, equals to <see cref="GetItemSlotNode"/></para>
|
||||||
|
/// <para>获取指定位置的物品槽,等同于<see cref="GetItemSlotNode"/></para>
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
ItemSlotNode? this[int index] => GetItemSlotNode(index);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// <para>If present, remove an item from the slot in the specified location and return it.</para>
|
/// <para>If present, remove an item from the slot in the specified location and return it.</para>
|
||||||
/// <para>如果存在,移除指定位置的槽位中的一个物品并将其返回</para>
|
/// <para>如果存在,移除指定位置的槽位中的一个物品并将其返回</para>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
@ -9,6 +10,8 @@ using ColdMint.scripts.utils;
|
||||||
|
|
||||||
using Godot;
|
using Godot;
|
||||||
|
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
namespace ColdMint.scripts.inventory;
|
namespace ColdMint.scripts.inventory;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -348,4 +351,17 @@ public class UniversalItemContainer : IItemContainer
|
||||||
|
|
||||||
_selectIndex = newSelectIndex;
|
_selectIndex = newSelectIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[MustDisposeResource]
|
||||||
|
public IEnumerator<ItemSlotNode> GetEnumerator()
|
||||||
|
{
|
||||||
|
return _itemSlotNodes?.GetEnumerator() ?? Enumerable.Empty<ItemSlotNode>().GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
[MustDisposeResource]
|
||||||
|
IEnumerator IEnumerable.GetEnumerator()
|
||||||
|
{
|
||||||
|
return GetEnumerator();
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user