extends Node

var current_material = null

func level_hud_slide(node):
	var animation = Animation.new()
	var track_index = animation.add_track(Animation.TYPE_BEZIER)
	var node_element = String(node.get_path()) + ":rect_position:x"
	
	animation.track_set_path(track_index, node_element)
	animation.bezier_track_insert_key(track_index, 0.0, 0.0, Vector2(-0.25, 0), Vector2(0.031, 190.492))
	animation.bezier_track_insert_key(track_index, 1.0, 170, Vector2(-0.349, 2.576), Vector2(0.25, 0))
	
	return animation

func level_hud_warning(node):
	var animation = Animation.new()
	var track_index = animation.add_track(Animation.TYPE_BEZIER)
	var node_element = String(node.get_path()) + ":rect_position:x"
	
	animation.track_set_path(track_index, node_element)
	animation.bezier_track_insert_key(track_index, 0.0, 0.0, Vector2(-0.25, 0), Vector2(0, 78.1))
	animation.bezier_track_insert_key(track_index, 0.2, 34.9, Vector2(-0.25, 0), Vector2(0, -66))
	animation.bezier_track_insert_key(track_index, 0.4, 12.1, Vector2(0, 73.2), Vector2(0, -124.8))
	animation.bezier_track_insert_key(track_index, 0.6, -41.9, Vector2(-0.095, 109.2), Vector2(0.062, -58.8))
	animation.bezier_track_insert_key(track_index, 0.8, 13.3, Vector2(-0.188, 93.6), Vector2(0.196, 104.4))
	animation.bezier_track_insert_key(track_index, 1.0, 0.0, Vector2(-0.155, -135.5), Vector2(0.25, 0))

	return animation

func start_dissolve(node, material):
	current_material = material
	node.interpolate_method(self, "animate_dissolve", 0, 1, 1.5, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
	node.start()

func animate_dissolve(progress: float) -> void:
	current_material.set_shader_param("dissolve_amount", ease(progress, 0.4))
