Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private bool IsOverlap(Vector3 position)
- {
- InventoryCell cell = GetCell(position);
- if (cell == null || cell.IsLocked) return true;
- overlappingCells = new List<InventoryCell> { cell };
- overlappingInventory = cell.Inventory;
- int width = overlappingInventory.Grid.GetLength(0);
- int height = overlappingInventory.Grid.GetLength(1);
- //Debug.Log($"w: {width} - h: {height}");
- System.Diagnostics.Stopwatch timer = System.Diagnostics.Stopwatch.StartNew();
- for (int x = 0; x < width; x++)
- {
- for (int y = 0; y < height; y++)
- {
- if (overlappingInventory.Grid[x, y].Equals(cell))
- {
- Vector2Int sizeVector = InventoryUtility.GetItemSizeInArray(size) + Vector2Int.one;
- int w = isOriginalSize ? sizeVector.x : sizeVector.y;
- int h = isOriginalSize ? sizeVector.y : sizeVector.x;
- //Debug.Log($"w: {w} / h: {h}");
- for (int i = 0; i < w; i++)
- {
- for (int j = 0; j < h; j++)
- {
- InventoryCell cellToAdd = overlappingInventory.Grid[x + i, y + j];
- if (cellToAdd.IsLocked) return true;
- if (!overlappingCells.Contains(cellToAdd))
- overlappingCells.Add(cellToAdd);
- }
- }
- //останавливал и здесь, дебажит всеравно 0 мс
- break;
- }
- }
- }
- timer.Stop();
- Debug.Log($"{timer.ElapsedMilliseconds} ms");
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement