extends Control

@onready var mp_scene = preload("res://scene/ui/item/mp_item.tscn")

@onready var hp_bar = $HpBar as TextureProgressBar
@onready var mp_sub_bar = $MpSubBar as TextureProgressBar
@onready var mp_list = $MpList as HBoxContainer

func on_hp_max_changed(value:float):
	hp_bar.max_value = value
	
func on_hp_changed(value:float):
	hp_bar.value = value
	
func on_mp_sub_max_changed(value:float):
	mp_sub_bar.max_value = value
	
func on_mp_sub_changed(value:float):
	mp_sub_bar.value = value
	
func on_mp_max_changed(value:int):
	for child in mp_list.get_children():
		child.queue_free()
	for i in range(value):
		var mp_item = mp_scene.instantiate() as MpItemSub
		mp_list.add_child(mp_item)
	
func on_mp_changed(value:int):
	for i in range(mp_list.get_child_count()):
		var mp_item = mp_list.get_child(i) as MpItemSub
		mp_item.set_active(i<value)	
