local q=Vector3_new(1,1,1)local function U()return q end local function j(q)if getAutoJump()and enableAutoJump()then local q=U()if not vec3IsZero(q)then doAutoJump()end end end local function Z()local q={}local U=false local Z=nil function q.Run(j)U=true local K=nil K=coroutine.create(function()while U and K==Z do q:Step()wait()end end)Z=K coroutine.resume(K)end function q.Stop(q)U=false end function q.Step(q)j()end return q end
-- NOTE: This function is radically different from the engine's implementation
local walkVelocityVector = Vector3_new(1, 1, 1)
local function calcDesiredWalkVelocity()
	-- TEMP
	return walkVelocityVector
end

local function preStepSimulatorSide(dt)
	if getAutoJump() and enableAutoJump() then
		local desiredWalkVelocity = calcDesiredWalkVelocity()
		if not vec3IsZero(desiredWalkVelocity) then
			doAutoJump()
		end
	end
end

local function AutoJumper()
	local this = {}
	local running = false
	local runRoutine = nil

	function this:Run()
		running = true
		local thisRoutine = nil
		thisRoutine = coroutine.create(function()
			while running and thisRoutine == runRoutine do
				this:Step()
				wait()
			end
		end)
		runRoutine = thisRoutine
		coroutine.resume(thisRoutine)
	end

	function this:Stop()
		running = false
	end

	function this:Step()
		preStepSimulatorSide()
	end

	return this
end
