♻️ Better miner tile
This commit is contained in:
		| @@ -51,7 +51,7 @@ public partial class GridManager : Node | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public Node2D? GetBuildingAtCell(Vector2I cell, GridLayer layer = GridLayer.Building) | ||||
|     public Node2D? GetTileAtCell(Vector2I cell, GridLayer layer = GridLayer.Building) | ||||
|     { | ||||
|         return _layers[layer].TryGetValue(cell, out var data) ? data.Building : null; | ||||
|     } | ||||
|   | ||||
| @@ -229,7 +229,7 @@ public partial class PlacementManager : Node2D | ||||
|                 // Check if the area is occupied by under-construction tiles | ||||
|                 var occupiedCells = GridUtils.GetOccupiedCells(_hoveredCell, building.Size, _currentRotation); | ||||
|                 var isUnderConstruction = occupiedCells.Any(cell => | ||||
|                     Grid.GetBuildingAtCell(cell, building.Layer) is BaseTile { IsConstructing: true }); | ||||
|                     Grid.GetTileAtCell(cell, building.Layer) is BaseTile { IsConstructing: true }); | ||||
|  | ||||
|                 if (!isUnderConstruction) | ||||
|                     _cannotDeploySound.Play(); | ||||
| @@ -289,7 +289,7 @@ public partial class PlacementManager : Node2D | ||||
|             !Grid.IsAreaFree(_hoveredCell, Vector2I.One, 0f)) | ||||
|         { | ||||
|             // Right click to destroy from current layer | ||||
|             var building = Grid.GetBuildingAtCell(_hoveredCell); | ||||
|             var building = Grid.GetTileAtCell(_hoveredCell); | ||||
|             if (building == null) return; | ||||
|  | ||||
|             // Find all cells occupied by this building | ||||
| @@ -426,7 +426,7 @@ public static class GridManagerExtensions | ||||
|     public static (Vector2I Position, Vector2I Size, float Rotation)? GetBuildingInfoAtCell(this GridManager grid, | ||||
|         Vector2I cell, GridLayer layer) | ||||
|     { | ||||
|         if (grid.GetBuildingAtCell(cell, layer) is { } building) | ||||
|         if (grid.GetTileAtCell(cell, layer) is { } building) | ||||
|         { | ||||
|             // Find the top-left position of the building | ||||
|             for (int x = 0; x < 100; x++) // Arbitrary max size | ||||
| @@ -434,16 +434,16 @@ public static class GridManagerExtensions | ||||
|                 for (int y = 0; y < 100; y++) | ||||
|                 { | ||||
|                     var checkCell = new Vector2I(cell.X - x, cell.Y - y); | ||||
|                     if (grid.GetBuildingAtCell(checkCell, layer) == building) | ||||
|                     if (grid.GetTileAtCell(checkCell, layer) == building) | ||||
|                     { | ||||
|                         // Found the top-left corner, now find the size | ||||
|                         var size = Vector2I.One; | ||||
|                         // Search right | ||||
|                         while (grid.GetBuildingAtCell(new Vector2I(checkCell.X + size.X, checkCell.Y), layer) == | ||||
|                         while (grid.GetTileAtCell(new Vector2I(checkCell.X + size.X, checkCell.Y), layer) == | ||||
|                                building) | ||||
|                             size.X++; | ||||
|                         // Search down | ||||
|                         while (grid.GetBuildingAtCell(new Vector2I(checkCell.X, checkCell.Y + size.Y), layer) == | ||||
|                         while (grid.GetTileAtCell(new Vector2I(checkCell.X, checkCell.Y + size.Y), layer) == | ||||
|                                building) | ||||
|                             size.Y++; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user