Files
net-gunner/scripts/pawn_display.gd

40 lines
1.3 KiB
GDScript

class_name PawnDisplay extends Panel
@onready var pawn_name : Label = %PawnName
@onready var hack_container : HBoxContainer = %HackContainer
@onready var portrait : TextureRect = $Portrait
@onready var portrait_blinder : TextureRect = $PortraitBlinder
var hacks : Array = []
var swap_portrait_tween : Tween = null
func _ready() -> void:
for child in hack_container.get_children():
hacks.append(child)
func set_hacks(hack_list : Array[HackSet]) -> void:
var hcount = 0
if len(hack_list) != 3:
return
for hack in hacks:
hack.setup(hack_list[hcount].type, hack_list[hcount].qty)
hcount+=1
func set_portrait(picture : Texture2D) -> void:
if swap_portrait_tween != null and swap_portrait_tween.is_running():
swap_portrait_tween.stop()
swap_portrait_tween = create_tween()
swap_portrait_tween.tween_property(portrait_blinder, "visible", true, 0)
swap_portrait_tween.tween_method(tv_blur, 1.0, 0.0, .1)
swap_portrait_tween.tween_property(portrait, "texture", picture, 0)
swap_portrait_tween.tween_method(tv_blur, 0.0, 1.0, .1)
swap_portrait_tween.tween_property(portrait_blinder, "visible", false, 0)
portrait.texture = picture
func tv_blur(amount : float) -> void:
var blinder_mat : ShaderMaterial = portrait_blinder.material
blinder_mat.set_shader_parameter("opacity_limit", amount)
func set_pawn_name(p_name : String) -> void:
pawn_name.text = p_name