extends Node2D
class_name Room

const COLORS: Array[CompressedTexture2D] = [
	preload("res://assets/textures/room/base_floor_red.png"),
	preload("res://assets/textures/room/base_floor_orange.png"),
	preload("res://assets/textures/room/base_floor_yellow.png"),
	preload("res://assets/textures/room/base_floor_green.png"),
	preload("res://assets/textures/room/base_floor_purple.png"),
]

@onready var base_floor: Sprite2D = $BaseFloor

func _ready():
	var health_bar: HealthBar = get_tree().get_first_node_in_group("health_bar")
	if health_bar != null:
		health_bar.health_changed.connect(_on_life_changed)

func _on_life_changed(new_life: int):
	base_floor.texture = COLORS[(new_life - 1) / 2]
