Mooege.Core.GS.Common.InventoryGrid.CollectOverlappingItems C# (CSharp) Метод

CollectOverlappingItems() приватный Метод

Collects (counts) the items overlapping with the item about to be dropped. If there are none, drop item If there is exacly one, swap it with item (TODO) If there are more, item cannot be dropped
private CollectOverlappingItems ( Item item, int row, int column ) : int
item Item
row int
column int
Результат int
        private int CollectOverlappingItems(Item item, int row, int column)
        {
            InventorySize dropSize = GetItemInventorySize(item);
            var overlapping = new List<uint>();

            // For every slot...
            for (int r = row; r < _backpack.GetLength(0) && r < row + dropSize.Height; r++)
                for (int c = column; c < _backpack.GetLength(1) && c < column + dropSize.Width; c++)

                    // that contains an item other than the one we want to drop
                    if (_backpack[r, c] != 0 && _backpack[r, c] != item.DynamicID) //TODO this would break for an item with id 0

                        // add it to the list if if dropping the item in <row, column> would need the same slot
                        //if (r >= row && r <= row + dropSize.Height)
                        //    if (c >= column && c <= column + dropSize.Width)
                        if (!overlapping.Contains(_backpack[r, c]))
                            overlapping.Add(_backpack[r, c]);

            return overlapping.Count;
        }