extends Node ## Width of the grid in cells. const width := 100 ## Height of the grid in cells. const height := 100 ## The size of a single cell. const cell_size := 10.0 var cells: Array[Cell] func _init(): cells.resize(width * height) for i in cells.size(): cells[i] = Cell.new() func notify_cell_changed(player: Player, old_pos: Vector2i, new_pos: Vector2i): print(player.name, " cell changed! ", old_pos, " ", new_pos) add_player(player, new_pos) remove_player(player, old_pos) func add_player(player: Player, coords: Vector2i): var cell := cells[coords.x + coords.y * height] cell.player_list.append(player) func remove_player(player: Player, coords: Vector2i): var cell := cells[coords.x + coords.y * height] cell.player_list.erase(player)