fadeOut = 0
fadeIn = 0

function tick(dt)
	if GetBool("level.dispatch") then
		if fadeOut < 3 then
			fadeOut = fadeOut + dt
			PlayMusic("caveisland.ogg")
			SetFloat("game.music.volume", 1-fadeOut/3)
		elseif fadeIn < 3 then
			fadeIn = fadeIn + dt
			PlayMusic("caveisland-hunted.ogg")
			SetFloat("game.music.volume", fadeIn/3)
		else
			PlayMusic("caveisland-hunted.ogg")
		end
	else
		PlayMusic("caveisland.ogg")
	end
end

