extends HBoxContainer

class_name CrewPortrait

@onready var texture_rect := $TextureRect
@onready var label := $Label

var mouse_in := false

var call_sign := "TEST"

var textures := {
	"white" : load("res://gfx/official/headshot_V2.png")
}


### 	 ACCESSORS 	 ###






### 	 BUILT-IN 	 ###

func _ready() -> void:
	pass


func _input(event: InputEvent) -> void:
	if mouse_in and event is InputEventMouseButton and  event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
		EVENTS.crew_selected.emit(call_sign)


### 	 VIRTUAL 	 ###





### 	 LOGIC 	 ###

func set_crew(crew_member) -> void:
	call_sign = crew_member.call_sign
	label.text = call_sign
	texture_rect.texture = textures[crew_member.anim_type]
	


### 	 SIGNAL-RESPONSE 	 ###


func _on_mouse_entered() -> void:
	mouse_in = true


func _on_mouse_exited() -> void:
	mouse_in = false
