extends Node3D
@export var ground_tile: PackedScene
@export var map_width: int = 500
@export var map_height: int = 500
@export var tile_size: float = 1.0 # Size of each tile (adjust based on your tile model)

func _ready() -> void:
	Log.pr('Testing tile map generation')
	create_tiles()

func create_tiles() -> void:
	Log.pr('I am going to put down some tiles...')
	
	if not ground_tile:
		Log.pr('Error: ground_tile scene is not assigned!')
		return
	
	# Calculate the starting position to center the grid
	var start_x = - (map_width * tile_size) / 2.0
	var start_z = - (map_height * tile_size) / 2.0
	
	# Generate tiles in a grid pattern
	for x in range(map_width):
		for z in range(map_height):
			# Instantiate the tile scene
			var tile_instance = ground_tile.instantiate()
			
			# Calculate world position
			var world_pos = Vector3(
				start_x + (x * tile_size),
				0, # Y position - adjust if needed
				start_z + (z * tile_size)
			)
			
			# Set the position
			tile_instance.position = world_pos
			
			# Add to the scene tree
			add_child(tile_instance)
	
	Log.pr('Finished creating %d tiles (%dx%d grid)' % [map_width * map_height, map_width, map_height])