diff --git a/scripts/inventory/UniversalItemContainer.cs b/scripts/inventory/UniversalItemContainer.cs index 5d47e56..c9e7801 100644 --- a/scripts/inventory/UniversalItemContainer.cs +++ b/scripts/inventory/UniversalItemContainer.cs @@ -67,16 +67,16 @@ public class UniversalItemContainer : IItemContainer public bool AddItemStack(IItemStack itemStack) { - while (true) + ItemSlotNode? itemSlotNode = Match(itemStack); + while (itemSlotNode is not null) { - var itemSlotNode = Match(itemStack); - - if (itemSlotNode == null) - return false; - if (itemSlotNode.AddItemStack(itemStack)) return true; + + itemSlotNode = Match(itemStack); } + + return false; } public int GetSelectIndex() @@ -234,7 +234,7 @@ public class UniversalItemContainer : IItemContainer return; } - itemSlotNode.IsSelect = (_itemSlotNodes.Count ) == _selectIndex; + itemSlotNode.IsSelect = (_itemSlotNodes.Count) == _selectIndex; _itemSlotNodes.Add(itemSlotNode); }