extends Control

@onready var sub_item_list = [$LockItem,$CoreItem,$WeaponItem,$PlayerStatusItem]

func _ready():
	SignalManager.character_status_changed.connect(on_character_status_changed)

func on_character_status_changed(id:int,status_name:String,value):
	if id != Global.character_mgr.get_player_id():
		return
	var func_name = "on_%s_changed" % status_name
	for sub_item in sub_item_list:
		if sub_item.has_method(func_name):
			sub_item.call(func_name,value)

func input_action_pressed(key:String):
	match key:
		"menu":
			Global.ui_mgr.close("hud")
			Global.ui_mgr.pause_open("menu")
		"status":
			Global.ui_mgr.close("hud")
			Global.ui_mgr.pause_open("status")
