40 lines
941 B
GDScript
40 lines
941 B
GDScript
## Represents a single 3D grid cell on the game board.
|
|
##
|
|
## It's a data structure for occupancy state, owner tetromino, bounds, and
|
|
## visual feedback.
|
|
class_name GridCell
|
|
extends Object
|
|
|
|
# Properties
|
|
var position: Vector3i # Grid coordinates
|
|
var owner: Tetromino = null # Tetromino occupying this cell
|
|
var bounds: AABB = AABB() # 3D axis-aligned bounding box
|
|
|
|
# Visual state
|
|
var is_highlighted: bool = false
|
|
var is_valid_placement: bool = true
|
|
|
|
|
|
## Checks if the cell is currently empty.
|
|
func is_empty() -> bool:
|
|
return owner == null
|
|
|
|
|
|
## Marks the cell as occupied by a tetromino.
|
|
func occupy(tetromino: Tetromino) -> void:
|
|
owner = tetromino
|
|
|
|
|
|
## Marks the cell as empty.
|
|
func clear() -> void:
|
|
owner = null
|
|
|
|
|
|
## Returns a string representation of the cell state.
|
|
func _to_string() -> String:
|
|
return "GridCell3D[pos=%v, occupied=%s, valid=%s]" % [
|
|
position,
|
|
"yes" if owner else "no",
|
|
"yes" if is_valid_placement else "no"
|
|
]
|