extends Node2D class_name Piece @export var piece_name: String = "" var cells: Array[Cell] = [] var block_size: int = 0 var cell_grid: Array[Vector2i] = [] func _ready() -> void: for c in self.get_children(): if c is Cell: cells.append(c) # all cells must have same block size for c in cells: if block_size == 0: block_size = c.block_size else: assert(block_size == c.block_size, "All cells must have same block size") # build cell grid coordinates for c in cells: var pos_x: int = floori(c.position.x / block_size) var pos_y: int = floori(c.position.y / block_size) cell_grid.append(Vector2i(pos_x, pos_y)) func _to_string() -> String: return str(cell_grid)