extends Node

var up_sound = preload("res://audio/coin.ogg")

func play_main_menu_music():
	$FinishMusic.stop()
	$MainMenuMusic.play()
	$GameMusic.stop()

func play_game_music():
	$FinishMusic.stop()
	$MainMenuMusic.stop()
	$GameMusic.play()
	
func play_finish_music():
	$FinishMusic.play()
	$MainMenuMusic.stop()
	$GameMusic.stop()

func play_npc_happy():
	play_sfx("npc_happy")
	
func play_sfx(sfx_name: String):
	var stream = null
	if (sfx_name == "npc_happy"):
		stream = up_sound
	elif (sfx_name == "jump"):
		stream = up_sound
	else:	
		print("Invalid SFX name")
		return
	
	var asp = AudioStreamPlayer.new()
	asp.stream = stream
	asp.name = "SFX"

	add_child(asp)
	asp.play()
	await asp.finished # waits for finished signal from AudioStreamPlayer (class)
	asp.queue_free()
