extends CanvasLayer

@onready var fader: ColorRect = $Fader


func fade_in() -> void:
	print(fader)
	var tween: Tween = create_tween()
	tween.tween_interval(0.1)
	tween.tween_property(fader, "color:a", 0.0, 1.0).from(1.0)
	
func change_scene(new_scene: PackedScene, player: Player) -> void:
	var tween: Tween = create_tween()
	tween.tween_property(fader, "color:a", 1.0, 1.0)
	tween.tween_interval(0.1)
	tween.tween_callback(func() -> void:
		PersistentData.cache_player_data(player)
		PersistentData.cache_gear(player)
		get_tree().get_root().get_node("Main").change_level(new_scene)
	)
