local z=require(script.Parent.BaseMotor)local a=setmetatable({},z)a.__index=a function a.new(h,n)assert(h,"\077\105\115\115\105\110\103 \097\114\103\117\109\101\110\116 \035\049\058 \105\110\105\116\105\097\108\086\097\108\117\101")assert(typeof(h)=="\110\117\109\098\101\114","\105\110\105\116\105\097\108\086\097\108\117\101 \109\117\115\116 \098\101 \097 \110\117\109\098\101\114\033")local P=setmetatable(z.new(),a)if n~=nil then P._useImplicitConnections=n else P._useImplicitConnections=true end P._goal=nil P._state={complete=true;value=h}return P end function a.step(a,z)if a._state.complete then return true end local h=a._goal:step(a._state,z)a._state=h a._onStep:fire(h.value)if h.complete then if a._useImplicitConnections then a:stop()end a._onComplete:fire()end return h.complete end function a.getValue(z)return z._state.value end function a.setGoal(a,z)a._state.complete=false a._goal=z a._onStart:fire()if a._useImplicitConnections then a:start()end end function a.__tostring(z)return"\077\111\116\111\114\040\083\105\110\103\108\101\041"end return a
local BaseMotor = require(script.Parent.BaseMotor)

local SingleMotor = setmetatable({}, BaseMotor)
SingleMotor.__index = SingleMotor

function SingleMotor.new(initialValue, useImplicitConnections)
	assert(initialValue, "Missing argument #1: initialValue")
	assert(typeof(initialValue) == "number", "initialValue must be a number!")

	local self = setmetatable(BaseMotor.new(), SingleMotor)

	if useImplicitConnections ~= nil then
		self._useImplicitConnections = useImplicitConnections
	else
		self._useImplicitConnections = true
	end

	self._goal = nil
	self._state = {
		complete = true,
		value = initialValue,
	}

	return self
end

function SingleMotor:step(deltaTime)
	if self._state.complete then
		return true
	end

	local newState = self._goal:step(self._state, deltaTime)

	self._state = newState
	self._onStep:fire(newState.value)

	if newState.complete then
		if self._useImplicitConnections then
			self:stop()
		end

		self._onComplete:fire()
	end

	return newState.complete
end

function SingleMotor:getValue()
	return self._state.value
end

function SingleMotor:setGoal(goal)
	self._state.complete = false
	self._goal = goal

	self._onStart:fire()

	if self._useImplicitConnections then
		self:start()
	end
end

function SingleMotor:__tostring()
	return "Motor(Single)"
end

return SingleMotor
