-- Public Functions

function WaypointPath:MoveTo()
	if self.currentIndex <= #self.waypoints then
		moveToAndWait(self.humanoid, self.waypoints[self.currentIndex].Position)
	else
		self._WaypointReachedEvent:Fire()
		return	
	end
	
	-- Next point
	self.currentIndex = self.currentIndex + 1
				
	-- Fire to listeners
	self._NodeReachedEvent:Fire()

	if self.count < 2 then
		-- Keep moving
		self.count = self.count + 1
		self:MoveTo()
	else
		self.count = 1
		self._FinishedMovingEvent:Fire()
	end
end

function WaypointPath:Stop()	
	self.humanoid:MoveTo(self.humanoidRoot.Position)
end


return WaypointPath
