extends Node2D
class_name LevelTemplate

export(String, FILE) var level_music = "res://assets/music/A Hearty Fellow (LOOP).wav"
export(float) var level_music_attenuation = -20
export(String, FILE) var level_ambiance = "res://assets/sounds/AMBIENCE_SciFi_Large_Space_Hangar_Deep_Smooth_loop_stereo.wav"
export(float) var level_ambiance_attenuation = -23

onready var signal_manager := $"%SignalManager"
onready var level_state := $"%LevelState"

func _ready() -> void:
	$TransitionLayer.visible = true
	var transition_tween = Tween.new()
	add_child(transition_tween)
	var property = "shader_param/position"
	var node = $TransitionLayer/SceneTransition
	transition_tween.interpolate_property(
		node.material, property, -1.5, 1.0, 0.94, Tween.TRANS_LINEAR, Tween.EASE_IN_OUT
	)
	transition_tween.start()
	# should spawn the tutorial thingies which are still remembered in the progress dictionary
	signal_manager.connect("terminal_activated", self, "stop_level_music")
	signal_manager.emit_signal("level_loaded")
	get_tree().paused = false
	$SceneAudio.play_parallel_sound(level_music, level_music_attenuation, false, 1.0, 0, "Music")
	$SceneAudio.play_parallel_sound(level_ambiance, level_ambiance_attenuation)


func stop_level_music(_unused: float) -> void:
	$SceneAudio.stop_parallel_sound(level_music)
