:NAME noisemaker_intro_tutorial

:GLOBAL int32					state
:GLOBAL float32					timer
:GLOBAL float32					focus_start_time
:GLOBAL float32					focus_start_scale
:GLOBAL c_object*				focus
:GLOBAL c_object*				message
:GLOBAL c_object*				arrow

local tutoriallib = require "scripts/tutorial_utils"
local state= nil

function global_initialize(g)
	g.state= 0
	g.focus= nil
	g.timer= 0
	g.focus_start_time= 0
	g.focus_start_scale= tutoriallib.k_scale_out	
	g.message= nil
	g.arrow= nil
end

-- ------------------ initial delay and message 1 ------------------

tutoriallib.add_delay(0)

state= tutoriallib.make_state("message1")
tutoriallib.focus_on(state, "noisemaker_marker", 1)

-- ------------------ wait until noisemaker gets picked up ------------------

state= tutoriallib.add_delay(0)
function noisemaker_picked_up()
	local ws= world_state_get()
	local gear_manager= ws.global_script("gear_manager")
	if (gear_manager) then
		if (gear_manager.noise_maker.actual_count > 0) then
			global.focus= object_place("focus_screen")
			global.focus.hide(true)
			return true
		end
	end
end
state.end_func= noisemaker_picked_up

-- ------------------ delay, then highlight the pickup ------------------

tutoriallib.add_delay(0.5)

state= tutoriallib.make_state("message2")
tutoriallib.focus_on(state, "noisemaker_icon_marker", 1.2)
function place_arrow()
	global.arrow= object_place("arrow")
	if (global.arrow) then
		local tween= global.arrow.tween_get()
		if (tween) then
			tween.play_animation_after_delay("fadein", 1.0);
		end
	end
end
state.start_func= place_arrow

state= tutoriallib.add_delay(0.1)
function remove_all_messages()
	tutoriallib.remove_bubble("message1")
	tutoriallib.remove_bubble("message2")
	
	if (global.arrow) then
		global.arrow.tween_animation_play_direction("fadein", false, false);
		global.arrow= nil
	end
end
state.start_func= remove_all_messages


-- ------------ init and update ------------

function global_initialize(g)
	g.state= 0
	g.focus= nil
	g.timer= 0
	g.focus_start_time= 0
	g.focus_start_scale= tutoriallib.k_scale_out	
	g.message= nil
end

function start()

	local world= world_get()
	local ws= world_state_get()
	global.focus= object_place("focus")
	global.focus.hide(true)
	tutoriallib.start()

end


function update()
	tutoriallib.update(k_states, global)
end

system_register(start, update, nil, nil)
