extends Node3D
class_name ChunkInfo

@export_enum("Biome", "straight_track", "curved_track") var chunk_type: int = 0

@export_group("Set Piece Rules (Unique pieces)")
@export var exclusive_biome: String = "" # Es: "Forest"

@export_group("Base exit (no roation)")
@export var north: bool = false
@export var est: bool = false
@export var south: bool = false
@export var west: bool = false

@export_group("Margin heights (level 0, 1, 2)")
@export var height_north: int = 0
@export var height_est: int = 0
@export var height_south: int = 0
@export var height_west: int = 0

@export_group("Lamppost")
@export var have_lamppost: bool = false
@export var connection_left: Array[Node3D]
@export var connection_right: Array[Node3D]

func _ready() -> void:
	if exclusive_biome != "":
		add_to_group("set_pieces")

func get_rotated_data(steps_90: int) -> Dictionary:
	var original_exit = [north, est, south, west]
	var original_height = [height_north, height_est, height_south, height_west]
	
	var calculated_exit = []
	var calculated_height = []
	
	for i in range(4):
		var index  = (i - steps_90 + 4) % 4
		calculated_exit.append(original_exit[index])
		calculated_height.append(original_height[index])
		
	return {
		"connections": {
			"north": calculated_exit[0], "est": calculated_exit[1],
			"south": calculated_exit[2], "west": calculated_exit[3]
		},
		"heights": {
			"north": calculated_height[0], "est": calculated_height[1],
			"south": calculated_height[2], "west": calculated_height[3]
		}
	}
