:NAME walk_to_exit

:VAR s_vector2d		exit_point

function attach(object)
	local player_control= object._c.player_control
	player_control.disabled= true
end

function compute_exit_point()

	var.exit_point.x= 0
	var.exit_point.y= 0

	local exit= object_get("exit")
	if (exit) then
		local marker= exit.marker_get("exit")
		
		local pos= marker.world_position_get(exit)
		
		var.exit_point.x= pos.x
		var.exit_point.y= pos.y
		
	end
	
	return true

end


function already_exited(object)
	local player_control= object._c.player_control
	local result= false
	if (player_control) then
		result= player_control.exited
	end
	
	return result
end

function update(object)
	if ((not already_exited(object)) and compute_exit_point()) then
		local path= object.path_get()
		if (path) then
			local world= world_get()
			path.move_to_point(world.arena, var.exit_point.x, var.exit_point.y);
		end
	end
	sleep()
end


component_register(attach, update, nil, nil)
