local RunService = game:GetService("RunService")
local Signal = require(script.Parent.Signal)
local noop = function() end
local BaseMotor = {}
BaseMotor.__index = BaseMotor
function BaseMotor.new()
return setmetatable({
_onStep = Signal.new(),
_onStart = Signal.new(),
_onComplete = Signal.new(),
}, BaseMotor)
end
function BaseMotor:onStep(handler)
return self._onStep:connect(handler)
end
function BaseMotor:onStart(handler)
return self._onStart:connect(handler)
end
function BaseMotor:onComplete(handler)
return self._onComplete:connect(handler)
end
function BaseMotor:start()
if not self._connection then
self._connection = RunService.RenderStepped:Connect(function(deltaTime)
self:step(deltaTime)
end)
end
end
function BaseMotor:stop()
if self._connection then
self._connection:Disconnect()
self._connection = nil
end
end
BaseMotor.destroy = BaseMotor.stop
BaseMotor.step = noop
BaseMotor.getValue = noop
BaseMotor.setGoal = noop
function BaseMotor:__tostring()
return "Motor"
end
return BaseMotor